Skip to content

Commit a4e14c9

Browse files
authored
fix: install default resources regardless of CRD maintenance flag (#762)
* fix: install default resources regardless of CRD maintenance flag * add changelog entry
1 parent ae6bba1 commit a4e14c9

3 files changed

Lines changed: 26 additions & 37 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ All notable changes to this project will be documented in this file.
2727
so a Pod kept the certificate it was given at startup and eventually ran on an expired one
2828
indefinitely, even though cert-manager had long since renewed it in the Secret. The restart is
2929
scheduled halfway between cert-manager's own `status.renewalTime` and the expiry ([#752]).
30+
- Install default resources regardless of CRD maintenance flag ([#762]).
3031

3132
[#730]: https://github.com/stackabletech/secret-operator/pull/730
3233
[#735]: https://github.com/stackabletech/secret-operator/pull/735
3334
[#736]: https://github.com/stackabletech/secret-operator/pull/736
3435
[#743]: https://github.com/stackabletech/secret-operator/pull/743
3536
[#752]: https://github.com/stackabletech/secret-operator/pull/752
3637
[#759]: https://github.com/stackabletech/secret-operator/pull/759
38+
[#762]: https://github.com/stackabletech/secret-operator/pull/762
3739

3840
## [26.7.0] - 2026-07-21
3941

‎deploy/helm/secret-operator/templates/roles.yaml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,7 @@ rules:
158158
resources:
159159
- secretclasses
160160
verbs:
161-
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
162161
- create
163-
- patch
164-
{{- end }}
165162
- get
166163
- watch
167164
- list

‎rust/operator-binary/src/main.rs‎

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This will need changes in our and upstream error types.
33
#![allow(clippy::result_large_err)]
44

5-
use std::{future::Future, os::unix::prelude::FileTypeExt, path::PathBuf};
5+
use std::{os::unix::prelude::FileTypeExt, path::PathBuf};
66

77
use anyhow::{Context, Ok, anyhow};
88
use clap::Parser;
@@ -212,54 +212,47 @@ async fn main() -> anyhow::Result<()> {
212212
crd = v1alpha1::TrustStore::crd_name()
213213
));
214214

215-
let (webhook_server, initial_reconcile_rx) = create_webhook_server(
215+
let (webhook_server, _) = create_webhook_server(
216216
&operator_environment,
217217
maintenance.disable_crd_maintenance,
218218
readiness_checks,
219219
client.as_kube_client(),
220220
)
221221
.await?;
222222

223-
// Here, we multiply the initial reconcile signal received by the oneshot receiver
224-
// to be able to pass it to both the default custom resource deployer and to delay
225-
// the startup of the controller.
226-
let initial_reconcile_signal =
227-
SignalWatcher::new(initial_reconcile_rx.map(|_| ()));
228-
229223
let webhook_server = webhook_server
230224
.run(sigterm_watcher.handle())
231225
.map_err(|err| anyhow!(err).context("failed to run webhook server"));
232226

233-
let ca_secret_namespace = tls_secretclass_ca_secret_namespace
234-
.unwrap_or(operator_environment.operator_namespace.clone());
235-
236-
let default_secretclass = create_default_secretclass(
237-
initial_reconcile_signal.handle(),
238-
ca_secret_namespace,
239-
client.clone(),
240-
)
241-
.map_err(|err| {
242-
anyhow!(err).context("failed to apply default custom resources")
243-
});
244-
245-
let truststore_controller = truststore_controller::start(
246-
client.clone(),
247-
&watch_namespace,
248-
sigterm_watcher.handle(),
249-
)
250-
.map(anyhow::Ok);
251-
252-
let delayed_truststore_controller = async {
227+
let truststore_controller_and_secret_class = async {
253228
signal::crd_established(&client, v1alpha2::SecretClass::crd_name()).await?;
254229
secret_class_crd_check.mark_passed();
255230
signal::crd_established(&client, v1alpha1::TrustStore::crd_name()).await?;
256231
trust_store_crd_check.mark_passed();
257-
truststore_controller.await
232+
233+
let truststore_controller = truststore_controller::start(
234+
client.clone(),
235+
&watch_namespace,
236+
sigterm_watcher.handle(),
237+
)
238+
.map(anyhow::Ok);
239+
240+
let ca_secret_namespace = tls_secretclass_ca_secret_namespace
241+
.unwrap_or(operator_environment.operator_namespace.clone());
242+
243+
// Only create the secret class after the CRDs are established
244+
let default_secretclass =
245+
create_default_secretclass(ca_secret_namespace, client.clone())
246+
.map_err(|err| {
247+
anyhow!(err).context("failed to apply default custom resources")
248+
});
249+
250+
try_join!(truststore_controller, default_secretclass)?;
251+
Ok(())
258252
};
259253

260254
try_join!(
261-
delayed_truststore_controller,
262-
default_secretclass,
255+
truststore_controller_and_secret_class,
263256
webhook_server,
264257
eos_checker,
265258
)?;
@@ -272,12 +265,9 @@ async fn main() -> anyhow::Result<()> {
272265
}
273266

274267
async fn create_default_secretclass(
275-
initial_reconcile_signal: impl Future<Output = ()>,
276268
ca_secret_namespace: String,
277269
client: Client,
278270
) -> anyhow::Result<()> {
279-
initial_reconcile_signal.await;
280-
281271
tracing::info!("applying default secretclass");
282272

283273
let deserializer = serde_yaml::Deserializer::from_slice(include_bytes!("secretclass.yaml"));

0 commit comments

Comments
 (0)