Skip to content

Commit 1442897

Browse files
committed
feat: Support floating tag in product image selection
1 parent 9f4d9d6 commit 1442897

7 files changed

Lines changed: 107 additions & 41 deletions

File tree

Cargo.lock

Lines changed: 16 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 33 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2024"
1010
repository = "https://github.com/stackabletech/druid-operator"
1111

1212
[workspace.dependencies]
13-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.116.0", features = ["crds", "webhook"] }
13+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.118.0", features = ["crds", "webhook"] }
1414

1515
anyhow = "1.0"
1616
built = { version = "0.8", features = ["chrono", "git2"] }

crate-hashes.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extra/crds.yaml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3715,12 +3715,13 @@ spec:
37153715
description: Version of the product, e.g. `1.4.1`.
37163716
type: string
37173717
pullPolicy:
3718-
default: Always
37193718
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the image.'
37203719
enum:
37213720
- IfNotPresent
37223721
- Always
37233722
- Never
3723+
- null
3724+
nullable: true
37243725
type: string
37253726
pullSecrets:
37263727
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry.'
@@ -3746,12 +3747,47 @@ spec:
37463747
type: string
37473748
stackableVersion:
37483749
description: |-
3749-
Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`.
3750+
Stackable version of the product, e.g. `26.7.0` or `0.0.0-dev`.
37503751
3751-
If not specified, the operator will use its own version, e.g. `23.4.1`. When using a nightly
3752+
If not specified, the operator will use its own version, e.g. `26.7.1`. When using a nightly
37523753
operator or a PR version, it will use the nightly `0.0.0-dev` image.
3754+
3755+
If this is used in combination with `stackableVersionPolicy: LatestPatch`, the correct
3756+
floating tag is computed automatically, e.g. `26.7.0` becomes `26.7` for the product image.
37533757
nullable: true
37543758
type: string
3759+
stackableVersionPolicy:
3760+
default: Exact
3761+
description: |-
3762+
Configure the Stackable version policy. Defaults to `Exact`.
3763+
3764+
Currently, two variants are supported:
3765+
3766+
- `Exact`, which uses the exact, fully-qualified, canonical version of a product image.
3767+
- `LatestPatch`, referencing a floating tag which always points to the latest patch version
3768+
in the current release line. The current release line is either automatically derived by
3769+
the operator based on its own version, or can be overridden with `stackableVersion`.
3770+
3771+
A potential newer image is only pulled when Pods are rotated or their containers are
3772+
restarted. Pods are NOT rotated and containers are NOT restarted automatically when a new
3773+
image is available. This behaviour makes this a passive update mechanism, rather than an
3774+
active one.
3775+
3776+
It should be noted that when this field is set to `LatestPatch`, the operator automatically
3777+
uses `Always` as the pull policy for product images. If set to `Exact`, `IfNotPresent` is
3778+
used. Explicitly setting `pullPolicy` takes precedence.
3779+
3780+
### Examples
3781+
3782+
- The `stackableVersion` field is not set, the operator falls back to its own version, eg.
3783+
26.7.0. If this field is set to `LatestPatch`, the `26.7` floating tag will be used for
3784+
product images, else, `26.7.0` will be used.
3785+
- The `stackableVersion` field is set to `26.3.0`. If this field is set to `LatestPatch`,
3786+
the `26.3` floating tag will be used for product images, else, `26.3.0` will be used.
3787+
enum:
3788+
- Exact
3789+
- LatestPatch
3790+
type: string
37553791
type: object
37563792
middleManagers:
37573793
description: |-

rust/operator-binary/src/controller/validate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub fn validate(
285285
.resolve(
286286
super::CONTAINER_IMAGE_BASE_NAME,
287287
&operator_environment.image_repository,
288-
crate::built_info::PKG_VERSION,
288+
&crate::built_info::PKG_VERSION_SEMVER,
289289
)
290290
.context(ResolveProductImageSnafu)?;
291291

@@ -471,7 +471,7 @@ spec:
471471
.resolve(
472472
CONTAINER_IMAGE_BASE_NAME,
473473
"oci.example.org",
474-
crate::built_info::PKG_VERSION,
474+
&crate::built_info::PKG_VERSION_SEMVER,
475475
)
476476
.expect("test: resolvable product image");
477477

rust/operator-binary/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ mod internal_secret;
4747
mod webhooks;
4848

4949
mod built_info {
50+
use std::{str::FromStr, sync::LazyLock};
51+
5052
include!(concat!(env!("OUT_DIR"), "/built.rs"));
53+
54+
pub static PKG_VERSION_SEMVER: LazyLock<semver::Version> = LazyLock::new(|| {
55+
semver::Version::from_str(PKG_VERSION)
56+
.expect("PKG_VERSION must be able to be parsed as semver")
57+
});
5158
}
5259

5360
#[derive(Parser)]

0 commit comments

Comments
 (0)