Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,8 @@ const (
// CreatedByLabel is the label key that indicates an object was
// created on behalf of a VM Operator VM. The value is the name of a VM.
CreatedByLabel = "vmoperator.vmware.com/created-by"

// NoUnmanagedVolumesRegisterAnnotationKey is the annotation to not create any CNSRegisterVolumes
// by skipping the unmanaged volume register reconcile.
NoUnmanagedVolumesRegisterAnnotationKey = "vmoperator.vmware.com/no-unmanaged-volumes-register"
Copy link
Contributor

@faisalabujabal faisalabujabal Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally not a fan of the no prefix. what do you think of one of those?

  • disallow-register-unmanaged-volumes
  • disallow-unmanaged-volumes-register
  • prevent-unmanaged-volumes-register
  • prevent-register-unmanaged-volumes

)
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ func (r reconciler) Reconcile(

logger := pkglog.FromContextOrDefault(ctx)

if _, ok := vm.Annotations[pkgconst.NoUnmanagedVolumesRegisterAnnotationKey]; ok {
logger.Info("Skipping register unmanaged volumes because of annotation")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we log the annotation here?

pkgcond.MarkFalse(
vm,
Condition,
"NoUnmanagedVolumesRegisterAnnotation",
"")
return nil
}

// Check if the VM is in the middle of promoting linked cloned disks.
for _, t := range pkgctx.GetVMRecentTasks(ctx) {
// If so, then return early.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,26 @@ var _ = Describe("Reconcile", func() {
configSpec)).To(Succeed())
})
})

When("VM has NoUnmanagedVolumesRegisterAnnotationKey annotation", func() {
BeforeEach(func() {
vm.Annotations[pkgconst.NoUnmanagedVolumesRegisterAnnotationKey] = ""
})

It("should return nil without error and update condition", func() {
Expect(unmanagedvolsreg.Reconcile(
ctx,
k8sClient,
vimClient,
vm,
moVM,
configSpec)).To(Succeed())
cond := pkgcond.Get(vm, unmanagedvolsreg.Condition)
Expect(cond).ToNot(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
Expect(cond.Reason).To(Equal("NoUnmanagedVolumesRegisterAnnotation"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we have a assertion that we didn't register any volumes

})
})
})

Context("PVC creation and management", func() {
Expand Down