@@ -24,6 +24,7 @@ import (
2424 "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
2525 . "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers"
2626 corev1 "k8s.io/api/core/v1"
27+ k8s_errors "k8s.io/apimachinery/pkg/api/errors"
2728 "k8s.io/apimachinery/pkg/types"
2829)
2930
@@ -102,4 +103,71 @@ var _ = Describe("ProvisionServer Test", func() {
102103 Expect (instance1 .Spec .Port ).ShouldNot (Equal (instance2 .Spec .Port ))
103104 })
104105 })
106+
107+ When ("A ProvisionServer resource is created with pause annotation" , func () {
108+ BeforeEach (func () {
109+ raw := map [string ]interface {}{
110+ "apiVersion" : "baremetal.openstack.org/v1beta1" ,
111+ "kind" : "OpenStackProvisionServer" ,
112+ "metadata" : map [string ]interface {}{
113+ "name" : provisionServerName .Name ,
114+ "namespace" : provisionServerName .Namespace ,
115+ "annotations" : map [string ]string {
116+ "openstack.org/paused" : "" ,
117+ },
118+ },
119+ "spec" : map [string ]interface {}{
120+ "osImage" : "edpm-hardened-uefi.qcow2" ,
121+ "osContainerImageUrl" : "quay.io/podified-antelope-centos9/edpm-hardened-uefi:current-podified" ,
122+ "apacheImageUrl" : "registry.redhat.io/ubi9/httpd-24:latest" ,
123+ "agentImageUrl" : "quay.io/openstack-k8s-operators/openstack-baremetal-operator-agent:latest" ,
124+ },
125+ }
126+ DeferCleanup (th .DeleteInstance , th .CreateUnstructured (raw ))
127+ })
128+
129+ It ("should not update status conditions while paused" , func () {
130+ Consistently (func (g Gomega ) {
131+ instance := & baremetalv1.OpenStackProvisionServer {}
132+ g .Expect (k8sClient .Get (ctx , provisionServerName , instance )).To (Succeed ())
133+ g .Expect (instance .Status .Conditions ).To (BeEmpty ())
134+ }, timeout , interval ).Should (Succeed ())
135+ })
136+
137+ It ("should resume reconciliation when pause annotation is removed" , func () {
138+ Consistently (func (g Gomega ) {
139+ instance := & baremetalv1.OpenStackProvisionServer {}
140+ g .Expect (k8sClient .Get (ctx , provisionServerName , instance )).To (Succeed ())
141+ g .Expect (instance .Status .Conditions ).To (BeEmpty ())
142+ }, timeout , interval ).Should (Succeed ())
143+
144+ Eventually (func (g Gomega ) {
145+ instance := & baremetalv1.OpenStackProvisionServer {}
146+ g .Expect (k8sClient .Get (ctx , provisionServerName , instance )).To (Succeed ())
147+ instance .Annotations = map [string ]string {}
148+ g .Expect (k8sClient .Update (ctx , instance )).To (Succeed ())
149+ }, timeout , interval ).Should (Succeed ())
150+
151+ th .ExpectCondition (
152+ provisionServerName ,
153+ ConditionGetterFunc (ProvisionServerConditionGetter ),
154+ condition .ReadyCondition ,
155+ corev1 .ConditionFalse ,
156+ )
157+ })
158+
159+ It ("should still allow deletion when paused" , func () {
160+ instance := & baremetalv1.OpenStackProvisionServer {}
161+ Eventually (func (g Gomega ) {
162+ g .Expect (k8sClient .Get (ctx , provisionServerName , instance )).To (Succeed ())
163+ }, timeout , interval ).Should (Succeed ())
164+
165+ Expect (k8sClient .Delete (ctx , instance )).To (Succeed ())
166+
167+ Eventually (func (g Gomega ) {
168+ err := k8sClient .Get (ctx , provisionServerName , instance )
169+ g .Expect (k8s_errors .IsNotFound (err )).To (BeTrue ())
170+ }, timeout , interval ).Should (Succeed ())
171+ })
172+ })
105173})
0 commit comments