Skip to content

Commit 670b9a0

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 a0641a2 commit 670b9a0

File tree

6 files changed

+91
-22
lines changed

6 files changed

+91
-22
lines changed

api/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.21
55
require (
66
github.com/onsi/ginkgo/v2 v2.20.1
77
github.com/onsi/gomega v1.34.1
8-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec
9-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35
8+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250513115636-b549982a5d8f
9+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7
1010
github.com/rhobs/observability-operator v0.3.1
1111
k8s.io/api v0.29.15
1212
k8s.io/apimachinery v0.29.15

api/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo
7272
github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
7373
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
7474
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
75-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec h1:Sr12fbgiUTL/a7qvKCosedKW5gn5S+53DgRJgeveTk4=
76-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec/go.mod h1:XywwuHkxaBZA+6QsF+N/3f9ekBq3tH0I/gQZzwL89GU=
77-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35 h1:dczrtvVjeDXUR3OhnUQRhVVnN14KX52qp0KXCulo8pA=
78-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
75+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250513115636-b549982a5d8f h1:b3WGatQCIBoNj8RvbVGNITL9RuQLwkXzXAgt7s/D5zc=
76+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250513115636-b549982a5d8f/go.mod h1:47iJk3vedZWnBkZyNyYij4ma2HjG4l2VCqKz3f+XDkQ=
77+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7 h1:c3h1q3fDoit3NmvNL89xUL9A12bJivaTF+IOPEOAwLc=
78+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
7979
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
8080
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
8181
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

controllers/autoscaling_controller.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22-
"github.com/openstack-k8s-operators/telemetry-operator/pkg/metricstorage"
2322
"strconv"
2423
"time"
2524

25+
"github.com/openstack-k8s-operators/telemetry-operator/pkg/metricstorage"
26+
2627
appsv1 "k8s.io/api/apps/v1"
2728
corev1 "k8s.io/api/core/v1"
2829
rbacv1 "k8s.io/api/rbac/v1"
@@ -933,6 +934,9 @@ func (r *AutoscalingReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
933934
Watches(&topologyv1.Topology{},
934935
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
935936
builder.WithPredicates(predicate.GenerationChangedPredicate{})).
937+
Watches(&keystonev1.KeystoneAPI{},
938+
handler.EnqueueRequestsFromMapFunc(r.findObjectForSrc),
939+
builder.WithPredicates(keystonev1.KeystoneAPIStatusChangedPredicate)).
936940
Complete(r)
937941
}
938942

@@ -968,3 +972,34 @@ func (r *AutoscalingReconciler) findObjectsForSrc(ctx context.Context, src clien
968972

969973
return requests
970974
}
975+
976+
func (r *AutoscalingReconciler) findObjectForSrc(ctx context.Context, src client.Object) []reconcile.Request {
977+
requests := []reconcile.Request{}
978+
979+
l := log.FromContext(ctx).WithName("Controllers").WithName("Autoscaling")
980+
981+
crList := &telemetryv1.AutoscalingList{}
982+
listOps := &client.ListOptions{
983+
Namespace: src.GetNamespace(),
984+
}
985+
err := r.Client.List(ctx, crList, listOps)
986+
if err != nil {
987+
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
988+
return requests
989+
}
990+
991+
for _, item := range crList.Items {
992+
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
993+
994+
requests = append(requests,
995+
reconcile.Request{
996+
NamespacedName: types.NamespacedName{
997+
Name: item.GetName(),
998+
Namespace: item.GetNamespace(),
999+
},
1000+
},
1001+
)
1002+
}
1003+
1004+
return requests
1005+
}

controllers/ceilometer_controller.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,9 @@ func (r *CeilometerReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
18121812
Watches(&topologyv1.Topology{},
18131813
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
18141814
builder.WithPredicates(predicate.GenerationChangedPredicate{})).
1815+
Watches(&keystonev1.KeystoneAPI{},
1816+
handler.EnqueueRequestsFromMapFunc(r.findObjectForSrc),
1817+
builder.WithPredicates(keystonev1.KeystoneAPIStatusChangedPredicate)).
18151818
Complete(r)
18161819
}
18171820

@@ -1849,6 +1852,37 @@ func (r *CeilometerReconciler) findObjectsForSrc(ctx context.Context, src client
18491852
return requests
18501853
}
18511854

1855+
func (r *CeilometerReconciler) findObjectForSrc(ctx context.Context, src client.Object) []reconcile.Request {
1856+
requests := []reconcile.Request{}
1857+
1858+
l := log.FromContext(ctx).WithName("Controllers").WithName("Ceilometer")
1859+
1860+
crList := &telemetryv1.CeilometerList{}
1861+
listOps := &client.ListOptions{
1862+
Namespace: src.GetNamespace(),
1863+
}
1864+
err := r.Client.List(ctx, crList, listOps)
1865+
if err != nil {
1866+
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
1867+
return requests
1868+
}
1869+
1870+
for _, item := range crList.Items {
1871+
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
1872+
1873+
requests = append(requests,
1874+
reconcile.Request{
1875+
NamespacedName: types.NamespacedName{
1876+
Name: item.GetName(),
1877+
Namespace: item.GetNamespace(),
1878+
},
1879+
},
1880+
)
1881+
}
1882+
1883+
return requests
1884+
}
1885+
18521886
func (r CeilometerReconciler) roleExists(
18531887
ctx context.Context,
18541888
helper *helper.Helper,

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ require (
1010
github.com/onsi/ginkgo/v2 v2.20.1
1111
github.com/onsi/gomega v1.34.1
1212
github.com/openstack-k8s-operators/heat-operator/api v0.6.0
13-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec
14-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250424160141-6db2b5a653cf
13+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250513115636-b549982a5d8f
14+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250604143452-2260c431b9f1
1515
github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20250423055245-3cb2ae8df6f0
16-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35
16+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7
1717
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250415060817-dc849adfa27e
1818
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240529090522-c780bd90b147
1919
github.com/rabbitmq/cluster-operator v1.14.0
@@ -55,8 +55,8 @@ require (
5555
github.com/modern-go/reflect2 v1.0.2 // indirect
5656
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5757
github.com/openshift/api v3.9.0+incompatible // indirect
58-
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250423055245-3cb2ae8df6f0 // indirect
59-
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250419062702-0acec6a591c8 // indirect
58+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250508141203-be026d3164f7 // indirect
59+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250508141203-be026d3164f7 // indirect
6060
github.com/pkg/errors v0.9.1 // indirect
6161
github.com/prometheus/client_golang v1.19.0 // indirect
6262
github.com/prometheus/client_model v0.6.0 // indirect

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6
8080
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
8181
github.com/openstack-k8s-operators/heat-operator/api v0.6.0 h1:WXdflkqFy28NuGSgnZ5tHVb98+pZs6Lyjz4wep6JRfw=
8282
github.com/openstack-k8s-operators/heat-operator/api v0.6.0/go.mod h1:oMtgRR+Cnzjq9Jk9aJeCJIg80sru6fGMpRtO5bhDg2M=
83-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec h1:Sr12fbgiUTL/a7qvKCosedKW5gn5S+53DgRJgeveTk4=
84-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec/go.mod h1:XywwuHkxaBZA+6QsF+N/3f9ekBq3tH0I/gQZzwL89GU=
85-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250424160141-6db2b5a653cf h1:RWYHdI5Aia5sUawoD8VgE98YUaQtqFsiQt6pRYMjN4g=
86-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250424160141-6db2b5a653cf/go.mod h1:VPkYswnrCtlSMTeYjgxTOpfNN7zvxqa+kZ8EWDJaFrg=
83+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250513115636-b549982a5d8f h1:b3WGatQCIBoNj8RvbVGNITL9RuQLwkXzXAgt7s/D5zc=
84+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250513115636-b549982a5d8f/go.mod h1:47iJk3vedZWnBkZyNyYij4ma2HjG4l2VCqKz3f+XDkQ=
85+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250604143452-2260c431b9f1 h1:YQuJwgoQ9mEyzNq9/SgS3wPCtLG0wMQWH/caWAMZeSc=
86+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250604143452-2260c431b9f1/go.mod h1:dgYQJbbVaRuP98yZZB3K1rNpqnF54I1HM1ZTaOzPKBY=
8787
github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20250423055245-3cb2ae8df6f0 h1:QKmpBfn9zIYcmODrvhnnrOx2CV1Y2t6M8DwNgLbaRbI=
8888
github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20250423055245-3cb2ae8df6f0/go.mod h1:0bajRHochTUT6Ecfriw27l3vL0yezVrnUmt3bcIpu4w=
89-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35 h1:dczrtvVjeDXUR3OhnUQRhVVnN14KX52qp0KXCulo8pA=
90-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
91-
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250423055245-3cb2ae8df6f0 h1:FAHrScvlj6w17wvcDhJ0ZnmraMrrOX1CxzvqZK595hA=
92-
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250423055245-3cb2ae8df6f0/go.mod h1:fesgTbs2j30Fhw2hebXkPgbeAIqG0Yk2oaeOklAInZg=
93-
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250419062702-0acec6a591c8 h1:oLY6iMNPe3/L5S8EvNcjvfWd1tbCNgfQ+iSnv3UCB0U=
94-
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250419062702-0acec6a591c8/go.mod h1:5+v92XC/PRATIiBrhNLEpJ+T4R9JpxBCgRP6QvbfwgE=
89+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7 h1:c3h1q3fDoit3NmvNL89xUL9A12bJivaTF+IOPEOAwLc=
90+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250508141203-be026d3164f7/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
91+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250508141203-be026d3164f7 h1:IybBq3PrxwdvzAF19TjdMCqbEVkX2p3gIkme/Fju6do=
92+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250508141203-be026d3164f7/go.mod h1:fesgTbs2j30Fhw2hebXkPgbeAIqG0Yk2oaeOklAInZg=
93+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250508141203-be026d3164f7 h1:N7HNoUrjqrWZWWcQdtaZubrQ1pFeWai1Cbls0RoCjK8=
94+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250508141203-be026d3164f7/go.mod h1:5+v92XC/PRATIiBrhNLEpJ+T4R9JpxBCgRP6QvbfwgE=
9595
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250415060817-dc849adfa27e h1:42PsCCv8ebk2tCw/ZiWsJJMhI4C3fmdUaatKSOJ0GXk=
9696
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250415060817-dc849adfa27e/go.mod h1:ZgHSxZSgpgHg1FhKPnBm/cqxAJbVFbKiBkqQoRohn3Q=
9797
github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49 h1:/7SnnHfGCH/dwuZFNUx54zw4cnwv2w6hjONq16aoowM=

0 commit comments

Comments
 (0)