Skip to content

Fix: Invalid app version label when using hash in custom image #1076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 13, 2025

Conversation

maltesander
Copy link
Member

@maltesander maltesander commented Aug 11, 2025

Description

When using custom images like:

---
apiVersion: spark.stackable.tech/v1alpha1
kind: SparkApplication
metadata:
  name: spark-ny-cm
spec:
  sparkImage:
    productVersion: 3.5.6
    custom: oci.stackable.tech/sdp/spark-k8s:3.5.6-stackable25.7.0@sha256:c8b77ba72de6f8ddb99cb484b5ee79c43623cc2514d1448243f7d65d0ef66212
    #custom: oci.stackable.tech/sdp/spark-k8s@sha256:c8b77ba72de6f8ddb99cb484b5ee79c43623cc2514d1448243f7d65d0ef66212

the operator errors out due to creating invalid labels:

2025-08-07T10:52:54.347504Z ERROR app_controller: stackable_operator::logging::controller: Failed to reconcile object controller.name="sparkapplication.spark.stackable.tech" error=reconciler for object SparkApplication.v1alpha1.spark.stackable.tech/spark-ny-cm.default failed error.sources=[failed to build Metadata, failed to set recommended labels, failed to parse value "3.5.2-sha256:15725cf7ee1d648dd81e3bcbf8bcfff8e34d922182d5101abc" of key "app.kubernetes.io/version", value violates kubernetes format]

This is a quick and dirty fix replacing all ":" in the hash_or_tag_image used for creating the label with "-" and parsing it as LabelValue.

This is breaking as the "resolve" method now returns an error.

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added

@maltesander maltesander moved this to Development: Waiting for Review in Stackable Engineering Aug 11, 2025
sbernauer
sbernauer previously approved these changes Aug 12, 2025
Copy link
Member

@sbernauer sbernauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like us now using a typed value :)
Only some nits

@sbernauer sbernauer moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Aug 12, 2025
Co-authored-by: Sebastian Bernauer <[email protected]>
Copy link
Member

@Techassi Techassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking for now, I will come back to this later today.

sbernauer
sbernauer previously approved these changes Aug 12, 2025
Copy link
Member

@sbernauer sbernauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the bug!

@maltesander maltesander requested a review from Techassi August 12, 2025 11:57
Copy link
Member

@Techassi Techassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last nit-pick, then ready to go.

@maltesander maltesander requested a review from Techassi August 12, 2025 13:44
@maltesander maltesander enabled auto-merge August 12, 2025 14:09
@maltesander maltesander added this pull request to the merge queue Aug 13, 2025
@maltesander maltesander moved this from Development: In Review to Development: Done in Stackable Engineering Aug 13, 2025
@maltesander
Copy link
Member Author

Release note:

Previously, when using custom images in combination with a SHA/Digest like e.g. `oci.stackable.tech/sdp/spark-k8s@sha256:c8b77ba72de6f8ddb99cb484b5ee79c43623cc2514d1448243f7d65d0ef66212`, all operators created invalid labels `app.kubernetes.io/version` for their applied resources. This was fixed by checking and replacing invalid characters in the created labels when a SHA/Digest is involved in the custom image. 

Merged via the queue into main with commit 113c4ee Aug 13, 2025
8 checks passed
@maltesander maltesander deleted the fix/custom-image-hash2 branch August 13, 2025 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Development: Done
Development

Successfully merging this pull request may close these issues.

3 participants