vmware-tanzu/vm-operator

🔥 Update v1alpha1 VirtualMachineImage to Namespace-scoped

Open

#84 opened on Mar 14, 2023

 (0 comments) (0 reactions) (0 assignees)Go (78 forks)auto 404
help wanted

Repository metrics

Stars
 (130 stars)
PR merge metrics
 (PR metrics pending)

Description

❗❗ This issue should be handled ASAP ❗ ❗

Now that the Image Registry API is enabled on Supervisor, the v1alpha1 VirtualMachineImage needs to be changed to Namespace-scoped. This results in a few errors:

  • The message an empty namespace may not be set during creation during tests that require a dummy image, ex.

    STEP: Creating a temporary namespace
    • Failure in Spec Setup (BeforeEach) [0.033 seconds]
    Integration tests
    /home/runner/work/vm-operator/vm-operator/test/builder/test_suite.go:252
      Invoking Create
      /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:21
        create table [BeforeEach]
        /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:102
          should work
          /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:103
    
          Unexpected error:
              <*errors.errorString | 0xc0008d3af0>: {
                  s: "an empty namespace may not be set during creation",
              }
              an empty namespace may not be set during creation
          occurred
    
          /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:82
    
  • This would seem like a straight-forward fix, ex.

    diff --git a/test/builder/util.go b/test/builder/util.go
    index bcc89d5a..6451a988 100644
    --- a/test/builder/util.go
    +++ b/test/builder/util.go
    @@ -340,10 +340,11 @@ func DummyVirtualMachineSetResourcePolicy2(name, namespace string) *vmopv1.Virtu
     	}
     }
     
    -func DummyVirtualMachineImage(imageName string) *vmopv1.VirtualMachineImage {
    +func DummyVirtualMachineImage(imageName, namespace string) *vmopv1.VirtualMachineImage {
     	return &vmopv1.VirtualMachineImage{
     		ObjectMeta: metav1.ObjectMeta{
    -			Name: imageName,
    +			Name:      imageName,
    +			Namespace: namespace,
     		},
     		Spec: vmopv1.VirtualMachineImageSpec{
     			ProductInfo: vmopv1.VirtualMachineImageProductInfo{
    
  • However, this breaks much of the rest of the test framework as it does not ever expect a Namespace is required to setup the world when creating dummy images, ex.

    Summarizing 12 Failures:
    
    [Fail] Integration tests Invoking Create [BeforeEach] create table should work 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:82
    
    [Fail] Integration tests Invoking Create [BeforeEach] create table should work for cluster vm image 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:82
    
    [Fail] Integration tests Invoking Create [BeforeEach] create table should not work for invalid image name 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:82
    
    [Fail] Integration tests Invoking Update [BeforeEach] when update is performed with changed image name should deny the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:123
    
    [Fail] Integration tests Invoking Update [BeforeEach] when update is performed with changed storageClass name should deny the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:123
    
    [Fail] Integration tests Invoking Update [BeforeEach] VirtualMachine update while VM is powered on when Ports are updated rejects the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:123
    
    [Fail] Integration tests Invoking Update [BeforeEach] VirtualMachine update while VM is powered on when VmMetadata is updated rejects the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:123
    
    [Fail] Integration tests Invoking Update [BeforeEach] VirtualMachine update while VM is powered on when NetworkInterfaces are updated rejects the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:123
    
    [Fail] Integration tests Invoking Update [BeforeEach] VirtualMachine update while VM is powered on when Volumes are updated when a vSphere volume is added rejects the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:123
    
    [Fail] Integration tests Invoking Update [BeforeEach] VirtualMachine update while VM is powered on when Volumes are updated when a PV is added does not reject the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:123
    
    [Fail] Integration tests Invoking Update [BeforeEach] VirtualMachine update while VM is powered on when AdvancedOptions VolumeProvisioningOptions are updated rejects the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:123
    
    [Fail] Integration tests Invoking Delete [BeforeEach] when delete is performed should allow the request 
    /home/runner/work/vm-operator/vm-operator/webhooks/virtualmachine/validation/virtualmachine_validator_intg_test.go:280
    
    Ran 12 of 12 Specs in 13.812 seconds
    FAIL! -- 0 Passed | 12 Failed | 0 Pending | 0 Skipped
    

Contributor guide