Skip to content

Commit dca5673

Browse files
committed
Add rough logic for propagating network creation error into network bindings.
1 parent 317ea27 commit dca5673

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

internal/controller/networkbinding_controller.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package controller
44

55
import (
66
"context"
7+
"errors"
78
"fmt"
89
"time"
910

@@ -66,14 +67,8 @@ func (r *NetworkBindingReconciler) Reconcile(ctx context.Context, req mcreconcil
6667
}
6768

6869
defer func() {
69-
if err != nil {
70-
// Don't update the status if errors are encountered
71-
return
72-
}
73-
statusChanged := apimeta.SetStatusCondition(&binding.Status.Conditions, readyCondition)
74-
75-
if statusChanged {
76-
err = cl.GetClient().Status().Update(ctx, &binding)
70+
if apimeta.SetStatusCondition(&binding.Status.Conditions, readyCondition) {
71+
err = errors.Join(err, cl.GetClient().Status().Update(ctx, &binding))
7772
}
7873
}()
7974

@@ -132,6 +127,12 @@ func (r *NetworkBindingReconciler) Reconcile(ctx context.Context, req mcreconcil
132127
readyCondition.Reason = "NetworkContextNotReady"
133128
readyCondition.Message = "Network context is not ready."
134129

130+
condition := apimeta.FindStatusCondition(networkContext.Status.Conditions, networkingv1alpha.NetworkContextProgrammed)
131+
if condition != nil && condition.Status == metav1.ConditionFalse && condition.Reason == "NetworkFailedToCreate" {
132+
readyCondition.Reason = "NetworkFailedToCreate"
133+
readyCondition.Message = condition.Message
134+
}
135+
135136
// Choosing to requeue here instead of establishing a watch on contexts, as
136137
// once the context is created an ready, future bindings will immediately
137138
// become ready.

0 commit comments

Comments
 (0)