Skip to content

Commit 6493e52

Browse files
committed
Watch KeystoneAPI status updates to reconcile
Adds watches of the Nova controller on the KeystoneAPI status to reconcile if e.g. the endpoint list changes. This triggers setting the new KeystoneAuthURL on the sub components to update their configuration. Depends-On: openstack-k8s-operators/keystone-operator#591 Jira: OSPRH-16994 Signed-off-by: Martin Schuppert <[email protected]>
1 parent e123506 commit 6493e52

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

controllers/designateapi_controller.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ func (r *DesignateAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.
377377
Watches(&topologyv1.Topology{},
378378
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
379379
builder.WithPredicates(predicate.GenerationChangedPredicate{})).
380+
Watches(&keystonev1.KeystoneAPI{},
381+
handler.EnqueueRequestsFromMapFunc(r.findObjectForSrc),
382+
builder.WithPredicates(keystonev1.KeystoneAPIStatusChangedPredicate)).
380383
Complete(r)
381384
}
382385

@@ -422,6 +425,37 @@ func (r *DesignateAPIReconciler) findObjectsForSrc(ctx context.Context, src clie
422425
return requests
423426
}
424427

428+
func (r *DesignateAPIReconciler) findObjectForSrc(ctx context.Context, src client.Object) []reconcile.Request {
429+
requests := []reconcile.Request{}
430+
431+
l := log.FromContext(ctx).WithName("Controllers").WithName("DesignateAPI")
432+
433+
crList := &designatev1beta1.DesignateAPIList{}
434+
listOps := &client.ListOptions{
435+
Namespace: src.GetNamespace(),
436+
}
437+
err := r.Client.List(ctx, crList, listOps)
438+
if err != nil {
439+
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
440+
return requests
441+
}
442+
443+
for _, item := range crList.Items {
444+
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
445+
446+
requests = append(requests,
447+
reconcile.Request{
448+
NamespacedName: types.NamespacedName{
449+
Name: item.GetName(),
450+
Namespace: item.GetNamespace(),
451+
},
452+
},
453+
)
454+
}
455+
456+
return requests
457+
}
458+
425459
func (r *DesignateAPIReconciler) reconcileDelete(ctx context.Context, instance *designatev1beta1.DesignateAPI, helper *helper.Helper) (ctrl.Result, error) {
426460
Log := r.GetLogger(ctx)
427461

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/onsi/gomega v1.34.1
1313
github.com/openstack-k8s-operators/designate-operator/api v0.1.1-0.20240807132522-6c2eca7c6bbb
1414
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250530085921-2b2be72badf4
15-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250528115713-faa7ebf8f7fc
15+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250604143452-2260c431b9f1
1616
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7
1717
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20250508141203-be026d3164f7
1818
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250524131103-7ebaceec882b

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6
9292
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
9393
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250530085921-2b2be72badf4 h1:FmgzhJRoXETu1zY+WJItpw3MEq+uR/7Gx5yXtfMs3UI=
9494
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250530085921-2b2be72badf4/go.mod h1:47iJk3vedZWnBkZyNyYij4ma2HjG4l2VCqKz3f+XDkQ=
95-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250528115713-faa7ebf8f7fc h1:gYSgcZ4cCz41GIElVe122d4ZzoUQZ8ag886Pvse6HVU=
96-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250528115713-faa7ebf8f7fc/go.mod h1:dgYQJbbVaRuP98yZZB3K1rNpqnF54I1HM1ZTaOzPKBY=
95+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250604143452-2260c431b9f1 h1:YQuJwgoQ9mEyzNq9/SgS3wPCtLG0wMQWH/caWAMZeSc=
96+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250604143452-2260c431b9f1/go.mod h1:dgYQJbbVaRuP98yZZB3K1rNpqnF54I1HM1ZTaOzPKBY=
9797
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7 h1:c3h1q3fDoit3NmvNL89xUL9A12bJivaTF+IOPEOAwLc=
9898
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
9999
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250508141203-be026d3164f7 h1:IybBq3PrxwdvzAF19TjdMCqbEVkX2p3gIkme/Fju6do=

tests/functional/designateapi_controller_test.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ var _ = Describe("DesignateAPI controller", func() {
126126
When("config files are created", func() {
127127
var keystoneInternalEndpoint string
128128
var keystonePublicEndpoint string
129+
var keystoneAPIName types.NamespacedName
129130

130131
BeforeEach(func() {
131-
keystoneName := keystone.CreateKeystoneAPI(namespace)
132-
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneName)
132+
keystoneAPIName = keystone.CreateKeystoneAPI(namespace)
133+
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName)
133134
keystoneInternalEndpoint = fmt.Sprintf("http://keystone-for-%s-internal", designateAPIName.Name)
134135
keystonePublicEndpoint = fmt.Sprintf("http://keystone-for-%s-public", designateAPIName.Name)
135-
SimulateKeystoneReady(keystoneName, keystonePublicEndpoint, keystoneInternalEndpoint)
136+
SimulateKeystoneReady(keystoneAPIName, keystonePublicEndpoint, keystoneInternalEndpoint)
136137

137138
DeferCleanup(k8sClient.Delete, ctx, CreateDesignateSecret(namespace))
138139
DeferCleanup(k8sClient.Delete, ctx, CreateTransportURLSecret(transportURLSecretName))
@@ -251,6 +252,25 @@ var _ = Describe("DesignateAPI controller", func() {
251252
Expect(conf).Should(
252253
ContainSubstring("[DEFAULT]\ndebug=True\n"))
253254
})
255+
256+
It("updates the KeystoneAuthURL if keystone internal endpoint changes", func() {
257+
newInternalEndpoint := "https://keystone-internal"
258+
259+
keystone.UpdateKeystoneAPIEndpoint(keystoneAPIName, "internal", newInternalEndpoint)
260+
logger.Info("Reconfigured")
261+
262+
Eventually(func(g Gomega) {
263+
confSecret := th.GetSecret(
264+
types.NamespacedName{
265+
Namespace: designateAPIName.Namespace,
266+
Name: fmt.Sprintf("%s-config-data", designateAPIName.Name)})
267+
g.Expect(confSecret).ShouldNot(BeNil())
268+
269+
conf := string(confSecret.Data["designate.conf"])
270+
g.Expect(string(conf)).Should(
271+
ContainSubstring("auth_url=%s", newInternalEndpoint))
272+
}, timeout, interval).Should(Succeed())
273+
})
254274
})
255275

256276
// NAD

0 commit comments

Comments
 (0)