Skip to content

Commit 7867960

Browse files
authored
[fix] : set reason to none if nothing specified (#628)
* set reason to none if nothing specified so that condition upgrade doesn't fail * fix empty reason for other controllers as well
1 parent 3169560 commit 7867960

7 files changed

+37
-1
lines changed

api/v1alpha2/linodecluster_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ type LinodeCluster struct {
103103
}
104104

105105
func (lc *LinodeCluster) GetConditions() []metav1.Condition {
106+
for i := range lc.Status.Conditions {
107+
if lc.Status.Conditions[i].Reason == "" {
108+
lc.Status.Conditions[i].Reason = DefaultConditionReason
109+
}
110+
}
106111
return lc.Status.Conditions
107112
}
108113

api/v1alpha2/linodefirewall_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ type LinodeFirewall struct {
137137
}
138138

139139
func (lfw *LinodeFirewall) GetConditions() []metav1.Condition {
140+
for i := range lfw.Status.Conditions {
141+
if lfw.Status.Conditions[i].Reason == "" {
142+
lfw.Status.Conditions[i].Reason = DefaultConditionReason
143+
}
144+
}
140145
return lfw.Status.Conditions
141146
}
142147

api/v1alpha2/linodemachine_types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import (
2727
const (
2828
// MachineFinalizer allows ReconcileLinodeMachine to clean up Linode resources associated
2929
// with LinodeMachine before removing it from the apiserver.
30-
MachineFinalizer = "linodemachine.infrastructure.cluster.x-k8s.io"
30+
MachineFinalizer = "linodemachine.infrastructure.cluster.x-k8s.io"
31+
DefaultConditionReason = "None"
3132
)
3233

3334
// LinodeMachineSpec defines the desired state of LinodeMachine
@@ -237,6 +238,11 @@ type LinodeMachine struct {
237238
}
238239

239240
func (lm *LinodeMachine) GetConditions() []metav1.Condition {
241+
for i := range lm.Status.Conditions {
242+
if lm.Status.Conditions[i].Reason == "" {
243+
lm.Status.Conditions[i].Reason = DefaultConditionReason
244+
}
245+
}
240246
return lm.Status.Conditions
241247
}
242248

api/v1alpha2/linodeobjectstoragebucket_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ type LinodeObjectStorageBucket struct {
105105
}
106106

107107
func (losb *LinodeObjectStorageBucket) GetConditions() []metav1.Condition {
108+
for i := range losb.Status.Conditions {
109+
if losb.Status.Conditions[i].Reason == "" {
110+
losb.Status.Conditions[i].Reason = DefaultConditionReason
111+
}
112+
}
108113
return losb.Status.Conditions
109114
}
110115

api/v1alpha2/linodeobjectstoragekey_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ type LinodeObjectStorageKey struct {
133133
}
134134

135135
func (losk *LinodeObjectStorageKey) GetConditions() []metav1.Condition {
136+
for i := range losk.Status.Conditions {
137+
if losk.Status.Conditions[i].Reason == "" {
138+
losk.Status.Conditions[i].Reason = DefaultConditionReason
139+
}
140+
}
136141
return losk.Status.Conditions
137142
}
138143

api/v1alpha2/linodeplacementgroup_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ type LinodePlacementGroup struct {
118118
}
119119

120120
func (lpg *LinodePlacementGroup) GetConditions() []metav1.Condition {
121+
for i := range lpg.Status.Conditions {
122+
if lpg.Status.Conditions[i].Reason == "" {
123+
lpg.Status.Conditions[i].Reason = DefaultConditionReason
124+
}
125+
}
121126
return lpg.Status.Conditions
122127
}
123128

api/v1alpha2/linodevpc_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ type LinodeVPC struct {
124124
}
125125

126126
func (lv *LinodeVPC) GetConditions() []metav1.Condition {
127+
for i := range lv.Status.Conditions {
128+
if lv.Status.Conditions[i].Reason == "" {
129+
lv.Status.Conditions[i].Reason = DefaultConditionReason
130+
}
131+
}
127132
return lv.Status.Conditions
128133
}
129134

0 commit comments

Comments
 (0)