@@ -25,7 +25,6 @@ import (
2525 . "github.com/onsi/ginkgo/v2"
2626 . "github.com/onsi/gomega"
2727 "k8s.io/apimachinery/pkg/api/resource"
28- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2928 "k8s.io/utils/ptr"
3029 crclient "sigs.k8s.io/controller-runtime/pkg/client"
3130
@@ -88,9 +87,7 @@ var _ = Describe("VirtualMachineConfiguration", func() {
8887 err = f .Clients .GenericClient ().Update (context .Background (), t .VM )
8988 Expect (err ).NotTo (HaveOccurred ())
9089
91- t .CheckRestartAwaitingChanges (t .VM )
92-
93- if t .VM .Spec .Disruptions .RestartApprovalMode == v1alpha2 .Manual {
90+ if util .IsRestartRequired (t .VM , 3 * time .Second ) {
9491 util .RebootVirtualMachineBySSH (f , t .VM )
9592 }
9693
@@ -157,18 +154,3 @@ func (t *configurationTest) GenerateResources(restartApprovalMode v1alpha2.Resta
157154 vmbuilder .WithRestartApprovalMode (restartApprovalMode ),
158155 )
159156}
160-
161- func (t * configurationTest ) CheckRestartAwaitingChanges (vm * v1alpha2.VirtualMachine ) {
162- if vm .Spec .Disruptions .RestartApprovalMode != v1alpha2 .Manual {
163- return
164- }
165-
166- // Avoid race conditions during the calculation of the "need restart" condition.
167- Eventually (func (g Gomega ) {
168- err := t .Framework .Clients .GenericClient ().Get (context .Background (), crclient .ObjectKeyFromObject (t .VM ), t .VM )
169- g .Expect (err ).NotTo (HaveOccurred ())
170- needRestart , _ := conditions .GetCondition (vmcondition .TypeAwaitingRestartToApplyConfiguration , t .VM .Status .Conditions )
171- g .Expect (needRestart .Status ).To (Equal (metav1 .ConditionTrue ))
172- g .Expect (t .VM .Status .RestartAwaitingChanges ).NotTo (BeNil ())
173- }).WithTimeout (3 * time .Second ).WithPolling (time .Second ).Should (Succeed ())
174- }
0 commit comments