From 1dd88fbe5acd7ea80bd4196b99432afe613b64ef Mon Sep 17 00:00:00 2001 From: Techassi Date: Mon, 14 Sep 2026 12:29:47 +0200 Subject: [PATCH] feat: Support floating tag in product image selection --- Cargo.lock | 28 ++++---- Cargo.nix | 65 ++++++++++++------- Cargo.toml | 2 +- crate-hashes.json | 18 ++--- extra/crds.yaml | 42 +++++++++++- rust/operator-binary/src/main.rs | 7 ++ .../src/zk_controller/validate.rs | 2 +- .../src/znode_controller/validate.rs | 2 +- 8 files changed, 116 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 619c4378..377e9297 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -340,9 +340,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "chacha20" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", "cpufeatures 0.3.0", @@ -1709,7 +1709,7 @@ dependencies = [ [[package]] name = "k8s-version" version = "0.1.3" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "darling 0.24.0", "regex", @@ -2818,6 +2818,10 @@ name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] [[package]] name = "serde" @@ -3127,7 +3131,7 @@ checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "stackable-certs" version = "0.4.1" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "const-oid", "ecdsa", @@ -3150,8 +3154,8 @@ dependencies = [ [[package]] name = "stackable-operator" -version = "0.116.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +version = "0.118.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "base64 0.23.1", "clap", @@ -3195,7 +3199,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.3.1" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "darling 0.24.0", "proc-macro2", @@ -3206,7 +3210,7 @@ dependencies = [ [[package]] name = "stackable-shared" version = "0.1.2" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "jiff", "k8s-openapi", @@ -3223,7 +3227,7 @@ dependencies = [ [[package]] name = "stackable-telemetry" version = "0.6.5" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "axum", "clap", @@ -3247,7 +3251,7 @@ dependencies = [ [[package]] name = "stackable-versioned" version = "0.11.1" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "kube", "schemars", @@ -3261,7 +3265,7 @@ dependencies = [ [[package]] name = "stackable-versioned-macros" version = "0.11.1" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "convert_case", "convert_case_extras", @@ -3279,7 +3283,7 @@ dependencies = [ [[package]] name = "stackable-webhook" version = "0.9.2" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#7b9f9ac9a76fa425ab27f2821377ef86571ca121" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1" dependencies = [ "arc-swap", "async-trait", diff --git a/Cargo.nix b/Cargo.nix index 6aab6b79..e8f5c30c 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -1049,9 +1049,9 @@ rec { }; "chacha20" = rec { crateName = "chacha20"; - version = "0.10.1"; + version = "0.10.2"; edition = "2024"; - sha256 = "108aajbvs3rwl4d0pdvq3p8ydy4pwh0rxy2z265ynwkflrmla96m"; + sha256 = "01hvvbgdmqkcgs2s4f12s9wa5h2gbq05rqvypv61azlwd55mxhv5"; authors = [ "RustCrypto Developers" ]; @@ -5424,8 +5424,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; libName = "k8s_version"; authors = [ @@ -9340,11 +9340,27 @@ rec { authors = [ "David Tolnay " ]; + dependencies = [ + { + name = "serde"; + packageId = "serde"; + optional = true; + usesDefaultFeatures = false; + target = { target, features }: false; + } + { + name = "serde_core"; + packageId = "serde_core"; + rename = "serde"; + optional = true; + usesDefaultFeatures = false; + } + ]; features = { "default" = [ "std" ]; "serde" = [ "dep:serde" ]; }; - resolvedDefaultFeatures = [ "default" "std" ]; + resolvedDefaultFeatures = [ "default" "serde" "std" ]; }; "serde" = rec { crateName = "serde"; @@ -10261,8 +10277,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; libName = "stackable_certs"; authors = [ @@ -10359,13 +10375,13 @@ rec { }; "stackable-operator" = rec { crateName = "stackable-operator"; - version = "0.116.0"; + version = "0.118.0"; edition = "2024"; workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; libName = "stackable_operator"; authors = [ @@ -10456,6 +10472,7 @@ rec { { name = "semver"; packageId = "semver"; + features = [ "serde" ]; } { name = "serde"; @@ -10545,8 +10562,10 @@ rec { "client-feature-gates" = [ "dep:winnow" ]; "crds" = [ "dep:stackable-versioned" ]; "default" = [ "crds" ]; - "full" = [ "client-feature-gates" "crds" "certs" "test-support" "time" "webhook" "kube-ws" "kube-cel" ]; + "full" = [ "client-feature-gates" "crds" "certs" "test-support" "time" "webhook" "kube-ws" "kube-cel" "kube-http-proxy" "kube-socks5" ]; "kube-cel" = [ "kube/cel" ]; + "kube-http-proxy" = [ "kube/http-proxy" ]; + "kube-socks5" = [ "kube/socks5" ]; "kube-ws" = [ "kube/ws" ]; "time" = [ "stackable-shared/time" ]; "webhook" = [ "dep:stackable-webhook" ]; @@ -10560,8 +10579,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; procMacro = true; libName = "stackable_operator_derive"; @@ -10595,8 +10614,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; libName = "stackable_shared"; authors = [ @@ -10676,8 +10695,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; libName = "stackable_telemetry"; authors = [ @@ -10786,8 +10805,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; libName = "stackable_versioned"; authors = [ @@ -10836,8 +10855,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; procMacro = true; libName = "stackable_versioned_macros"; @@ -10904,8 +10923,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "7b9f9ac9a76fa425ab27f2821377ef86571ca121"; - sha256 = "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9"; + rev = "bc6c84025c2dcc834b94bfb57ec72810ae5f5eb1"; + sha256 = "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci"; }; libName = "stackable_webhook"; authors = [ diff --git a/Cargo.toml b/Cargo.toml index d62c5b98..e53c6aed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" repository = "https://github.com/stackabletech/zookeeper-operator" [workspace.dependencies] -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.116.0", features = ["webhook"] } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.118.0", features = ["webhook"] } anyhow = "1.0" built = { version = "0.8", features = ["chrono", "git2"] } diff --git a/crate-hashes.json b/crate-hashes.json index 3fae0f9f..8357dcf2 100644 --- a/crate-hashes.json +++ b/crate-hashes.json @@ -1,11 +1,11 @@ { - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#k8s-version@0.1.3": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#stackable-certs@0.4.1": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#stackable-operator-derive@0.3.1": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#stackable-operator@0.116.0": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#stackable-shared@0.1.2": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#stackable-telemetry@0.6.5": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#stackable-versioned-macros@0.11.1": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#stackable-versioned@0.11.1": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.116.0#stackable-webhook@0.9.2": "1p3744fxgvs12sqwvi8hhainwrgvhdfwmbyqf0sp0aq3awq3q1v9" + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#k8s-version@0.1.3": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#stackable-certs@0.4.1": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#stackable-operator-derive@0.3.1": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#stackable-operator@0.118.0": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#stackable-shared@0.1.2": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#stackable-telemetry@0.6.5": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#stackable-versioned-macros@0.11.1": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#stackable-versioned@0.11.1": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.118.0#stackable-webhook@0.9.2": "0cgziqra8097hp05ynib1qpw4c95n972f4w2rk9l3llyp8r1vmci" } \ No newline at end of file diff --git a/extra/crds.yaml b/extra/crds.yaml index 65141ff5..1c76e1b9 100644 --- a/extra/crds.yaml +++ b/extra/crds.yaml @@ -160,12 +160,13 @@ spec: description: Version of the product, e.g. `1.4.1`. type: string pullPolicy: - default: Always description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the image.' enum: - IfNotPresent - Always - Never + - null + nullable: true type: string pullSecrets: description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry.' @@ -191,12 +192,47 @@ spec: type: string stackableVersion: description: |- - Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`. + Stackable version of the product, e.g. `26.7.0` or `0.0.0-dev`. - If not specified, the operator will use its own version, e.g. `23.4.1`. When using a nightly + If not specified, the operator will use its own version, e.g. `26.7.1`. When using a nightly operator or a PR version, it will use the nightly `0.0.0-dev` image. + + If this is used in combination with `stackableVersionPolicy: LatestPatch`, the correct + floating tag is computed automatically, e.g. `26.7.0` becomes `26.7` for the product image. nullable: true type: string + stackableVersionPolicy: + default: Exact + description: |- + Configure the Stackable version policy. Defaults to `Exact`. + + Currently, two variants are supported: + + - `Exact`, which uses the exact, fully-qualified, canonical version of a product image. + - `LatestPatch`, referencing a floating tag which always points to the latest patch version + in the current release line. The current release line is either automatically derived by + the operator based on its own version, or can be overridden with `stackableVersion`. + + A potential newer image is only pulled when Pods are rotated or their containers are + restarted. Pods are NOT rotated and containers are NOT restarted automatically when a new + image is available. This behaviour makes this a passive update mechanism, rather than an + active one. + + It should be noted that when this field is set to `LatestPatch`, the operator automatically + uses `Always` as the pull policy for product images. If set to `Exact`, `IfNotPresent` is + used. Explicitly setting `pullPolicy` takes precedence. + + ### Examples + + - The `stackableVersion` field is not set, the operator falls back to its own version, eg. + 26.7.0. If this field is set to `LatestPatch`, the `26.7` floating tag will be used for + product images, else, `26.7.0` will be used. + - The `stackableVersion` field is set to `26.3.0`. If this field is set to `LatestPatch`, + the `26.3` floating tag will be used for product images, else, `26.3.0` will be used. + enum: + - Exact + - LatestPatch + type: string type: object objectOverrides: default: [] diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index 165036fb..8c4f0f7e 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -50,7 +50,14 @@ mod zk_controller; mod znode_controller; mod built_info { + use std::{str::FromStr, sync::LazyLock}; + include!(concat!(env!("OUT_DIR"), "/built.rs")); + + pub static PKG_VERSION_SEMVER: LazyLock = LazyLock::new(|| { + semver::Version::from_str(PKG_VERSION) + .expect("PKG_VERSION must be able to be parsed as semver") + }); } #[derive(clap::Parser)] diff --git a/rust/operator-binary/src/zk_controller/validate.rs b/rust/operator-binary/src/zk_controller/validate.rs index aad9c318..3ffdf496 100644 --- a/rust/operator-binary/src/zk_controller/validate.rs +++ b/rust/operator-binary/src/zk_controller/validate.rs @@ -377,7 +377,7 @@ pub fn validate( .resolve( CONTAINER_IMAGE_BASE_NAME, &operator_environment.image_repository, - crate::built_info::PKG_VERSION, + &crate::built_info::PKG_VERSION_SEMVER, ) .context(ResolveProductImageSnafu)?; diff --git a/rust/operator-binary/src/znode_controller/validate.rs b/rust/operator-binary/src/znode_controller/validate.rs index 862f3c90..7abc7f7e 100644 --- a/rust/operator-binary/src/znode_controller/validate.rs +++ b/rust/operator-binary/src/znode_controller/validate.rs @@ -172,7 +172,7 @@ pub fn validate( .resolve( CONTAINER_IMAGE_BASE_NAME, &operator_environment.image_repository, - crate::built_info::PKG_VERSION, + &crate::built_info::PKG_VERSION_SEMVER, ) .context(ResolveProductImageSnafu)?;