diff --git a/CHANGELOG.md b/CHANGELOG.md index a6760aa..84c92c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file. - Install and manage the OpenLineageConnection Custom Resource Definition ([#435]). - Add `/ready` endpoint to the operator Deployment, which reports the CRD installation status ([#461]). +- Add the StatefulSet annotation `restarter.stackable.tech/change-tracking-mechanism`. With the + value `data-hash`, the restarter only restarts Pods when the content of a referenced ConfigMap + or Secret changes, so content-identical writes by third parties no longer trigger a rolling + restart. The default `resource-version` keeps the previous behavior ([#449]). ### Changed @@ -17,6 +21,9 @@ All notable changes to this project will be documented in this file. - Extend Helm deployed RBAC permissions to list and watch customresourcedefinitions required for startup condition ([#461]). - The operator Deployment runs with a restricted security context, so it can be deployed into namespaces that enforce the `restricted` Pod Security Standard ([#462]). - The operator Deployment runs with a read-only root filesystem ([#469]). +- Extend Helm deployed RBAC permissions to get configmaps and secrets, required to digest their + content for the `data-hash` change tracking mechanism, and to create secrets in the operator + namespace, required to store the key of these digests ([#449]). ### Fixed @@ -28,6 +35,7 @@ All notable changes to this project will be documented in this file. [#439]: https://github.com/stackabletech/commons-operator/pull/439 [#443]: https://github.com/stackabletech/commons-operator/pull/443 [#444]: https://github.com/stackabletech/commons-operator/pull/444 +[#449]: https://github.com/stackabletech/commons-operator/pull/449 [#461]: https://github.com/stackabletech/commons-operator/pull/461 [#462]: https://github.com/stackabletech/commons-operator/pull/462 [#466]: https://github.com/stackabletech/commons-operator/pull/466 diff --git a/Cargo.lock b/Cargo.lock index dbc3ef5..2ba0864 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1107,9 +1107,9 @@ dependencies = [ [[package]] name = "granit-parser" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f05586d4d4df3d47123207826c40b252728b438a1a07bad3c01ee6bea401df" +checksum = "9bd04d0d9c7079b416b458d2317aea4aa964c81938cb7c20f559758c4f422dc8" dependencies = [ "arraydeque", "smallvec", @@ -1866,9 +1866,9 @@ checksum = "2e126dda6f34391ab7b444f9922055facc83c07a910da3eb16f1e4d9c45dc777" [[package]] name = "libz-sys" -version = "1.1.31" +version = "1.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff20308ecabd635a2dc1dd5834a86c462cca20efba1d5d3ddab1f8aea3455cb2" +checksum = "fee3f59f4321dab0c78d828942e7aa09d0bd8ad6e78a501977e6bf3d02938045" dependencies = [ "cc", "libc", @@ -2814,12 +2814,12 @@ dependencies = [ [[package]] name = "serde-saphyr" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f4dc2714fc5632417a6e979602d7044bad8f2880c63fc7217087180acec31b6" +checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9" dependencies = [ "annotate-snippets", - "base64 0.23.1", + "base64 0.22.1", "encoding_rs_io", "granit-parser", "nohash-hasher", @@ -3108,10 +3108,13 @@ dependencies = [ "chrono", "clap", "futures 0.3.34", + "hmac", "http", "json-patch", + "rand 0.10.3", "serde", "serde_json", + "sha2", "snafu 0.9.2", "stackable-operator", "strum", diff --git a/Cargo.nix b/Cargo.nix index 9a25838..e3dad5d 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -3612,10 +3612,10 @@ rec { }; "granit-parser" = rec { crateName = "granit-parser"; - version = "2.1.0"; + version = "2.2.0"; edition = "2021"; crateBin = []; - sha256 = "1pq1ljzfc7n0sfx0f6la8f5p4lmj81n841rj293kvpylsj35bw05"; + sha256 = "1j1d897qqxarylh7rjrq37469aaax9x33ljqnhbb8ybhkh6lvl4v"; libName = "granit_parser"; license = "MIT OR Apache-2.0"; authors = [ @@ -6336,10 +6336,10 @@ rec { }; "libz-sys" = rec { crateName = "libz-sys"; - version = "1.1.31"; + version = "1.1.33"; edition = "2018"; links = "z"; - sha256 = "1cjw8nisxy5iv8yms7dsxwhclb26djl38n6xq4nmlqxxra73087z"; + sha256 = "0ic0jc13vgz6fwcm12p7ss5bvl09mbkl52c2ip3v1ni18fgzbqzy"; libName = "libz_sys"; license = "MIT OR Apache-2.0"; authors = [ @@ -9678,10 +9678,10 @@ rec { }; "serde-saphyr" = rec { crateName = "serde-saphyr"; - version = "2.1.0"; + version = "2.2.0"; edition = "2024"; crateBin = []; - sha256 = "1diixjn80w882xrgqqqci3rdifj4f0nn0yg9lqbj8qy59xqw4k9z"; + sha256 = "1n87f1lfymy00y0fnr4kjq9xn1pqp2zsv6szigsvnk9l941xx74n"; libName = "serde_saphyr"; license = "MIT OR Apache-2.0"; dependencies = [ @@ -9692,7 +9692,7 @@ rec { } { name = "base64"; - packageId = "base64 0.23.1"; + packageId = "base64 0.22.1"; optional = true; } { @@ -10616,6 +10616,10 @@ rec { packageId = "futures 0.3.34"; features = [ "compat" ]; } + { + name = "hmac"; + packageId = "hmac"; + } { name = "http"; packageId = "http"; @@ -10624,6 +10628,10 @@ rec { name = "json-patch"; packageId = "json-patch"; } + { + name = "rand"; + packageId = "rand 0.10.3"; + } { name = "serde"; packageId = "serde"; @@ -10633,6 +10641,10 @@ rec { name = "serde_json"; packageId = "serde_json"; } + { + name = "sha2"; + packageId = "sha2"; + } { name = "snafu"; packageId = "snafu 0.9.2"; diff --git a/Cargo.toml b/Cargo.toml index 4d2cbc1..99482ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,12 @@ chrono = "0.4" clap = "4.6" futures = { version = "0.3", features = ["compat"] } http = "1.5" +hmac = "0.13" json-patch = "4.2" +rand = "0.10" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +sha2 = "0.11" snafu = "0.9" strum = { version = "0.28", features = ["derive"] } tokio = { version = "1.54", features = ["full"] } diff --git a/deploy/helm/commons-operator/templates/roles.yaml b/deploy/helm/commons-operator/templates/roles.yaml index 8ed0df3..e658d07 100644 --- a/deploy/helm/commons-operator/templates/roles.yaml +++ b/deploy/helm/commons-operator/templates/roles.yaml @@ -7,14 +7,23 @@ metadata: {{- include "commons-operator.labels" . | nindent 4 }} rules: # Watch pods to detect expired restart annotations. - # Watch configmaps and secrets to trigger rolling restarts of referencing StatefulSets. - apiGroups: - "" resources: - pods + verbs: + - list + - watch + # Watch configmaps and secrets to trigger rolling restarts of referencing StatefulSets. + # Get them to digest their content for StatefulSets using the change tracking mechanism + # data-hash (annotation restarter.stackable.tech/change-tracking-mechanism). + - apiGroups: + - "" + resources: - configmaps - secrets verbs: + - get - list - watch # For automatic cluster domain detection. @@ -73,3 +82,35 @@ rules: # Required for startup condition - list - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "commons-operator.fullname" . }}-role + labels: + {{- include "commons-operator.labels" . | nindent 4 }} +rules: + # Create the Secret holding the key of the content digests on first use of the change tracking + # mechanism data-hash (annotation restarter.stackable.tech/change-tracking-mechanism). + # Reading it is covered by the ClusterRole above. + - apiGroups: + - "" + resources: + - secrets + verbs: + - create +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "commons-operator.fullname" . }}-rolebinding + labels: + {{- include "commons-operator.labels" . | nindent 4 }} +subjects: + - kind: ServiceAccount + name: {{ include "commons-operator.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: {{ include "commons-operator.fullname" . }}-role + apiGroup: rbac.authorization.k8s.io diff --git a/docs/modules/commons-operator/pages/restarter.adoc b/docs/modules/commons-operator/pages/restarter.adoc index 36993b5..75cd938 100644 --- a/docs/modules/commons-operator/pages/restarter.adoc +++ b/docs/modules/commons-operator/pages/restarter.adoc @@ -61,13 +61,43 @@ spec: ... ---- +Annotation:: `restarter.stackable.tech/change-tracking-mechanism` + +This annotation selects what counts as a change of a referenced ConfigMap or Secret: + +`resource-version` (default):: Every write to the object counts as a change, including writes that only touch its metadata (labels, annotations, managed fields) or that write identical content. +`data-hash`:: Only a change of the content (`data` and `binaryData` of a ConfigMap, `data` of a Secret) counts as a change. +Writes by third parties that leave the content as it is do not restart the Pods. +To hash the content, the operator reads a referenced object whenever its resource version changes. +It only keeps the hash, not the content. +The hash is keyed with a random key that only the operator can read and bound to the UID of the object, so the hash in the Pod template annotations reveals nothing about the content beyond whether it changed. +On the first use of `data-hash`, the operator creates this key in the Secret `commons-operator-restarter-digest-key` in its own namespace. +Deleting that Secret, or the namespace, makes the operator create a new key on its next start, which changes every hash and therefore rolling-restarts every StatefulSet using `data-hash` once. + +With any other value, the operator logs an error and stops updating the Pod template annotations of the StatefulSet until the value is fixed. +Switching between the mechanisms changes the values of the Pod template annotations described below and therefore rolling-restarts the StatefulSet once. + +[source,yaml] +---- +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: statefulset-with-content-based-restarts + labels: + restarter.stackable.tech/enabled: "true" + annotations: + restarter.stackable.tech/change-tracking-mechanism: data-hash +... +---- + ==== 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. +Its key is `configmap.restarter.stackable.tech/\{name\}` or `secret.restarter.stackable.tech/\{name\}`, its value is the UID of the referenced object, followed by its resource version or, with the `data-hash` mechanism, a hash of its content. 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. +This is intended: once the object is created, the value changes as described above (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/Cargo.toml b/rust/operator-binary/Cargo.toml index 12c1a69..931db83 100644 --- a/rust/operator-binary/Cargo.toml +++ b/rust/operator-binary/Cargo.toml @@ -16,9 +16,12 @@ chrono.workspace = true clap.workspace = true http.workspace = true futures.workspace = true +hmac.workspace = true json-patch.workspace = true +rand.workspace = true serde.workspace = true serde_json.workspace = true +sha2.workspace = true snafu.workspace = true strum.workspace = true tokio.workspace = true diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index 0951e19..b512f5d 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -110,7 +110,10 @@ async fn main() -> anyhow::Result<()> { ) .await?; - let (ctx, cm_store_tx, secret_store_tx) = create_context(client.clone()); + let (ctx, cm_store_tx, secret_store_tx) = create_context( + client.clone(), + operator_environment.operator_namespace.clone(), + ); let mut readiness_checks = HealthCheckRegistry::new(); let authentication_class_crd_check = readiness_checks.register(format!( diff --git a/rust/operator-binary/src/restart_controller/content_digest.rs b/rust/operator-binary/src/restart_controller/content_digest.rs new file mode 100644 index 0000000..5df18f8 --- /dev/null +++ b/rust/operator-binary/src/restart_controller/content_digest.rs @@ -0,0 +1,343 @@ +//! Digests over the content of ConfigMaps and Secrets, for the `data-hash` change tracking +//! mechanism of the StatefulSet restarter. +//! +//! The restarter only watches the metadata of ConfigMaps and Secrets. The content of an object is +//! fetched on demand, only when a StatefulSet using `data-hash` references it, and only once per +//! resourceVersion: the [`DigestCache`] keeps the digest, never the content. +//! +//! The digests are keyed with a [`DigestKey`] and bound to the uid of their object, so that anyone +//! who can read them in the Pod template annotations learns nothing about the content beyond +//! whether it changed. + +use std::{ + collections::HashMap, + future::Future, + marker::PhantomData, + sync::{Mutex, MutexGuard}, +}; + +use hmac::{Hmac, Mac}; +use sha2::Sha256; +use stackable_operator::{ + k8s_openapi::{ + api::core::v1::{ConfigMap, Secret}, + apimachinery::pkg::apis::meta::v1::ObjectMeta, + }, + kube::Resource, +}; + +use crate::restart_controller::digest_key::DigestKey; + +/// An object whose content can be digested. +pub trait ContentDigest: Resource { + /// Keyed digest over the parts of the object that a Pod can read, bound to the object's `uid`. + fn content_digest(&self, uid: &str, digest_key: &DigestKey) -> String; +} + +impl ContentDigest for ConfigMap { + fn content_digest(&self, uid: &str, digest_key: &DigestKey) -> String { + let mut mac = object_mac(uid, digest_key); + mac.update(b"configmap/data"); + for (key, value) in self.data.iter().flatten() { + update_entry(&mut mac, key, value.as_bytes()); + } + mac.update(b"configmap/binaryData"); + for (key, value) in self.binary_data.iter().flatten() { + update_entry(&mut mac, key, &value.0); + } + finish_digest(mac) + } +} + +impl ContentDigest for Secret { + fn content_digest(&self, uid: &str, digest_key: &DigestKey) -> String { + let mut mac = object_mac(uid, digest_key); + mac.update(b"secret/data"); + for (key, value) in self.data.iter().flatten() { + update_entry(&mut mac, key, &value.0); + } + finish_digest(mac) + } +} + +/// Returns a new MAC keyed with `digest_key` and bound to the object with the given `uid`. +/// +/// Binding to the uid keeps the digests of different objects apart, even with identical content. +/// Otherwise anyone able to create an object could have the operator digest guesses of another +/// object's content and compare the results. +fn object_mac(uid: &str, digest_key: &DigestKey) -> Hmac { + let mut mac = digest_key.mac(); + update_entry(&mut mac, "uid", uid.as_bytes()); + mac +} + +/// Adds one key/value pair to `mac`, length-prefixed. +fn update_entry(mac: &mut Hmac, key: &str, value: &[u8]) { + mac.update(&(key.len() as u64).to_be_bytes()); + mac.update(key.as_bytes()); + mac.update(&(value.len() as u64).to_be_bytes()); + mac.update(value); +} + +/// Truncates the digest to 128 bits and hex-encodes it. +fn finish_digest(mac: Hmac) -> String { + mac.finalize().into_bytes()[..16] + .iter() + .map(|byte| format!("{byte:02x}")) + .collect() +} + +/// The content digest of one object at one resourceVersion. +/// +/// Deliberately holds no content, so no Secret data stays in memory after hashing. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct CachedDigest { + pub uid: String, + pub resource_version: String, + pub digest: String, +} + +/// Namespace and name of a cached object. +type CacheKey = (String, String); + +/// Content digests of the objects of kind `K` referenced by StatefulSets using `data-hash`, keyed +/// by namespace and name. +/// +/// An entry is replaced when the uid or resourceVersion changes, and removed when a fetch finds +/// the object gone. Entries of objects deleted without a later fetch stay until the operator +/// restarts. They cannot be served for a recreated object, which has a new uid, and are only a +/// few hundred bytes each, so they are not tracked any further. +#[derive(Debug)] +pub struct DigestCache { + entries: Mutex>, + kind: PhantomData K>, +} + +impl Default for DigestCache { + fn default() -> Self { + Self { + entries: Mutex::default(), + kind: PhantomData, + } + } +} + +impl DigestCache { + /// Returns the digest of the object described by `metadata`, as seen by the metadata watch. + /// + /// The cached digest is used if it was computed for the same uid and resourceVersion, + /// otherwise the object is fetched by calling `fetch` with its name and namespace, and its + /// digest cached. Returns `None` if `metadata` lacks a name or namespace, or `fetch` does not + /// find the object. + /// + /// All calls on one cache must pass the same `digest_key`, as the cached digests are not keyed + /// by it. + pub async fn get_or_fetch<'a, E, Fut>( + &self, + metadata: &'a ObjectMeta, + digest_key: &DigestKey, + fetch: impl FnOnce(&'a str, &'a str) -> Fut, + ) -> Result, E> + where + Fut: Future, E>>, + { + let (Some(namespace), Some(name)) = (&metadata.namespace, &metadata.name) else { + return Ok(None); + }; + let cache_key = (namespace.clone(), name.clone()); + + if let Some(cached) = self.lock().get(&cache_key) + && Some(&cached.uid) == metadata.uid.as_ref() + && Some(&cached.resource_version) == metadata.resource_version.as_ref() + { + return Ok(Some(cached.clone())); + } + + tracing::debug!( + k8s.object.namespace = namespace, + k8s.object.name = name, + "Fetching object to digest its content" + ); + let Some(object) = fetch(name, namespace).await? else { + self.lock().remove(&cache_key); + return Ok(None); + }; + let (Some(uid), Some(resource_version)) = ( + object.meta().uid.clone(), + object.meta().resource_version.clone(), + ) else { + return Ok(None); + }; + let cached = CachedDigest { + digest: object.content_digest(&uid, digest_key), + uid, + resource_version, + }; + self.lock().insert(cache_key, cached.clone()); + + Ok(Some(cached)) + } + + fn lock(&self) -> MutexGuard<'_, HashMap> { + self.entries + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner) + } +} + +#[cfg(test)] +mod tests { + use std::{cell::Cell, convert::Infallible}; + + use stackable_operator::k8s_openapi::{ + ByteString, apimachinery::pkg::apis::meta::v1::ManagedFieldsEntry, + }; + + use super::*; + + const TEST_KEY: DigestKey = DigestKey::new([42; 32]); + + const TEST_UID: &str = "f9dc0a8f-5f4b-4f52-9d0f-1a0ba1e0bd2c"; + + fn config_map(data: &[(&str, &str)]) -> ConfigMap { + ConfigMap { + data: Some( + data.iter() + .map(|(key, value)| ((*key).to_owned(), (*value).to_owned())) + .collect(), + ), + ..ConfigMap::default() + } + } + + fn metadata(uid: &str, resource_version: &str) -> ObjectMeta { + ObjectMeta { + name: Some("my-config".to_owned()), + namespace: Some("my-namespace".to_owned()), + uid: Some(uid.to_owned()), + resource_version: Some(resource_version.to_owned()), + ..ObjectMeta::default() + } + } + + fn stored(uid: &str, resource_version: &str, data: &[(&str, &str)]) -> ConfigMap { + ConfigMap { + metadata: metadata(uid, resource_version), + ..config_map(data) + } + } + + /// Changing the digest function rolling-restarts every StatefulSet using `data-hash`. + #[test] + fn digest_is_stable_across_releases() { + let binary_config_map = ConfigMap { + binary_data: Some([("foo".to_owned(), ByteString(b"bar".to_vec()))].into()), + ..ConfigMap::default() + }; + let secret = Secret { + data: Some([("foo".to_owned(), ByteString(b"bar".to_vec()))].into()), + ..Secret::default() + }; + + assert_eq!( + config_map(&[("foo", "bar")]).content_digest(TEST_UID, &TEST_KEY), + "aec6a1a9a372bda7f4b7a600d631186f" + ); + assert_eq!( + binary_config_map.content_digest(TEST_UID, &TEST_KEY), + "c2efb2422a076038e7e3affa23d7ffb1" + ); + assert_eq!( + secret.content_digest(TEST_UID, &TEST_KEY), + "646f7311f8401d03267d18cf5419ba32" + ); + } + + #[test] + fn digest_ignores_metadata() { + let mut changed = config_map(&[("foo", "bar")]); + changed.metadata = ObjectMeta { + resource_version: Some("12345".to_owned()), + labels: Some([("cost-center".to_owned(), "irrelevant".to_owned())].into()), + annotations: Some([("probe".to_owned(), "1".to_owned())].into()), + managed_fields: Some(vec![ManagedFieldsEntry { + manager: Some("third-party-controller".to_owned()), + ..ManagedFieldsEntry::default() + }]), + ..ObjectMeta::default() + }; + + assert_eq!( + config_map(&[("foo", "bar")]).content_digest(TEST_UID, &TEST_KEY), + changed.content_digest(TEST_UID, &TEST_KEY) + ); + } + + /// Each pair would collide without the key, the uid binding, the length prefixes or the field + /// prefixes. + #[test] + fn digest_distinguishes_content() { + let binary = ConfigMap { + binary_data: Some([("foo".to_owned(), ByteString(b"bar".to_vec()))].into()), + ..ConfigMap::default() + }; + let text = config_map(&[("foo", "bar")]); + + for (left, right) in [ + ( + text.content_digest(TEST_UID, &TEST_KEY), + text.content_digest(TEST_UID, &DigestKey::new([43; 32])), + ), + ( + text.content_digest(TEST_UID, &TEST_KEY), + text.content_digest("0b6f1a52-2d1e-4c43-8c55-5ad3d3a4e7f1", &TEST_KEY), + ), + ( + config_map(&[("ab", "c")]).content_digest(TEST_UID, &TEST_KEY), + config_map(&[("a", "bc")]).content_digest(TEST_UID, &TEST_KEY), + ), + ( + text.content_digest(TEST_UID, &TEST_KEY), + binary.content_digest(TEST_UID, &TEST_KEY), + ), + ] { + assert_ne!(left, right); + } + } + + /// Each step looks the object up by uid and resourceVersion, with the content a fetch returns + /// (`None` if the object is gone) and whether the cache has to fetch it. + #[tokio::test] + async fn cache_fetches_once_per_uid_and_resource_version() { + let cache = DigestCache::::default(); + + for (uid, resource_version, content, fetches) in [ + ("uid-1", "100", Some("bar"), true), + ("uid-1", "100", Some("bar"), false), + ("uid-1", "101", Some("baz"), true), + ("uid-2", "101", Some("qux"), true), + ("uid-2", "102", None, true), + ("uid-2", "101", Some("qux"), true), + ] { + let fetched = Cell::new(false); + let object = content.map(|content| stored(uid, resource_version, &[("foo", content)])); + let cached = cache + .get_or_fetch(&metadata(uid, resource_version), &TEST_KEY, |_, _| { + fetched.set(true); + std::future::ready(Ok::<_, Infallible>(object.clone())) + }) + .await + .expect("fetching should be infallible"); + + assert_eq!(fetched.get(), fetches); + assert_eq!( + cached, + object.map(|object| CachedDigest { + uid: uid.to_owned(), + resource_version: resource_version.to_owned(), + digest: object.content_digest(uid, &TEST_KEY), + }) + ); + } + } +} diff --git a/rust/operator-binary/src/restart_controller/digest_key.rs b/rust/operator-binary/src/restart_controller/digest_key.rs new file mode 100644 index 0000000..8b1994f --- /dev/null +++ b/rust/operator-binary/src/restart_controller/digest_key.rs @@ -0,0 +1,186 @@ +//! The secret key of the content digests of the `data-hash` change tracking mechanism. +//! +//! The digests end up in Pod template annotations, which anyone who can read a StatefulSet or its +//! Pods can see. Without a secret key, a digest would let them verify guesses of a Secret's +//! content offline. Each digest is also bound to the uid of its object (see +//! [`crate::restart_controller::content_digest`]), so that the operator cannot be used to verify +//! such guesses either. The key lives in a Secret in the operator namespace, so that it survives +//! operator restarts: a new key changes every digest and rolling-restarts every StatefulSet using +//! `data-hash`. + +use std::fmt; + +use hmac::{Hmac, KeyInit}; +use sha2::Sha256; +use snafu::{OptionExt, ResultExt, Snafu}; +use stackable_operator::{ + builder::meta::ObjectMetaBuilder, + client::Client, + k8s_openapi::{ByteString, api::core::v1::Secret}, + kvp::Label, +}; +use tokio::sync::OnceCell; + +/// Name of the Secret holding the [`DigestKey`]. +const SECRET_NAME: &str = "commons-operator-restarter-digest-key"; + +/// Entry of the Secret data holding the [`DigestKey`]. +const SECRET_DATA_KEY: &str = "key"; + +/// Length of the [`DigestKey`] in bytes. +const KEY_LENGTH: usize = 32; + +#[derive(Debug, Snafu)] +pub enum Error { + #[snafu(display("failed to load or create the digest key Secret {secret_name:?}"))] + LoadOrCreateSecret { + source: stackable_operator::client::Error, + secret_name: String, + }, + + #[snafu(display( + "the digest key Secret {secret_name:?} does not hold a {KEY_LENGTH} byte key in {SECRET_DATA_KEY:?}, delete it to generate a new key (this rolling-restarts every StatefulSet using data-hash)" + ))] + InvalidKey { secret_name: String }, +} + +/// The secret key of the content digests. +#[derive(Clone)] +pub struct DigestKey([u8; KEY_LENGTH]); + +impl DigestKey { + pub const fn new(bytes: [u8; KEY_LENGTH]) -> Self { + Self(bytes) + } + + /// Returns a new HMAC-SHA256 keyed with this key. + pub fn mac(&self) -> Hmac { + Hmac::new_from_slice(&self.0).expect("HMAC must accept keys of any length") + } + + fn generate() -> Self { + Self::new(rand::random()) + } + + fn from_secret(secret: &Secret) -> Result { + let bytes = secret + .data + .as_ref() + .and_then(|data| data.get(SECRET_DATA_KEY)) + .and_then(|value| <[u8; KEY_LENGTH]>::try_from(value.0.as_slice()).ok()) + .context(InvalidKeySnafu { + secret_name: SECRET_NAME, + })?; + + Ok(Self::new(bytes)) + } + + fn to_secret(&self, namespace: &str) -> Secret { + Secret { + metadata: ObjectMetaBuilder::new() + .name(SECRET_NAME) + .namespace(namespace) + .with_label(Label::stackable_vendor()) + .build(), + data: Some([(SECRET_DATA_KEY.to_owned(), ByteString(self.0.to_vec()))].into()), + immutable: Some(true), + ..Secret::default() + } + } +} + +/// Redacted, so that the key never ends up in logs. +impl fmt::Debug for DigestKey { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter.write_str("DigestKey()") + } +} + +/// Loads the [`DigestKey`] on first use, creating its Secret if it does not exist yet. +/// +/// Loading lazily keeps the operator startup independent of the Secret, so installations that do +/// not use `data-hash` never create it and do not need the permission to. +pub struct DigestKeyStore { + client: Client, + namespace: String, + key: OnceCell, +} + +impl DigestKeyStore { + pub fn new(client: Client, namespace: String) -> Self { + Self { + client, + namespace, + key: OnceCell::new(), + } + } + + /// Returns the key, loading or creating its Secret in the operator namespace on first use. + /// + /// A failed attempt is not cached, the next call tries again. + pub async fn get(&self) -> Result<&DigestKey, Error> { + self.key + .get_or_try_init(|| async { + let secret = self + .client + .create_if_missing(&DigestKey::generate().to_secret(&self.namespace)) + .await + .context(LoadOrCreateSecretSnafu { + secret_name: SECRET_NAME, + })?; + DigestKey::from_secret(&secret) + }) + .await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn key_round_trips_through_its_secret() { + let key = DigestKey::new([7; KEY_LENGTH]); + let secret = key.to_secret("operator-namespace"); + + assert_eq!(secret.metadata.name.as_deref(), Some(SECRET_NAME)); + assert_eq!( + secret.metadata.namespace.as_deref(), + Some("operator-namespace") + ); + assert_eq!(secret.immutable, Some(true)); + assert_eq!( + DigestKey::from_secret(&secret) + .expect("a Secret built from a key should hold a valid key") + .0, + key.0 + ); + } + + #[test] + fn secret_without_valid_key_is_rejected() { + let short_key = Secret { + data: Some([(SECRET_DATA_KEY.to_owned(), ByteString(vec![7; 16]))].into()), + ..Secret::default() + }; + let wrong_entry = Secret { + data: Some([("other".to_owned(), ByteString(vec![7; KEY_LENGTH]))].into()), + ..Secret::default() + }; + + for secret in [Secret::default(), short_key, wrong_entry] { + assert!(matches!( + DigestKey::from_secret(&secret), + Err(Error::InvalidKey { .. }) + )); + } + } + + #[test] + fn debug_output_redacts_the_key() { + assert_eq!( + format!("{:?}", DigestKey::new([7; KEY_LENGTH])), + "DigestKey()" + ); + } +} diff --git a/rust/operator-binary/src/restart_controller/mod.rs b/rust/operator-binary/src/restart_controller/mod.rs index 37b6488..5f171a6 100644 --- a/rust/operator-binary/src/restart_controller/mod.rs +++ b/rust/operator-binary/src/restart_controller/mod.rs @@ -1,2 +1,4 @@ +pub mod content_digest; +pub mod digest_key; pub mod pod; pub mod statefulset; diff --git a/rust/operator-binary/src/restart_controller/statefulset.rs b/rust/operator-binary/src/restart_controller/statefulset.rs index 8e3e874..87a0665 100644 --- a/rust/operator-binary/src/restart_controller/statefulset.rs +++ b/rust/operator-binary/src/restart_controller/statefulset.rs @@ -1,18 +1,24 @@ use std::{ collections::{BTreeMap, BTreeSet}, + fmt::Debug, future::Future, sync::Arc, time::Duration, }; use futures::{Stream, StreamExt, TryStream, stream}; +use serde::de::DeserializeOwned; use serde_json::json; use snafu::{ResultExt, Snafu}; use stackable_operator::{ client::Client, - k8s_openapi::api::{ - apps::v1::StatefulSet, - core::v1::{ConfigMap, EnvFromSource, EnvVar, PodSpec, Secret, Volume}, + k8s_openapi::{ + NamespaceResourceScope, + api::{ + apps::v1::StatefulSet, + core::v1::{ConfigMap, EnvFromSource, EnvVar, PodSpec, Secret, Volume}, + }, + apimachinery::pkg::apis::meta::v1::ObjectMeta, }, kube::{ self, Resource, ResourceExt, @@ -30,9 +36,15 @@ use stackable_operator::{ logging::controller::{ReconcilerError, report_controller_reconciled}, namespace::WatchNamespace, }; -use strum::{EnumDiscriminants, IntoStaticStr}; +use strum::{EnumDiscriminants, EnumString, IntoStaticStr}; -use crate::utils::delayed_init::{DelayedInit, InitDropped, Initializer}; +use crate::{ + restart_controller::{ + content_digest::{ContentDigest, DigestCache}, + digest_key::{self, DigestKeyStore}, + }, + utils::delayed_init::{DelayedInit, InitDropped, Initializer}, +}; const FULL_CONTROLLER_NAME: &str = "statefulset.restarter.commons.stackable.tech"; @@ -42,10 +54,45 @@ const CONFIGMAP_ANNOTATION_PREFIX: &str = "configmap.restarter.stackable.tech"; /// Prefix of the Pod annotations tracking the referenced Secrets. const SECRET_ANNOTATION_PREFIX: &str = "secret.restarter.stackable.tech"; +/// StatefulSet annotation selecting the [`ChangeTrackingMechanism`]. +const CHANGE_TRACKING_MECHANISM_ANNOTATION: &str = + "restarter.stackable.tech/change-tracking-mechanism"; + +/// How the restarter decides that a referenced ConfigMap or Secret has changed. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, EnumString)] +#[strum(serialize_all = "kebab-case")] +enum ChangeTrackingMechanism { + /// Every write to the object counts as a change, including metadata-only writes. + /// + /// Only needs the metadata of the object, which the restarter watches anyway. + #[default] + ResourceVersion, + + /// Only changes to the content (`data` and `binaryData`) count as a change. + /// + /// Fetches the object whenever its resourceVersion changes, to digest its content. + DataHash, +} + +impl ChangeTrackingMechanism { + /// Reads the mechanism from the StatefulSet annotation, falling back to the default. + fn from_statefulset(sts: &StatefulSet) -> Result { + match sts.annotations().get(CHANGE_TRACKING_MECHANISM_ANNOTATION) { + Some(value) => value + .parse() + .context(InvalidChangeTrackingMechanismSnafu { value }), + None => Ok(Self::default()), + } + } +} + pub struct Ctx { client: Client, cms: DelayedInit>>, secrets: DelayedInit>>, + cm_digests: DigestCache, + secret_digests: DigestCache, + digest_key: DigestKeyStore, } #[derive(Snafu, Debug, EnumDiscriminants)] @@ -74,6 +121,23 @@ pub enum Error { source: KeyError, object_name: String, }, + + #[snafu(display( + "invalid value {value:?} for StatefulSet annotation {CHANGE_TRACKING_MECHANISM_ANNOTATION:?}, expected one of \"resource-version\" or \"data-hash\"" + ))] + InvalidChangeTrackingMechanism { + source: strum::ParseError, + value: String, + }, + + #[snafu(display("failed to fetch {obj_ref} to digest its content"))] + FetchContentFailed { + source: stackable_operator::client::Error, + obj_ref: Box>, + }, + + #[snafu(display("failed to load the key for content digests"))] + LoadDigestKey { source: digest_key::Error }, } impl ReconcilerError for Error { @@ -88,6 +152,9 @@ impl ReconcilerError for Error { Error::ConfigMapsUninitialized { .. } => None, Error::SecretsUninitialized { .. } => None, Error::InvalidAnnotationKey { .. } => None, + Error::InvalidChangeTrackingMechanism { .. } => None, + Error::FetchContentFailed { obj_ref, .. } => Some(*obj_ref.clone()), + Error::LoadDigestKey { .. } => None, } } } @@ -95,6 +162,7 @@ impl ReconcilerError for Error { #[allow(clippy::type_complexity)] pub fn create_context( client: Client, + operator_namespace: String, ) -> ( Arc, Initializer>>, @@ -103,9 +171,12 @@ pub fn create_context( let (cm_store_tx, cm_store_delayed) = DelayedInit::new(); let (secret_store_tx, secret_store_delayed) = DelayedInit::new(); let ctx = Arc::new(Ctx { - client, + client: client.clone(), cms: cm_store_delayed, secrets: secret_store_delayed, + cm_digests: DigestCache::default(), + secret_digests: DigestCache::default(), + digest_key: DigestKeyStore::new(client, operator_namespace), }); (ctx, cm_store_tx, secret_store_tx) @@ -274,6 +345,47 @@ fn annotation_key(prefix: &str, object_name: &str) -> Result { Ok(key.to_string()) } +/// Value of the Pod template annotation tracking the object with the given `metadata` for +/// `ChangeTrackingMechanism::ResourceVersion`, or `None` if the metadata lacks uid or +/// resourceVersion. +fn resource_version_value(metadata: &ObjectMeta) -> Option { + let uid = metadata.uid.as_deref()?; + let resource_version = metadata.resource_version.as_deref()?; + Some(format!("{uid}/{resource_version}")) +} + +/// Value of the Pod template annotation tracking `object` according to `mechanism`, or `None` if +/// it cannot be determined, e.g. because the object was deleted in the meantime. +/// +/// For [`ChangeTrackingMechanism::DataHash`] this fetches the object, unless `digests` already +/// holds the digest for its current resourceVersion. +async fn tracking_value( + ctx: &Ctx, + digests: &DigestCache, + object: &PartialObjectMeta, + mechanism: ChangeTrackingMechanism, +) -> Result, Error> +where + K: ContentDigest + Resource + Clone + Debug + DeserializeOwned, +{ + let metadata = &object.metadata; + match mechanism { + ChangeTrackingMechanism::ResourceVersion => Ok(resource_version_value(metadata)), + ChangeTrackingMechanism::DataHash => { + let digest_key = ctx.digest_key.get().await.context(LoadDigestKeySnafu)?; + let cached = digests + .get_or_fetch(metadata, digest_key, |name, namespace| { + ctx.client.get_opt::(name, namespace) + }) + .await + .with_context(|_| FetchContentFailedSnafu { + obj_ref: ObjectRef::from_obj(object).erase(), + })?; + Ok(cached.map(|cached| format!("{}/{}", cached.uid, cached.digest))) + } + } +} + pub async fn get_updated_restarter_annotations( sts: &StatefulSet, ctx: Arc, @@ -281,6 +393,7 @@ pub async fn get_updated_restarter_annotations( let ns = sts.metadata.namespace.as_deref().expect( "A StatefulSet observed by a reflector (so send by Kubernetes) always has a namespace set", ); + let mechanism = ChangeTrackingMechanism::from_statefulset(sts)?; let mut annotations = BTreeMap::::new(); let pod_specs = sts @@ -334,21 +447,19 @@ pub async fn get_updated_restarter_annotations( // 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. + // watcher). Once the ConfigMap shows up, the value changes to its tracking value (see + // `ChangeTrackingMechanism`, 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 - && !ignored_cms.contains(cm_name) - { - format!("{uid}/{resource_version}",) - } else { - "changes-ignored".to_owned() - }; + let value = match cm { + Some(cm) if !ignored_cms.contains(cm_name) => { + tracking_value(&ctx, &ctx.cm_digests, &cm, mechanism).await? + } + _ => None, + } + .unwrap_or_else(|| "changes-ignored".to_owned()); annotations.insert(annotation_key(CONFIGMAP_ANNOTATION_PREFIX, cm_name)?, value); } @@ -393,15 +504,13 @@ pub async fn get_updated_restarter_annotations( 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 - && !ignored_secrets.contains(secret_name) - { - format!("{uid}/{resource_version}",) - } else { - "changes-ignored".to_owned() - }; + let value = match secret { + Some(secret) if !ignored_secrets.contains(secret_name) => { + tracking_value(&ctx, &ctx.secret_digests, &secret, mechanism).await? + } + _ => None, + } + .unwrap_or_else(|| "changes-ignored".to_owned()); annotations.insert( annotation_key(SECRET_ANNOTATION_PREFIX, secret_name)?, @@ -464,6 +573,7 @@ fn error_policy(_obj: Arc>, error: &Error, _ctx: A match error { // root object is invalid, will be requeued when modified anyway Error::InvalidStatefulSet { .. } => Action::await_change(), + Error::InvalidChangeTrackingMechanism { .. } => Action::await_change(), _ => Action::requeue(Duration::from_secs(5)), } @@ -497,4 +607,54 @@ mod tests { "secret.restarter.stackable.tech/hiverest-owner-user.stackable-postgres-cluster.credent-8221aa71" ); } + + fn statefulset_with_mechanism(mechanism: Option<&str>) -> StatefulSet { + StatefulSet { + metadata: ObjectMeta { + annotations: mechanism.map(|mechanism| { + [( + CHANGE_TRACKING_MECHANISM_ANNOTATION.to_owned(), + mechanism.to_owned(), + )] + .into() + }), + ..ObjectMeta::default() + }, + ..StatefulSet::default() + } + } + + #[test] + fn change_tracking_mechanism_is_read_from_the_annotation() { + for (annotation, expected) in [ + (None, Some(ChangeTrackingMechanism::ResourceVersion)), + ( + Some("resource-version"), + Some(ChangeTrackingMechanism::ResourceVersion), + ), + (Some("data-hash"), Some(ChangeTrackingMechanism::DataHash)), + (Some("DataHash"), None), + ] { + assert_eq!( + ChangeTrackingMechanism::from_statefulset(&statefulset_with_mechanism(annotation)) + .ok(), + expected + ); + } + } + + #[test] + fn resource_version_value_matches_previous_releases() { + let metadata = ObjectMeta { + uid: Some("f9dc0a8f-5f4b-4f52-9d0f-1a0ba1e0bd2c".to_owned()), + resource_version: Some("12345".to_owned()), + ..ObjectMeta::default() + }; + + assert_eq!( + resource_version_value(&metadata).as_deref(), + Some("f9dc0a8f-5f4b-4f52-9d0f-1a0ba1e0bd2c/12345") + ); + assert_eq!(resource_version_value(&ObjectMeta::default()), None); + } } diff --git a/rust/operator-binary/src/webhooks/restarter_mutate_sts.rs b/rust/operator-binary/src/webhooks/restarter_mutate_sts.rs index a00548e..19f3aeb 100644 --- a/rust/operator-binary/src/webhooks/restarter_mutate_sts.rs +++ b/rust/operator-binary/src/webhooks/restarter_mutate_sts.rs @@ -23,7 +23,7 @@ use stackable_operator::{ use crate::{ FIELD_MANAGER, OPERATOR_NAME, - restart_controller::statefulset::{Ctx, get_updated_restarter_annotations}, + restart_controller::statefulset::{Ctx, Error, get_updated_restarter_annotations}, }; pub fn create_webhook( @@ -94,9 +94,14 @@ fn get_sts_restarter_mutating_webhook_configuration() -> MutatingWebhookConfigur // > Webhooks typically operate only on the content of the AdmissionReview sent to them. // > Some webhooks, however, make out-of-band changes as part of processing admission requests. // - // We read in the state of the world using the ConfigMap and Secret store. - // So, technically our outcome depends on external factors, *but* this webhook is not - // creating any external objects, so from our understanding it's side-effect free. + // We read in the state of the world using the ConfigMap and Secret store and, for the + // `data-hash` change tracking mechanism, by fetching the referenced ConfigMaps and + // Secrets. So, technically our outcome depends on external factors. + // The only object this webhook may create is the Secret holding the digest key of + // `data-hash`, on its first use (see `DigestKeyStore`). Creating it is idempotent and + // happens on the first reconcile of such a StatefulSet anyway, so even when triggered + // by a dry-run request it has no effect beyond what the real request would have. We + // therefore consider this webhook side-effect free. side_effects: "None".to_owned(), ..Default::default() }]), @@ -135,6 +140,21 @@ async fn add_sts_restarter_annotations_handler( let annotations = match get_updated_restarter_annotations(sts, ctx).await { Ok(annotations) => annotations, + // Rejecting the StatefulSet would block its creation over a typo in the change tracking + // mechanism or an API error while fetching a ConfigMap or Secret or loading the digest key. + // Admitting it without the annotations instead has the same outcome as + // `failure_policy: Ignore`: the controller adds them later, which restarts the Pods once. + Err( + err @ (Error::InvalidChangeTrackingMechanism { .. } + | Error::FetchContentFailed { .. } + | Error::LoadDigestKey { .. }), + ) => { + tracing::warn!( + error = &err as &dyn std::error::Error, + "Admitting StatefulSet without restarter annotations" + ); + return AdmissionResponse::from(&request); + } Err(err) => { return AdmissionResponse::invalid(format!( "failed to get updated restarted annotations: {err:#}" diff --git a/tests/templates/kuttl/restarter-no-unneeded-restart/03-assert.yaml b/tests/templates/kuttl/restarter-no-unneeded-restart/03-assert.yaml new file mode 100644 index 0000000..f6463bb --- /dev/null +++ b/tests/templates/kuttl/restarter-no-unneeded-restart/03-assert.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 300 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: data-hash + generation: 1 +status: + readyReplicas: 2 + replicas: 2 diff --git a/tests/templates/kuttl/restarter-no-unneeded-restart/03-data-hash.yaml b/tests/templates/kuttl/restarter-no-unneeded-restart/03-data-hash.yaml new file mode 100644 index 0000000..17946a7 --- /dev/null +++ b/tests/templates/kuttl/restarter-no-unneeded-restart/03-data-hash.yaml @@ -0,0 +1,41 @@ +--- +# With the data-hash change tracking mechanism, only content changes of the ConfigMap restart the +# Pods, writes that only touch its metadata do not. + +apiVersion: v1 +kind: ConfigMap +metadata: + name: data-hash-config +data: + foo: bar +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: data-hash + labels: + restarter.stackable.tech/enabled: "true" + annotations: + restarter.stackable.tech/change-tracking-mechanism: data-hash +spec: + selector: + matchLabels: + app: data-hash + serviceName: data-hash + replicas: 2 + template: + metadata: + labels: + app: data-hash + spec: + terminationGracePeriodSeconds: 1 + containers: + - name: nginx + image: nginxinc/nginx-unprivileged:1.27 + volumeMounts: + - name: config + mountPath: /config + volumes: + - name: config + configMap: + name: data-hash-config diff --git a/tests/templates/kuttl/restarter-no-unneeded-restart/04-assert.yaml b/tests/templates/kuttl/restarter-no-unneeded-restart/04-assert.yaml new file mode 100644 index 0000000..c5bc2db --- /dev/null +++ b/tests/templates/kuttl/restarter-no-unneeded-restart/04-assert.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: data-hash + generation: 1 diff --git a/tests/templates/kuttl/restarter-no-unneeded-restart/04-metadata-only-write.yaml b/tests/templates/kuttl/restarter-no-unneeded-restart/04-metadata-only-write.yaml new file mode 100644 index 0000000..5c51b77 --- /dev/null +++ b/tests/templates/kuttl/restarter-no-unneeded-restart/04-metadata-only-write.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: kubectl label configmap data-hash-config --namespace $NAMESPACE third-party=true + # Give the restarter time to react, otherwise the following assert passes right away. + - script: sleep 15 diff --git a/tests/templates/kuttl/restarter-no-unneeded-restart/05-assert.yaml b/tests/templates/kuttl/restarter-no-unneeded-restart/05-assert.yaml new file mode 100644 index 0000000..80c5ff0 --- /dev/null +++ b/tests/templates/kuttl/restarter-no-unneeded-restart/05-assert.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: data-hash + generation: 2 diff --git a/tests/templates/kuttl/restarter-no-unneeded-restart/05-content-change.yaml b/tests/templates/kuttl/restarter-no-unneeded-restart/05-content-change.yaml new file mode 100644 index 0000000..70b3621 --- /dev/null +++ b/tests/templates/kuttl/restarter-no-unneeded-restart/05-content-change.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: data-hash-config +data: + foo: baz