Skip to content

Commit 93b128e

Browse files
committed
Remove IP states to Pending, Allocated
1 parent bfd7e71 commit 93b128e

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ KUBECTL_BIN ?= $(LOCAL_BIN)/kubectl
160160
## Tools versions
161161
ADDLICENSE_VERSION ?= v1.1.1
162162
CONTROLLER_GEN_VERSION ?= v0.14.0
163-
GOLANGCI_LINT_VERSION ?= v1.55.2
163+
GOLANGCI_LINT_VERSION ?= v1.63
164164
GOIMPORTS_VERSION ?= v0.16.1
165165
ENVTEST_K8S_VERSION ?= 1.31.0
166166
CODE_GENERATOR_VERSION ?= v0.28.3

api/ipam/v1alpha1/ip_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
)
1010

1111
const (
12-
CFailedIPState IPState = "Failed"
13-
CProcessingIPState IPState = "Processing"
14-
CFinishedIPState IPState = "Finished"
12+
// TODO: Remove failed state
13+
IPStateFailed IPState = "Failed"
14+
IPStatePending IPState = "Pending"
15+
IPStateAllocated IPState = "Allocated"
1516
)
1617

1718
// IPState is a processing state of IP resource

api/ipam/v1alpha1/subnet_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (in *Subnet) SetupWebhookWithManager(mgr ctrl.Manager) error {
5959
}
6060
state := ip.Status.State
6161
parentSubnet := ip.Spec.Subnet.Name
62-
if state != CFinishedIPState {
62+
if state != IPStateAllocated {
6363
return nil
6464
}
6565
return []string{parentSubnet}

api/ipam/v1alpha1/subnet_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ var _ = Describe("Subnet webhook", func() {
579579
return err == nil
580580
}, CTimeout, CInterval).Should(BeTrue())
581581

582-
childIP.Status.State = CFinishedIPState
582+
childIP.Status.State = IPStateAllocated
583583
Expect(k8sClient.Status().Update(ctx, &childIP)).Should(Succeed())
584584
Eventually(func() bool {
585585
childIPsMatchingFields := client.MatchingFields{

controllers/ip_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ func (r *IPReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Re
109109
return ctrl.Result{}, err
110110
}
111111

112-
if ip.Status.State == v1alpha1.CFinishedIPState ||
113-
ip.Status.State == v1alpha1.CFailedIPState {
112+
if ip.Status.State == v1alpha1.IPStateAllocated ||
113+
ip.Status.State == v1alpha1.IPStateFailed {
114114
return ctrl.Result{}, nil
115115
}
116116

117117
if ip.Status.State == "" {
118-
ip.Status.State = v1alpha1.CProcessingIPState
118+
ip.Status.State = v1alpha1.IPStatePending
119119
ip.Status.Message = ""
120120
if err := r.Status().Update(ctx, ip); err != nil {
121121
log.Error(err, "unable to update ip resource status", "name", req.NamespacedName, "currentStatus", ip.Status.State, "targetStatus", v1alpha1.CProcessingNetworkState)
@@ -140,7 +140,7 @@ func (r *IPReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Re
140140
} else {
141141
cidr, err := subnet.ProposeForCapacity(resource.NewScaledQuantity(1, 0))
142142
if err != nil {
143-
ip.Status.State = v1alpha1.CFailedIPState
143+
ip.Status.State = v1alpha1.IPStateFailed
144144
ip.Status.Message = err.Error()
145145
if err := r.Status().Update(ctx, ip); err != nil {
146146
log.Error(err, "unable to update ip status", "name", req.NamespacedName)
@@ -152,7 +152,7 @@ func (r *IPReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Re
152152
}
153153

154154
if err := subnet.Reserve(ipCidrToReserve); err != nil {
155-
ip.Status.State = v1alpha1.CFailedIPState
155+
ip.Status.State = v1alpha1.IPStateFailed
156156
ip.Status.Message = err.Error()
157157
if err := r.Status().Update(ctx, ip); err != nil {
158158
log.Error(err, "unable to update ip status", "name", req.NamespacedName)
@@ -167,7 +167,7 @@ func (r *IPReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Re
167167
return ctrl.Result{}, err
168168
}
169169

170-
ip.Status.State = v1alpha1.CFinishedIPState
170+
ip.Status.State = v1alpha1.IPStateAllocated
171171
ip.Status.Message = ""
172172
ip.Status.Reserved = ipCidrToReserve.AsIPAddr()
173173
if err := r.Status().Update(ctx, ip); err != nil {

controllers/ip_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ var _ = Describe("IP controller", func() {
192192
if err != nil {
193193
return false
194194
}
195-
if createdIP.Status.State != v1alpha1.CFinishedIPState {
195+
if createdIP.Status.State != v1alpha1.IPStateAllocated {
196196
return false
197197
}
198198
return true
@@ -229,7 +229,7 @@ var _ = Describe("IP controller", func() {
229229
if err != nil {
230230
return false
231231
}
232-
if ipCopy.Status.State != v1alpha1.CFailedIPState {
232+
if ipCopy.Status.State != v1alpha1.IPStateFailed {
233233
return false
234234
}
235235
return true
@@ -249,7 +249,7 @@ var _ = Describe("IP controller", func() {
249249
if err != nil {
250250
return false
251251
}
252-
if ipCopy.Status.State != v1alpha1.CFinishedIPState {
252+
if ipCopy.Status.State != v1alpha1.IPStateAllocated {
253253
return false
254254
}
255255
if !ipCopy.Status.Reserved.Equal(testIP) {

controllers/subnet_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func (r *SubnetReconciler) SetupWithManager(mgr ctrl.Manager) error {
294294
if parentSubnet == "" {
295295
return nil
296296
}
297-
if state != v1alpha1.CFailedIPState {
297+
if state != v1alpha1.IPStateFailed {
298298
return nil
299299
}
300300
return []string{parentSubnet}
@@ -432,7 +432,7 @@ func (r *SubnetReconciler) requeueFailedIPs(ctx context.Context, log logr.Logger
432432
}
433433

434434
for _, ip := range ips.Items {
435-
ip.Status.State = v1alpha1.CProcessingIPState
435+
ip.Status.State = v1alpha1.IPStatePending
436436
ip.Status.Message = ""
437437
if err := r.Status().Update(ctx, &ip); err != nil {
438438
log.Error(err, "unable to update child ips", "name", types.NamespacedName{Namespace: subnet.Namespace, Name: subnet.Name}, "subnet", subnet.Name)

0 commit comments

Comments
 (0)