Skip to content

Commit

Permalink
Check allocatable SEV devices in the test
Browse files Browse the repository at this point in the history
Apparently, kubelet does not always reset the capacity. It may take some
time before it drops to zero.

Signed-off-by: Vasiliy Ulyanov <[email protected]>
  • Loading branch information
vasiliy-ul committed Jul 4, 2023
1 parent 7b057d0 commit 5b3f53a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/launchsecurity/sev.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ var _ = Describe("[sig-compute]AMD Secure Encrypted Virtualization (SEV)", decor
Eventually(func() bool {
node, err := virtClient.CoreV1().Nodes().Get(context.Background(), nodeName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
val, ok := node.Status.Capacity[sevResourceName]
val, ok := node.Status.Allocatable[sevResourceName]
return ok && !val.IsZero()
}, 180*time.Second, 1*time.Second).Should(BeTrue(), fmt.Sprintf("SEV capacity should not be zero on %s", nodeName))
}, 180*time.Second, 1*time.Second).Should(BeTrue(), fmt.Sprintf("Allocatable SEV should not be zero on %s", nodeName))
})

AfterEach(func() {
Expand All @@ -298,15 +298,15 @@ var _ = Describe("[sig-compute]AMD Secure Encrypted Virtualization (SEV)", decor
}
})

It("[QUARANTINE] should reset SEV capacity when the feature gate is disabled", func() {
It("[QUARANTINE] should reset SEV allocatable devices when the feature gate is disabled", func() {
By(fmt.Sprintf("Disabling %s feature gate", virtconfig.WorkloadEncryptionSEV))
tests.DisableFeatureGate(virtconfig.WorkloadEncryptionSEV)
Eventually(func() bool {
node, err := virtClient.CoreV1().Nodes().Get(context.Background(), nodeName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
val, ok := node.Status.Capacity[sevResourceName]
val, ok := node.Status.Allocatable[sevResourceName]
return !ok || val.IsZero()
}, 180*time.Second, 1*time.Second).Should(BeTrue(), fmt.Sprintf("SEV capacity should be zero on %s", nodeName))
}, 180*time.Second, 1*time.Second).Should(BeTrue(), fmt.Sprintf("Allocatable SEV should be zero on %s", nodeName))
})
})

Expand Down

0 comments on commit 5b3f53a

Please sign in to comment.