diff --git a/manifests/deploy/deploy.yaml b/manifests/deploy/deploy.yaml index a6ff43b..c05adf7 100644 --- a/manifests/deploy/deploy.yaml +++ b/manifests/deploy/deploy.yaml @@ -208,7 +208,7 @@ webhooks: resources: # TODO: correct logic if we ever need to account for both virtual machines and virtual machine instances. For now # we are only counting virtual machine instances. - - "virtualmachines" + #- "virtualmachines" - "virtualmachineinstances" admissionReviewVersions: - "v1" diff --git a/manifests/test/rosa-vm-3.yaml b/manifests/test/rosa-vm-3.yaml index 3b47297..5edfad0 100644 --- a/manifests/test/rosa-vm-3.yaml +++ b/manifests/test/rosa-vm-3.yaml @@ -198,7 +198,7 @@ spec: utc: {} cpu: cores: 1 - sockets: 32 + sockets: 64 threads: 1 devices: disks: diff --git a/resources/virtualmachineinstance.go b/resources/virtualmachineinstance.go index e97b21b..a204821 100644 --- a/resources/virtualmachineinstance.go +++ b/resources/virtualmachineinstance.go @@ -33,18 +33,20 @@ func (vmi virtualMachineInstance) Extract(admissionRequest *admissionv1.Admissio // NeedsValidation returns if a virtual machine instance object needs validation or not. func (vmi virtualMachineInstance) NeedsValidation() *WindowsValidationResult { - // if we have owner references, see if we are owned by a virtual machine - if len(vmi.GetOwnerReferences()) > 0 { - for _, ref := range vmi.GetOwnerReferences() { - // we only want to validate virtual machine instances that do not have a windows preference. this is - // because provisioning from a preference seems to have a specialized workflow that is difficult - // to determine for windows. - // TODO: this logic is likely to need adjusted. - if ref.Name == VirtualMachineType { - return &WindowsValidationResult{Reason: "virtual machine instance owned by virtual machine object"} - } - } - } + // TODO: correct logic if we ever need to account for both virtual machines and virtual machine instances. For now + // we are only counting virtual machine instances. + // // if we have owner references, see if we are owned by a virtual machine + // if len(vmi.GetOwnerReferences()) > 0 { + // for _, ref := range vmi.GetOwnerReferences() { + // // we only want to validate virtual machine instances that do not have a windows preference. this is + // // because provisioning from a preference seems to have a specialized workflow that is difficult + // // to determine for windows. + // // TODO: this logic is likely to need adjusted. + // if ref.Name == VirtualMachineType { + // return &WindowsValidationResult{Reason: "virtual machine instance owned by virtual machine object"} + // } + // } + // } // finally use the windows logic to determine if we need validation return vmi.isWindows() @@ -159,11 +161,17 @@ func (vmi virtualMachineInstance) hasWindowsPreference() *WindowsValidationResul } if annotations["vm.kubevirt.io/os"] == "windows" { - return &WindowsValidationResult{NeedsValidation: true, Reason: "has 'vm.kubevirt.io/os' windows annotation"} + return &WindowsValidationResult{ + NeedsValidation: true, + Reason: "has 'vm.kubevirt.io/os' windows annotation", + } } if strings.HasPrefix(annotations["kubevirt.io/cluster-preference-name"], "windows") { - return &WindowsValidationResult{NeedsValidation: true, Reason: "has 'kubevirt.io/cluster-preference-name' windows annotation"} + return &WindowsValidationResult{ + NeedsValidation: true, + Reason: "has 'kubevirt.io/cluster-preference-name' windows annotation", + } } return &WindowsValidationResult{Reason: "has no windows preference"} diff --git a/webhook/operation.go b/webhook/operation.go index 2c1226a..a2b90ac 100644 --- a/webhook/operation.go +++ b/webhook/operation.go @@ -35,8 +35,8 @@ func NewOperation(w http.ResponseWriter, r *http.Request) (*operation, error) { // we are only counting virtual machine instances. var validator resources.WindowsInstanceValidator switch req.admissionRequest.Kind.Kind { - case resources.VirtualMachineType: - validator = resources.NewVirtualMachine() + // case resources.VirtualMachineType: + // validator = resources.NewVirtualMachine() case resources.VirtualMachineInstanceType: validator = resources.NewVirtualMachineInstance() default: