Skip to content

Commit 53aad37

Browse files
komer3glennpratt
authored andcommitted
[fix] restore pause handling during pivot (Backport #1063)
* fix: restore pause handling during pivot * fix: bump Go toolchain to 1.25.9 * Add e2e test to assert cluster.spec.pause will set pause conditions on linode resource. Unpause as well when Cluster is unpaused. * fix: watch pause annotation updates
1 parent 43a6371 commit 53aad37

23 files changed

Lines changed: 1247 additions & 12 deletions

.github/filters.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ kubeadm-full:
2828
kubeadm-flatcar:
2929
- templates/flavors/kubeadm/flatcar/*
3030

31+
cluster-pause:
32+
- e2e/cluster-pause/*
33+
3134
#k3s:
3235
# - templates/flavors/k3s/default/*
3336
# - e2e/capl-cluster-flavors/k3s-capl-cluster/*

.github/workflows/e2e-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ on:
2424
required: true
2525
options:
2626
- quick
27+
- cluster-pause
2728
- flavors
2829
- k3s
2930
- rke2

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ GOWRAP_VERSION ?= v1.4.0
381381
S5CMD_VERSION ?= v2.2.2
382382
CONVERSION_GEN_VERSION ?= v0.32.2
383383
GOLANGCI_LINT_VERSION ?= v2.1.5
384+
ENVTEST_VERSION ?= release-0.22
384385

385386
.PHONY: tools
386387
tools: $(KUSTOMIZE) $(CTLPTL) $(CLUSTERCTL) $(KUBECTL) $(CONTROLLER_GEN) $(CONVERSION_GEN) $(TILT) $(KIND) $(CHAINSAW) $(ENVTEST) $(HUSKY) $(NILAWAY) $(GOVULNC) $(MOCKGEN) $(GOWRAP)
@@ -452,7 +453,7 @@ $(CHAINSAW): $(CACHE_BIN)
452453
.PHONY: envtest
453454
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
454455
$(ENVTEST): $(CACHE_BIN)
455-
GOBIN=$(CACHE_BIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20230216140739-c98506dc3b8e
456+
GOBIN=$(CACHE_BIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_VERSION)
456457

457458
.phony: golangci-lint
458459
golangci-lint: $(GOLANGCI_LINT)

api/v1alpha2/linodecluster_types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,37 @@ func (lc *LinodeCluster) GetConditions() []metav1.Condition {
127127
lc.Status.Conditions[i].Reason = DefaultConditionReason
128128
}
129129
}
130+
130131
return lc.Status.Conditions
131132
}
132133

133134
func (lc *LinodeCluster) SetConditions(conditions []metav1.Condition) {
134135
lc.Status.Conditions = conditions
135136
}
136137

138+
func (lc *LinodeCluster) SetCondition(cond metav1.Condition) {
139+
if cond.LastTransitionTime.IsZero() {
140+
cond.LastTransitionTime = metav1.Now()
141+
}
142+
for i := range lc.Status.Conditions {
143+
if lc.Status.Conditions[i].Type == cond.Type {
144+
lc.Status.Conditions[i] = cond
145+
return
146+
}
147+
}
148+
lc.Status.Conditions = append(lc.Status.Conditions, cond)
149+
}
150+
151+
func (lc *LinodeCluster) GetCondition(condType string) *metav1.Condition {
152+
for i := range lc.Status.Conditions {
153+
if lc.Status.Conditions[i].Type == condType {
154+
return &lc.Status.Conditions[i]
155+
}
156+
}
157+
158+
return nil
159+
}
160+
137161
// We need V1Beta2Conditions helpers to be able to use the conditions package from cluster-api
138162
func (lc *LinodeCluster) GetV1Beta2Conditions() []metav1.Condition {
139163
return lc.GetConditions()

api/v1alpha2/linodefirewall_types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,37 @@ func (lfw *LinodeFirewall) GetConditions() []metav1.Condition {
157157
lfw.Status.Conditions[i].Reason = DefaultConditionReason
158158
}
159159
}
160+
160161
return lfw.Status.Conditions
161162
}
162163

163164
func (lfw *LinodeFirewall) SetConditions(conditions []metav1.Condition) {
164165
lfw.Status.Conditions = conditions
165166
}
166167

168+
func (lfw *LinodeFirewall) SetCondition(cond metav1.Condition) {
169+
if cond.LastTransitionTime.IsZero() {
170+
cond.LastTransitionTime = metav1.Now()
171+
}
172+
for i := range lfw.Status.Conditions {
173+
if lfw.Status.Conditions[i].Type == cond.Type {
174+
lfw.Status.Conditions[i] = cond
175+
return
176+
}
177+
}
178+
lfw.Status.Conditions = append(lfw.Status.Conditions, cond)
179+
}
180+
181+
func (lfw *LinodeFirewall) GetCondition(condType string) *metav1.Condition {
182+
for i := range lfw.Status.Conditions {
183+
if lfw.Status.Conditions[i].Type == condType {
184+
return &lfw.Status.Conditions[i]
185+
}
186+
}
187+
188+
return nil
189+
}
190+
167191
// We need V1Beta2Conditions helpers to be able to use the conditions package from cluster-api
168192
func (lfw *LinodeFirewall) GetV1Beta2Conditions() []metav1.Condition {
169193
return lfw.GetConditions()

api/v1alpha2/linodemachine_types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,37 @@ func (lm *LinodeMachine) GetConditions() []metav1.Condition {
558558
lm.Status.Conditions[i].Reason = DefaultConditionReason
559559
}
560560
}
561+
561562
return lm.Status.Conditions
562563
}
563564

564565
func (lm *LinodeMachine) SetConditions(conditions []metav1.Condition) {
565566
lm.Status.Conditions = conditions
566567
}
567568

569+
func (lm *LinodeMachine) SetCondition(cond metav1.Condition) {
570+
if cond.LastTransitionTime.IsZero() {
571+
cond.LastTransitionTime = metav1.Now()
572+
}
573+
for i := range lm.Status.Conditions {
574+
if lm.Status.Conditions[i].Type == cond.Type {
575+
lm.Status.Conditions[i] = cond
576+
return
577+
}
578+
}
579+
lm.Status.Conditions = append(lm.Status.Conditions, cond)
580+
}
581+
582+
func (lm *LinodeMachine) GetCondition(condType string) *metav1.Condition {
583+
for i := range lm.Status.Conditions {
584+
if lm.Status.Conditions[i].Type == condType {
585+
return &lm.Status.Conditions[i]
586+
}
587+
}
588+
589+
return nil
590+
}
591+
568592
func (lm *LinodeMachine) GetV1Beta2Conditions() []metav1.Condition {
569593
return lm.GetConditions()
570594
}

api/v1alpha2/linodeplacementgroup_types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,37 @@ func (lpg *LinodePlacementGroup) GetConditions() []metav1.Condition {
140140
lpg.Status.Conditions[i].Reason = DefaultConditionReason
141141
}
142142
}
143+
143144
return lpg.Status.Conditions
144145
}
145146

146147
func (lpg *LinodePlacementGroup) SetConditions(conditions []metav1.Condition) {
147148
lpg.Status.Conditions = conditions
148149
}
149150

151+
func (lpg *LinodePlacementGroup) SetCondition(cond metav1.Condition) {
152+
if cond.LastTransitionTime.IsZero() {
153+
cond.LastTransitionTime = metav1.Now()
154+
}
155+
for i := range lpg.Status.Conditions {
156+
if lpg.Status.Conditions[i].Type == cond.Type {
157+
lpg.Status.Conditions[i] = cond
158+
return
159+
}
160+
}
161+
lpg.Status.Conditions = append(lpg.Status.Conditions, cond)
162+
}
163+
164+
func (lpg *LinodePlacementGroup) GetCondition(condType string) *metav1.Condition {
165+
for i := range lpg.Status.Conditions {
166+
if lpg.Status.Conditions[i].Type == condType {
167+
return &lpg.Status.Conditions[i]
168+
}
169+
}
170+
171+
return nil
172+
}
173+
150174
func (lpg *LinodePlacementGroup) GetV1Beta2Conditions() []metav1.Condition {
151175
return lpg.GetConditions()
152176
}

api/v1alpha2/linodevpc_types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,37 @@ func (lv *LinodeVPC) GetConditions() []metav1.Condition {
215215
lv.Status.Conditions[i].Reason = DefaultConditionReason
216216
}
217217
}
218+
218219
return lv.Status.Conditions
219220
}
220221

221222
func (lv *LinodeVPC) SetConditions(conditions []metav1.Condition) {
222223
lv.Status.Conditions = conditions
223224
}
224225

226+
func (lv *LinodeVPC) SetCondition(cond metav1.Condition) {
227+
if cond.LastTransitionTime.IsZero() {
228+
cond.LastTransitionTime = metav1.Now()
229+
}
230+
for i := range lv.Status.Conditions {
231+
if lv.Status.Conditions[i].Type == cond.Type {
232+
lv.Status.Conditions[i] = cond
233+
return
234+
}
235+
}
236+
lv.Status.Conditions = append(lv.Status.Conditions, cond)
237+
}
238+
239+
func (lv *LinodeVPC) GetCondition(condType string) *metav1.Condition {
240+
for i := range lv.Status.Conditions {
241+
if lv.Status.Conditions[i].Type == condType {
242+
return &lv.Status.Conditions[i]
243+
}
244+
}
245+
246+
return nil
247+
}
248+
225249
func (lv *LinodeVPC) GetV1Beta2Conditions() []metav1.Condition {
226250
return lv.GetConditions()
227251
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: capi-controller-manager
5+
namespace: capi-system
6+
status:
7+
availableReplicas: 1
8+
---
9+
apiVersion: apps/v1
10+
kind: Deployment
11+
metadata:
12+
name: capl-controller-manager
13+
namespace: capl-system
14+
status:
15+
availableReplicas: 1
16+
---
17+
apiVersion: apps/v1
18+
kind: Deployment
19+
metadata:
20+
name: capi-kubeadm-bootstrap-controller-manager
21+
namespace: capi-kubeadm-bootstrap-system
22+
status:
23+
availableReplicas: 1
24+
---
25+
apiVersion: apps/v1
26+
kind: Deployment
27+
metadata:
28+
name: capi-kubeadm-control-plane-controller-manager
29+
namespace: capi-kubeadm-control-plane-system
30+
status:
31+
availableReplicas: 1
32+
---
33+
apiVersion: apps/v1
34+
kind: Deployment
35+
metadata:
36+
name: caaph-controller-manager
37+
namespace: caaph-system
38+
status:
39+
availableReplicas: 1
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: ccm-linode
5+
namespace: kube-system
6+
status:
7+
currentNumberScheduled: 1
8+
desiredNumberScheduled: 1
9+
numberAvailable: 1
10+
numberMisscheduled: 0
11+
numberReady: 1
12+
---
13+
apiVersion: apps/v1
14+
kind: DaemonSet
15+
metadata:
16+
name: cilium
17+
namespace: kube-system
18+
status:
19+
currentNumberScheduled: 2
20+
desiredNumberScheduled: 2
21+
numberAvailable: 2
22+
numberMisscheduled: 0
23+
numberReady: 2
24+
---
25+
apiVersion: apps/v1
26+
kind: DaemonSet
27+
metadata:
28+
name: csi-linode-node
29+
namespace: kube-system
30+
status:
31+
currentNumberScheduled: 2
32+
desiredNumberScheduled: 2
33+
numberAvailable: 2
34+
numberMisscheduled: 0
35+
numberReady: 2

0 commit comments

Comments
 (0)