Skip to content

Commit 3352ba3

Browse files
committed
Rename IP states to Pending, Allocated
1 parent 3b46ac7 commit 3352ba3

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

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-
FailedIPState IPState = "Failed"
13-
ProcessingIPState IPState = "Processing"
14-
FinishedIPState 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

internal/controller/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.FinishedIPState ||
113-
ip.Status.State == v1alpha1.FailedIPState {
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.ProcessingIPState
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.FailedIPState
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.FailedIPState
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.FinishedIPState
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 {

internal/controller/ip_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ var _ = Describe("IP controller", func() {
187187
if err != nil {
188188
return false
189189
}
190-
if createdIP.Status.State != v1alpha1.FinishedIPState {
190+
if createdIP.Status.State != v1alpha1.IPStateAllocated {
191191
return false
192192
}
193193
return true
@@ -224,7 +224,7 @@ var _ = Describe("IP controller", func() {
224224
if err != nil {
225225
return false
226226
}
227-
if ipCopy.Status.State != v1alpha1.FailedIPState {
227+
if ipCopy.Status.State != v1alpha1.IPStateFailed {
228228
return false
229229
}
230230
return true
@@ -244,7 +244,7 @@ var _ = Describe("IP controller", func() {
244244
if err != nil {
245245
return false
246246
}
247-
if ipCopy.Status.State != v1alpha1.FinishedIPState {
247+
if ipCopy.Status.State != v1alpha1.IPStateAllocated {
248248
return false
249249
}
250250
if !ipCopy.Status.Reserved.Equal(testIP) {

internal/controller/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.FailedIPState {
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.ProcessingIPState
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)

internal/webhook/v1alpha1/subnet_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func SetupSubnetWebhookWithManager(mgr ctrl.Manager) error {
6060
}
6161
state := ip.Status.State
6262
parentSubnet := ip.Spec.Subnet.Name
63-
if state != v1alpha1.FinishedIPState {
63+
if state != v1alpha1.IPStateAllocated {
6464
return nil
6565
}
6666
return []string{parentSubnet}

internal/webhook/v1alpha1/subnet_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ var _ = Describe("Subnet webhook", func() {
581581
return err == nil
582582
}, Timeout, Interval).Should(BeTrue())
583583

584-
childIP.Status.State = v1alpha1.FinishedIPState
584+
childIP.Status.State = v1alpha1.IPStateAllocated
585585
Expect(k8sClient.Status().Update(ctx, &childIP)).Should(Succeed())
586586
Eventually(func() bool {
587587
childIPsMatchingFields := client.MatchingFields{

0 commit comments

Comments
 (0)