diff --git a/docs/modules/commons-operator/pages/restarter.adoc b/docs/modules/commons-operator/pages/restarter.adoc index 3ba89fb..36993b5 100644 --- a/docs/modules/commons-operator/pages/restarter.adoc +++ b/docs/modules/commons-operator/pages/restarter.adoc @@ -64,7 +64,10 @@ spec: ==== Pod template annotations To detect changes, the operator adds an annotation for every referenced ConfigMap and Secret to the Pod template of the StatefulSet. -Its key is `configmap.restarter.stackable.tech/\{name\}` or `secret.restarter.stackable.tech/\{name\}`, its value is the UID and resource version of the referenced object (or `changes-ignored` if it is excluded as described above). +Its key is `configmap.restarter.stackable.tech/\{name\}` or `secret.restarter.stackable.tech/\{name\}`, its value is the UID and resource version of the referenced object. +The value is `changes-ignored` instead if the object is excluded, either by the StatefulSet annotations described above or by the `restarter.stackable.tech/ignore` label described below. +The value is also `changes-ignored` if the referenced object does not exist (yet), for example because the StatefulSet was created before a mounted Secret. +This is intended: once the object is created, the value changes to its UID and resource version (unless it is excluded), and the Pods are restarted to pick it up. Kubernetes rolling-restarts the Pods whenever one of these values changes. These annotations are managed by the operator, there is no need to set them yourself. diff --git a/rust/operator-binary/src/restart_controller/statefulset.rs b/rust/operator-binary/src/restart_controller/statefulset.rs index 754a31a..8e3e874 100644 --- a/rust/operator-binary/src/restart_controller/statefulset.rs +++ b/rust/operator-binary/src/restart_controller/statefulset.rs @@ -331,6 +331,15 @@ pub async fn get_updated_restarter_annotations( let cm_name = &cm_ref.name; let cm = cms.get(&cm_ref); + // It is intended that "changes-ignored" is also used if the ConfigMap is not in the store, + // i.e. it doesn't exist (yet), e.g. because the StatefulSet was created before the + // ConfigMap, or it has the label `restarter.stackable.tech/ignore=true` (filtered out by the + // watcher). Once the ConfigMap shows up, the value changes to its uid/resourceVersion + // (unless ignored via the StatefulSet annotations), which restarts the Pods so that they + // pick it up. + // Leaving out the annotation instead would not avoid any restart, but cause additional + // ones, e.g. when an object ignored via a StatefulSet annotation is created after the + // StatefulSet. let value = if let Some(cm) = cm && let Some(uid) = &cm.metadata.uid && let Some(resource_version) = &cm.metadata.resource_version @@ -383,6 +392,7 @@ pub async fn get_updated_restarter_annotations( let secret_name = &secret_ref.name; let secret = secrets.get(&secret_ref); + // Same as for ConfigMaps above, "changes-ignored" is intended for Secrets not in the store. let value = if let Some(secret) = secret && let Some(uid) = &secret.metadata.uid && let Some(resource_version) = &secret.metadata.resource_version