Skip to content

Commit

Permalink
Minor fixes for #3219 (#3231)
Browse files Browse the repository at this point in the history
1. fix comment (should be masters instead of workers)
2. use HaveValue matcher in unit tests.

Signed-off-by: Oren Cohen <[email protected]>
  • Loading branch information
orenc1 authored Dec 22, 2024
1 parent 081abbb commit fc5d5b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions controllers/operands/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,9 @@ func hcoConfig2KvConfig(hcoConfig hcov1beta1.HyperConvergedConfig, controlPlaneH
kvConfig.Replicas = ptr.To[uint8](1)
}

// In case there are no worker nodes, we're setting an empty struct for NodePlacement
// so that kubevirt control plane pods won't have any affinity rules, and they could get
// scheduled onto worker nodes.
// In case there are no control plane / master nodes in the cluster, we're setting
// an empty struct for NodePlacement so that kubevirt control plane pods won't have
// any affinity rules, and they could get scheduled onto worker nodes.
if hcoConfig.NodePlacement == nil && !controlPlaneNodeExists {
kvConfig.NodePlacement = &kubevirtcorev1.NodePlacement{}
return kvConfig
Expand Down
11 changes: 4 additions & 7 deletions controllers/operands/kubevirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3022,7 +3022,7 @@ Version: 1.2.3`)
kv, err := NewKubeVirt(hco)
Expect(err).ToNot(HaveOccurred())
Expect(kv.Spec.Infra).To(Not(BeNil()))
Expect(*kv.Spec.Infra.Replicas).To(Equal(uint8(1)))
Expect(kv.Spec.Infra.Replicas).To(HaveValue(Equal(uint8(1))))
Expect(kv.Spec.Workloads).To(BeNil())
})

Expand Down Expand Up @@ -3066,8 +3066,7 @@ Version: 1.2.3`)
kv, err := NewKubeVirt(hco)
Expect(err).ToNot(HaveOccurred())
Expect(kv.Spec.Infra).To(Not(BeNil()))
Expect(kv.Spec.Infra.Replicas).To(Not(BeNil()))
Expect(*kv.Spec.Infra.Replicas).To(Equal(uint8(1)))
Expect(kv.Spec.Infra.Replicas).To(HaveValue(Equal(uint8(1))))
Expect(kv.Spec.Workloads).To(Not(BeNil()))
Expect(kv.Spec.Workloads.Replicas).To(BeNil())
})
Expand Down Expand Up @@ -3107,8 +3106,7 @@ Version: 1.2.3`)
kv, err := NewKubeVirt(hco)
Expect(err).ToNot(HaveOccurred())
Expect(kv.Spec.Infra).To(Not(BeNil()))
Expect(kv.Spec.Infra.Replicas).To(Not(BeNil()))
Expect(*kv.Spec.Infra.Replicas).To(Equal(uint8(1)))
Expect(kv.Spec.Infra.Replicas).To(HaveValue(Equal(uint8(1))))
Expect(kv.Spec.Workloads).To(BeNil())
})

Expand All @@ -3129,8 +3127,7 @@ Version: 1.2.3`)
kv, err := NewKubeVirt(hco)
Expect(err).ToNot(HaveOccurred())
Expect(kv.Spec.Infra).To(Not(BeNil()))
Expect(kv.Spec.Infra.Replicas).To(Not(BeNil()))
Expect(*kv.Spec.Infra.Replicas).To(Equal(uint8(1)))
Expect(kv.Spec.Infra.Replicas).To(HaveValue(Equal(uint8(1))))
Expect(kv.Spec.Workloads).To(Not(BeNil()))
Expect(kv.Spec.Workloads.Replicas).To(BeNil())
})
Expand Down

0 comments on commit fc5d5b1

Please sign in to comment.