Skip to content

Commit

Permalink
fix: panic error and windows logic for virtual machines
Browse files Browse the repository at this point in the history
Signed-off-by: Dustin Scott <[email protected]>
  • Loading branch information
scottd018 committed Nov 26, 2024
1 parent 9c5a28c commit 951120f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ certs:
@scripts/gen-certs.sh

create:
@kubectl create ns my-vms --dry-run=client -o yaml | kubectl apply -f -
@kubectl create ns windows-overcommit-webhook --dry-run=client -o yaml | kubectl apply -f - && \
@kubectl apply -f manifests/deploy/namespace.yaml && \
scripts/apply-certs.sh && \
kubectl apply -f manifests/deploy/deploy.yaml && \
kubectl patch validatingwebhookconfiguration windows-overcommit-webhook \
--type=json \
-p="$$(echo '[{"op": "replace", "path": "/webhooks/0/clientConfig/caBundle", "value": "'$$(cat tmp/ca.crt | base64 | tr -d '\n')'"}]')"

destroy:
@kubectl delete -f manifests/deploy/deploy.yaml && \
kubectl delete ns windows-overcommit-webhook && \
kubectl delete ns my-vms
@kubectl delete -f manifests/deploy/deploy.yaml
@kubectl delete ns windows-overcommit-webhook

#
# development and test related tasks
#
create-vm-ns:
@kubectl create ns my-vms --dry-run=client -o yaml | kubectl apply -f -

destroy-vm-ns:
@kubectl delete ns my-vms
2 changes: 1 addition & 1 deletion manifests/deploy/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ spec:
drop:
- "ALL"
runAsNonRoot: true
runAsUser: 1001
runAsUser: 1000860101
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down
6 changes: 5 additions & 1 deletion resources/virtualmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ func (vm virtualMachine) Extract(admissionRequest *admissionv1.AdmissionRequest)

// IsWindows determines if a virtual machine object is a windows instance or not.
func (vm virtualMachine) IsWindows() bool {
return vm.HasWindowsPreference()
if vm.HasWindowsPreference() {
return true
}

return vm.VirtualMachineInstance().IsWindows()
}

// SumCPU sums up the value of all CPUs for the virtual machine.
Expand Down
4 changes: 4 additions & 0 deletions resources/virtualmachineinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func (vmi virtualMachineInstance) HasSysprepVolume() bool {
// sysprep volumes for linux machines. This is guaranteed to work when using out of the box OpenShift templates.
func (vmi virtualMachineInstance) HasWindowsDriverDiskVolume() bool {
for _, volume := range vmi.Spec.Volumes {
if volume.DataVolume == nil {
continue
}

if volume.DataVolume.Name == "windows-drivers-disk" {
return true
}
Expand Down

0 comments on commit 951120f

Please sign in to comment.