@@ -25,6 +25,7 @@ import (
2525 "go.uber.org/mock/gomock"
2626 corev1 "k8s.io/api/core/v1"
2727 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28+ "k8s.io/apimachinery/pkg/types"
2829 "k8s.io/utils/ptr"
2930 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3031 conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
@@ -61,6 +62,10 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
6162 Namespace : defaultNamespace ,
6263 OwnerReferences : ownerRefs ,
6364 }
65+ cluster := clusterv1.Cluster {
66+ ObjectMeta : metadata ,
67+ Spec : clusterv1.ClusterSpec {},
68+ }
6469 linodeCluster := infrav1alpha2.LinodeCluster {
6570 ObjectMeta : metadata ,
6671 Spec : infrav1alpha2.LinodeClusterSpec {
@@ -72,6 +77,9 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
7277 ObjectMeta : metav1.ObjectMeta {
7378 Name : "vpctest" ,
7479 Namespace : defaultNamespace ,
80+ Labels : map [string ]string {
81+ clusterv1 .ClusterNameLabel : linodeCluster .ObjectMeta .Name ,
82+ },
7583 },
7684 Spec : infrav1alpha2.LinodeVPCSpec {
7785 Region : "us-ord" ,
@@ -98,6 +106,7 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
98106 BeforeAll (func (ctx SpecContext ) {
99107 cScope .Client = k8sClient
100108 Expect (k8sClient .Create (ctx , & linodeCluster )).To (Succeed ())
109+ Expect (k8sClient .Create (ctx , & cluster )).To (Succeed ())
101110 })
102111
103112 ctlrSuite .BeforeEach (func (ctx context.Context , mck Mock ) {
@@ -181,7 +190,7 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
181190 cScope .LinodeClient = mck .LinodeClient
182191 // Set VPC as ready
183192 linodeVPC .Status .Ready = true
184- k8sClient .Status ().Update (ctx , & linodeVPC )
193+ Expect ( k8sClient .Status ().Update (ctx , & linodeVPC )). To ( Succeed () )
185194
186195 // Create and mark firewall as ready if using firewall ref
187196 if cScope .LinodeCluster .Spec .NodeBalancerFirewallRef != nil {
@@ -329,8 +338,7 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
329338 clusterKey := client .ObjectKeyFromObject (& linodeCluster )
330339 Expect (k8sClient .Get (ctx , clusterKey , & linodeCluster )).To (Succeed ())
331340 Expect (linodeCluster .Status .Ready ).To (BeTrue ())
332- Expect (linodeCluster .Status .Conditions ).To (HaveLen (4 ))
333- Expect (conditions .Get (& linodeCluster , clusterv1 .PausedV1Beta2Condition ).Status ).To (Equal (metav1 .ConditionFalse ))
341+ Expect (linodeCluster .Status .Conditions ).To (HaveLen (3 ))
334342 Expect (conditions .Get (& linodeCluster , string (clusterv1 .ReadyCondition )).Status ).To (Equal (metav1 .ConditionTrue ))
335343 Expect (conditions .Get (& linodeCluster , ConditionPreflightLinodeNBFirewallReady )).NotTo (BeNil ())
336344 Expect (conditions .Get (& linodeCluster , ConditionPreflightLinodeVPCReady )).NotTo (BeNil ())
@@ -342,6 +350,29 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
342350 Expect (linodeCluster .Spec .ControlPlaneEndpoint .Port ).To (Equal (int32 (controlPlaneEndpointPort )))
343351 }),
344352 ),
353+ Path (
354+ Call ("cluster is paused" , func (ctx context.Context , mck Mock ) {
355+ cScope .LinodeClient = mck .LinodeClient
356+ cluster .Spec .Paused = true
357+ Expect (k8sClient .Update (ctx , & cluster )).To (Succeed ())
358+ }),
359+ Result ("cluster does nothing" , func (ctx context.Context , mck Mock ) {
360+ reconciler .Client = k8sClient
361+ _ , err := reconciler .Reconcile (ctx , reconcile.Request {types.NamespacedName {Name : clusterName , Namespace : defaultNamespace }})
362+ Expect (err ).NotTo (HaveOccurred ())
363+
364+ By ("checking paused conditions" )
365+ clusterKey := client .ObjectKeyFromObject (& linodeCluster )
366+ Expect (k8sClient .Get (ctx , clusterKey , & linodeCluster )).To (Succeed ())
367+ Expect (linodeCluster .Status .Ready ).To (BeTrue ())
368+ Expect (linodeCluster .Status .Conditions ).To (HaveLen (4 ))
369+ Expect (conditions .Get (& linodeCluster , string (clusterv1 .PausedV1Beta2Condition )).Status ).To (Equal (metav1 .ConditionTrue ))
370+ Expect (conditions .Get (& linodeCluster , string (clusterv1 .ReadyCondition )).Status ).To (Equal (metav1 .ConditionTrue ))
371+ Expect (conditions .Get (& linodeCluster , ConditionPreflightLinodeNBFirewallReady )).NotTo (BeNil ())
372+ Expect (conditions .Get (& linodeCluster , ConditionPreflightLinodeVPCReady )).NotTo (BeNil ())
373+
374+ }),
375+ ),
345376 ),
346377 )
347378})
@@ -448,7 +479,7 @@ var _ = Describe("cluster-lifecycle-dns", Ordered, Label("cluster", "cluster-lif
448479 clusterKey := client .ObjectKeyFromObject (& linodeCluster )
449480 Expect (k8sClient .Get (ctx , clusterKey , & linodeCluster )).To (Succeed ())
450481 Expect (linodeCluster .Status .Ready ).To (BeTrue ())
451- Expect (linodeCluster .Status .Conditions ).To (HaveLen (2 ))
482+ Expect (linodeCluster .Status .Conditions ).To (HaveLen (1 ))
452483 readyCond := conditions .Get (& linodeCluster , string (clusterv1 .ReadyCondition ))
453484 Expect (readyCond ).NotTo (BeNil ())
454485
@@ -722,7 +753,7 @@ var _ = Describe("dns-override-endpoint", Ordered, Label("cluster", "dns-overrid
722753 clusterKey := client .ObjectKeyFromObject (& linodeCluster )
723754 Expect (k8sClient .Get (ctx , clusterKey , & linodeCluster )).To (Succeed ())
724755 Expect (linodeCluster .Status .Ready ).To (BeTrue ())
725- Expect (linodeCluster .Status .Conditions ).To (HaveLen (2 ))
756+ Expect (linodeCluster .Status .Conditions ).To (HaveLen (1 ))
726757 cond := conditions .Get (& linodeCluster , string (clusterv1 .ReadyCondition ))
727758 Expect (cond ).NotTo (BeNil ())
728759
0 commit comments