Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/bases/placement.openstack.org_placementapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ spec:
status:
description: PlacementAPIStatus defines the observed state of PlacementAPI
properties:
applicationCredentialSecret:
description: |-
ApplicationCredentialSecret - the AC secret placement is currently
consuming and protecting with the openstack.org/placementapi-ac-consumer
finalizer. Tracked so the controller can remove its finalizer from the
old secret when the openstack-operator rotates the reference.
type: string
conditions:
description: Conditions
items:
Expand Down
6 changes: 6 additions & 0 deletions api/placement/v1beta1/api_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ type PlacementAPIStatus struct {

// LastAppliedTopology - the last applied Topology
LastAppliedTopology *topologyv1.TopoRef `json:"lastAppliedTopology,omitempty"`

// ApplicationCredentialSecret - the AC secret placement is currently
// consuming and protecting with the openstack.org/placementapi-ac-consumer
// finalizer. Tracked so the controller can remove its finalizer from the
// old secret when the openstack-operator rotates the reference.
ApplicationCredentialSecret string `json:"applicationCredentialSecret,omitempty"`
}

// PlacementAPI is the Schema for the placementapis API
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/placement.openstack.org_placementapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ spec:
status:
description: PlacementAPIStatus defines the observed state of PlacementAPI
properties:
applicationCredentialSecret:
description: |-
ApplicationCredentialSecret - the AC secret placement is currently
consuming and protecting with the openstack.org/placementapi-ac-consumer
finalizer. Tracked so the controller can remove its finalizer from the
old secret when the openstack-operator rotates the reference.
type: string
conditions:
description: Conditions
items:
Expand Down
65 changes: 65 additions & 0 deletions internal/controller/placement/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,21 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request
return ctrl.Result{}, nil
}

if instance.Spec.Auth.ApplicationCredentialSecret != "" {
if err := keystonev1.ManageACSecretFinalizer(ctx, h, instance.Namespace,
instance.Spec.Auth.ApplicationCredentialSecret,
"",
placement.ACConsumerFinalizer); err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
condition.ServiceConfigReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
condition.ServiceConfigReadyErrorMessage,
err.Error()))
return ctrl.Result{}, err
}
}

instance.Status.Conditions.MarkTrue(condition.ServiceConfigReadyCondition, condition.ServiceConfigReadyMessage)

serviceAnnotations, result, err := r.ensureNetworkAttachments(ctx, h, instance)
Expand Down Expand Up @@ -502,6 +517,26 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request
return ctrl.Result{}, err
}

// Manage the old AC secret's finalizer and status tracking.
// On rotation (old != new), only remove the old secret's finalizer after
// all sub-services are ready with the new credentials. This prevents
// premature revocation during rapid rotations.
isRotation := instance.Status.ApplicationCredentialSecret != "" &&
instance.Status.ApplicationCredentialSecret != instance.Spec.Auth.ApplicationCredentialSecret

if isRotation {
allServicesReady := instance.Status.Conditions.AllSubConditionIsTrue()
if allServicesReady {
if err := keystonev1.RemoveACSecretConsumerFinalizer(ctx, h, instance.Namespace,
instance.Status.ApplicationCredentialSecret, placement.ACConsumerFinalizer); err != nil {
return ctrl.Result{}, err
}
instance.Status.ApplicationCredentialSecret = instance.Spec.Auth.ApplicationCredentialSecret
}
} else {
instance.Status.ApplicationCredentialSecret = instance.Spec.Auth.ApplicationCredentialSecret
}

return ctrl.Result{}, nil
}

Expand Down Expand Up @@ -1094,6 +1129,17 @@ func (r *PlacementAPIReconciler) reconcileDelete(ctx context.Context, instance *
}
}

// Remove consumer finalizer from AC secrets placement was consuming.
for _, secretName := range []string{
instance.Status.ApplicationCredentialSecret,
instance.Spec.Auth.ApplicationCredentialSecret,
} {
if err := keystonev1.RemoveACSecretConsumerFinalizer(ctx, helper, instance.Namespace,
secretName, placement.ACConsumerFinalizer); err != nil {
return ctrl.Result{}, err
}
}

// We did all the cleanup on the objects we created so we can remove the
// finalizer from ourselves to allow the deletion
controllerutil.RemoveFinalizer(instance, helper.GetFinalizer())
Expand Down Expand Up @@ -1332,6 +1378,25 @@ func (r *PlacementAPIReconciler) ensureDeployment(
}
// create Deployment - end

// Manage the old AC secret's finalizer and status tracking.
// On rotation (old != new), only remove the old secret's finalizer after
// all sub-services are ready with the new credentials. This prevents
// premature revocation during rapid rotations.
isRotation := instance.Status.ApplicationCredentialSecret != "" && instance.Status.ApplicationCredentialSecret != instance.Spec.Auth.ApplicationCredentialSecret

if isRotation {
allServicesReady := instance.Status.Conditions.AllSubConditionIsTrue()
if allServicesReady {
if err := keystonev1.RemoveACSecretConsumerFinalizer(ctx, h, instance.Namespace,
instance.Status.ApplicationCredentialSecret, placement.ACConsumerFinalizer); err != nil {
return ctrl.Result{}, err
}
instance.Status.ApplicationCredentialSecret = instance.Spec.Auth.ApplicationCredentialSecret
}
} else {
instance.Status.ApplicationCredentialSecret = instance.Spec.Auth.ApplicationCredentialSecret
}

Log.Info("Reconciled Service successfully")
return ctrl.Result{}, nil
}
Expand Down
3 changes: 3 additions & 0 deletions internal/placement/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ const (
// PlacementUserID is the linux user ID used by Kolla for the placement
// user in the service containers
PlacementUserID int64 = 42482

// ACConsumerFinalizer is added to AC secrets that placement is actively consuming
ACConsumerFinalizer = "openstack.org/placementapi-ac-consumer"
)
Loading
Loading