Skip to content

Commit 690acf8

Browse files
authored
Merge pull request #656 from gndrmnn/fix_issue_314
Fix RouterInterface status when waiting for routerRef
2 parents 28038cf + dfede6b commit 690acf8

2 files changed

Lines changed: 42 additions & 12 deletions

File tree

internal/controllers/routerinterface/reconcile.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,38 @@ func (r *orcRouterInterfaceReconciler) Reconcile(ctx context.Context, req ctrl.R
4848
router := &orcv1alpha1.Router{}
4949
if err := r.client.Get(ctx, req.NamespacedName, router); err != nil {
5050
if apierrors.IsNotFound(err) {
51-
return ctrl.Result{}, nil
51+
// The router does not exist (yet). We still need to update the status
52+
// on all RouterInterfaces that are associated with that router
53+
54+
// Creating a dummy router struct with namespace and name will be enough to
55+
// retrieve all defined RouterInterfaces for that to-be-created router
56+
router.Name = req.Name
57+
router.Namespace = req.Namespace
58+
routerInterfaces, err := routerDependency.GetObjectsForDependency(ctx, r.client, router)
59+
60+
if err != nil {
61+
return ctrl.Result{}, fmt.Errorf("fetching router interfaces: %w", err)
62+
}
63+
64+
if len(routerInterfaces) == 0 {
65+
return ctrl.Result{}, nil
66+
}
67+
68+
var osResource *osclients.PortExt
69+
70+
var reconcileStatus progress.ReconcileStatus
71+
for i := range routerInterfaces {
72+
routerInterface := &routerInterfaces[i]
73+
log = log.WithValues("name", routerInterface.Name)
74+
75+
var ifReconcileStatus progress.ReconcileStatus
76+
ifReconcileStatus = progress.WaitingOnObject("Router", req.Name, progress.WaitingOnCreation)
77+
ifReconcileStatus = ifReconcileStatus.WithReconcileStatus(r.updateStatus(ctx, routerInterface, osResource, ifReconcileStatus))
78+
79+
reconcileStatus = reconcileStatus.WithReconcileStatus(ifReconcileStatus)
80+
}
81+
82+
return reconcileStatus.Return(log)
5283
}
5384
return ctrl.Result{}, err
5485
}

internal/controllers/routerinterface/tests/routerinterface-dependency/00-assert.yaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ apiVersion: openstack.k-orc.cloud/v1alpha1
33
kind: RouterInterface
44
metadata:
55
name: routerinterface-dependency-no-router
6-
# FIXME: https://github.com/k-orc/openstack-resource-controller/issues/314
7-
# status:
8-
# conditions:
9-
# - type: Available
10-
# message: Waiting for Router/routerinterface-dependency-pending to be created
11-
# status: "False"
12-
# reason: Progressing
13-
# - type: Progressing
14-
# message: Waiting for Router/routerinterface-dependency-pending to be created
15-
# status: "True"
16-
# reason: Progressing
6+
status:
7+
conditions:
8+
- type: Available
9+
message: Waiting for Router/routerinterface-dependency-pending to be created
10+
status: "False"
11+
reason: Progressing
12+
- type: Progressing
13+
message: Waiting for Router/routerinterface-dependency-pending to be created
14+
status: "True"
15+
reason: Progressing
1716
---
1817
apiVersion: openstack.k-orc.cloud/v1alpha1
1918
kind: RouterInterface

0 commit comments

Comments
 (0)