You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement immutable secrets for application credentials
Deleted unused `GetApplicationCredentialFromSecret` function and introduce immutable per-rotation AC secrets with deterministic names,
add Keystone-side revocation of unused rotated ACs, and suppress Owns() create events on the secret
watch to prevent a race condition caused by stale informer cach and sometimes causing additional AC secret to be created and deleted immediately during rotation.
Signed-off-by: Veronika Fisarova <vfisarov@redhat.com>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
- Sets `.status.lastRotated` (only during rotation, not initial creation)
154
+
- Sets `.status.lastRotated` and emits `ApplicationCredentialRotated` event (only during rotation, not initial creation)
142
155
- Marks AC CR ready
143
-
- Emits an event for rotation to notify EDPM nodes
144
-
145
-
10. Requeue for Next Check
146
-
- Calculates next reconcile at `expiresAt - gracePeriod`
147
-
- If already in grace window, requeues immediately, otherwise requeues after 24 h
148
156
149
157
AC in Keystone side:
150
158
```
@@ -174,15 +182,20 @@ When the next reconcile hits the grace window (`now ≥ expiresAt - gracePeriodD
174
182
- Generates a new Keystone AC with a fresh 5-char suffix
175
183
- Uses the same roles, unrestricted flag, access rules, and expirationDays
176
184
- Does _not_ revoke the old AC, the old credential naturally expires
177
-
- Store Updated Secret
178
-
- Overwrites the existing `ac-barbican-secret` with the new `AC_ID` and `AC_SECRET`
185
+
- Create New Immutable Secret
186
+
- Creates a **new** immutable Secret with a unique name (e.g. `ac-barbican-d38dc-secret`)
187
+
- The previous Secret (e.g. `ac-barbican-7b23d-secret`) is **retained** — it is not deleted
188
+
- Both secrets are owned by the AC CR and will be garbage-collected when the CR is deleted
179
189
- Update Status
190
+
- Sets `.status.secretName` to the new Secret name
180
191
- Replaces `.status.ACID`, `.status.createdAt`, `.status.expiresAt`, and `.status.rotationEligibleAt` with the new values
181
192
- Sets `.status.lastRotated` to current timestamp
182
193
- Re-marks AC CR ready
183
-
- Emits an event to notify EDPM nodes about the rotation
184
-
- Requeue
185
-
- Schedules the next check at `(newExpiresAt - gracePeriodDays)`
194
+
- Emits `ApplicationCredentialRotated` event for EDPM visibility
195
+
- Propagation
196
+
- The openstack-operator `Owns` the AC CR, so the status change triggers re-reconciliation
197
+
- It reads the new `.status.secretName` and updates the service CR's `ApplicationCredentialSecret`
198
+
- The service operator detects the spec change and reads credentials from the new Secret
186
199
187
200
## Manual Rotation
188
201
@@ -203,8 +216,8 @@ This triggers seamless rotation with one pod restart and no authentication fallb
203
216
ApplicationCredentials in Keystone are **not automatically deleted** by the controller. This design decision prevents disrupting running services, especially EDPM nodes that actively use these credentials.
204
217
205
218
**Cleanup behavior:**
206
-
- **During rotation:** The old AC remains in Keystone and expires naturally based on its `expiresAt` timestamp. The new AC is created with fresh credentials.
207
-
- **When AC CR is deleted:** The ApplicationCredential remains in Keystone and continues to be valid until natural expiration.
219
+
- **During rotation:** The old AC remains in Keystone and expires naturally based on its `expiresAt` timestamp. The old K8s Secret is also retained (immutable). A new AC and a new immutable Secret are created.
220
+
- **When AC CR is deleted:** The controller removes the `openstack.org/ac-secret-protection` finalizer from **all** AC Secrets for the service (found by label), allowing owner-reference garbage collection to delete them. The ApplicationCredential in Keystone remains valid until natural expiration.
208
221
- **Manual cleanup:** If immediate cleanup is required, operators can manually delete the AC from Keystone:
This approach ensures that deleting the AC CR (intentionally or accidentally) does not cause immediate authentication failures across the control plane and EDPM deployments.
215
228
216
-
## Client-Side Helper Functions
229
+
## Exported API Helpers
217
230
218
-
Service operators can use these helper functions to consume ApplicationCredential data:
231
+
The `keystone-operator/api/v1beta1` package exports the following helpers for use by other operators:
Service operators read AC data directly from the Secret referenced by the service CR's `ApplicationCredentialSecret` field, using `ACIDSecretKey` and `ACSecretSecretKey` as the data keys.
0 commit comments