Skip to content

Commit e1d2978

Browse files
stuggiclaude
andcommitted
[lb pub endpt] Public endpoint reuse: service cert, front port, live port name
Support a MetalLB LoadBalancer public endpoint with a custom hostname, certificate and port (RHOSP 17.1 -> RHOSO 18 adoption). - Service cert: SANs come from the canonical service.GetVHostServerName set ({custom host, short, FQDN}); the custom endpointURL host is added for public and internal endpoints, a bad endpointURL falls back to the in-cluster names and is logged. A bring-your-own pod-level cert is taken from tls.api.<endpoint>.secretName (snapshotted pre-restore at every EnsureEndpointConfig call site), else one is issued. It applies to the LoadBalancer public endpoint and the internal endpoint; a Route-backed public endpoint keeps the operator-issued cert (a custom cert there goes on the Route via apiOverride.tls.secretName, which is validated only when a Route exists). Fix the cert cleanup delete target (Service cert, not Route cert). - Front port: for a TLS LoadBalancer public endpoint with an endpointURL, inject a ports[] override with the endpointURL port (the scheme default when the URL has none). There is no implicit director legacy port: without an endpointURL the Service keeps its native port, and adopters who keep a RHOSP 17.1 front port put it in the endpointURL (e.g. https://keystone.example.com:13000). Injection is skipped for non-TLS or routed endpoints, non-LoadBalancer Services, multi-port Services, and while the live port is not yet named after its endpoint type ("public"), since an override carrying the old <service>-public name is rejected by the service operator's by-name port merge before the Service is patched. A watch on managed Services' port names and type wakes the control plane when the service operator renames the port. The override Spec is copied before it is mutated. - Routes: CreateRoute reads the target port name from the live Service instead of assuming it equals the object name. A user endpointURL is kept when a Route is replaced by a LoadBalancer. - Glance: return the requeue of the API that asked for it, and do not let a later endpoint's valid secret overwrite CustomTLSReady False set earlier in the same reconcile. Jira: OSPRH-39364 Jira: OSPRH-39366 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent fbc23a8 commit e1d2978

21 files changed

Lines changed: 2154 additions & 110 deletions

‎internal/controller/core/openstackcontrolplane_controller.go‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (r *OpenStackControlPlaneReconciler) GetLogger(ctx context.Context) logr.Lo
125125
// +kubebuilder:rbac:groups=redis.openstack.org,resources=redises,verbs=get;list;watch;create;update;patch;delete
126126
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=get;list;watch;create;update;patch;delete;
127127
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes/custom-host,verbs=create;update;patch
128-
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;
128+
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch
129129
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete;
130130
// +kubebuilder:rbac:groups=cert-manager.io,resources=issuers,verbs=get;list;watch;create;update;patch;delete;
131131
// +kubebuilder:rbac:groups=cert-manager.io,resources=certificates,verbs=get;list;watch;create;update;patch;delete;
@@ -228,6 +228,17 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr
228228
instance.Status.ObservedGeneration = instance.Generation
229229

230230
// If we're not deleting this and the service object doesn't have our finalizer, add it.
231+
//
232+
// This must stay the only metadata write that is followed by more spec mutation, and
233+
// it returns before any is made. The reconcilers mutate instance.Spec in memory (issued
234+
// cert secret names, overrides, CA bundle names), and the deferred PatchInstance builds
235+
// its MergeFrom patch on the main resource whenever the metadata changed - that patch
236+
// would then persist those spec changes. The persisted spec is the user input the
237+
// reconcilers snapshot as the bring-your-own cert signal and the secret field indexes read;
238+
// persisted operator-issued names would be mistaken for BYO secrets (see resolveServiceCert).
239+
// The finalizer removal in reconcileDelete is safe for the same reason: no spec mutation
240+
// has happened on that path. Do not add annotation/label/finalizer writes after the spec
241+
// mutations without going through a separate patch.
231242
if instance.DeletionTimestamp.IsZero() && controllerutil.AddFinalizer(instance, helper.GetFinalizer()) || isNewInstance {
232243
return ctrl.Result{}, nil
233244
}
@@ -900,6 +911,13 @@ func (r *OpenStackControlPlaneReconciler) SetupWithManager(
900911
handler.EnqueueRequestsFromMapFunc(r.findControlPlaneForSrc),
901912
builder.WithPredicates(backup.AnnotationChangedPredicate(openstack.ServiceCertSelector)),
902913
).
914+
// the service operators rename the Service ports and set its type; the
915+
// endpointURL front port is injected only after that, see EnsureEndpointConfig
916+
Watches(
917+
&corev1.Service{},
918+
handler.EnqueueRequestsFromMapFunc(r.findControlPlaneForSrc),
919+
builder.WithPredicates(openstack.ServicePortOrTypeChangedPredicate()),
920+
).
903921
Complete(r)
904922
}
905923

‎internal/openstack/barbican.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ func ReconcileBarbican(ctx context.Context, instance *corev1beta1.OpenStackContr
108108
instance.Spec.Barbican.Template.Auth.ApplicationCredentialSecret = acSecretName
109109
}
110110

111+
// snapshot pre-restore BYO service cert secret (pure user input; see resolveServiceCert)
112+
barbicanUserTLS := instance.Spec.Barbican.Template.BarbicanAPI.TLS
111113
// preserve any previously set TLS certs, set CA cert
112114
if instance.Spec.TLS.PodLevel.Enabled {
113115
instance.Spec.Barbican.Template.BarbicanAPI.TLS = barbican.Spec.BarbicanAPI.TLS
@@ -136,7 +138,7 @@ func ReconcileBarbican(ctx context.Context, instance *corev1beta1.OpenStackContr
136138
instance.Spec.Barbican.APIOverride,
137139
corev1beta1.OpenStackControlPlaneExposeBarbicanReadyCondition,
138140
false, // TODO: (mschuppert) could be removed when all integrated service support TLS
139-
instance.Spec.Barbican.Template.BarbicanAPI.TLS,
141+
barbicanUserTLS,
140142
)
141143
if err != nil {
142144
return ctrlResult, err

‎internal/openstack/cinder.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl
132132
instance.Spec.Cinder.Template.Auth.ApplicationCredentialSecret = acSecretName
133133
}
134134

135+
// snapshot pre-restore BYO service cert secret (pure user input; see resolveServiceCert)
136+
cinderUserTLS := instance.Spec.Cinder.Template.CinderAPI.TLS
135137
// preserve any previously set TLS certs,set CA cert
136138
if instance.Spec.TLS.PodLevel.Enabled {
137139
instance.Spec.Cinder.Template.CinderAPI.TLS = cinder.Spec.CinderAPI.TLS
@@ -160,7 +162,7 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl
160162
instance.Spec.Cinder.APIOverride,
161163
corev1beta1.OpenStackControlPlaneExposeCinderReadyCondition,
162164
false, // TODO (mschuppert) could be removed when all integrated service support TLS
163-
instance.Spec.Cinder.Template.CinderAPI.TLS,
165+
cinderUserTLS,
164166
)
165167
if err != nil {
166168
return ctrlResult, err

0 commit comments

Comments
 (0)