Skip to content

RHINENG-27056: update cji db-migration job with name using image_tag and suffix#2246

Merged
TenSt merged 1 commit into
RedHatInsights:masterfrom
TenSt:stepan/RHINENG-27056-update-cji-with-proper-name-and-random-suffix
Jun 24, 2026
Merged

RHINENG-27056: update cji db-migration job with name using image_tag and suffix#2246
TenSt merged 1 commit into
RedHatInsights:masterfrom
TenSt:stepan/RHINENG-27056-update-cji-with-proper-name-and-random-suffix

Conversation

@TenSt

@TenSt TenSt commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

This PR:

  • updates the CJI db-migration with name using image_tag and random suffix because qontract-reconcile does not support generateName for any k8s object

Summary by Sourcery

Update the CJI db-migration job to use an explicit name incorporating the image tag and a generated unique suffix instead of relying on Kubernetes generateName, and add a new parameter to supply that suffix.

@TenSt TenSt requested a review from a team as a code owner June 24, 2026 12:12
@sourcery-ai

sourcery-ai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the CJI db-migration ClowdJobInvocation to use a deterministic name based on IMAGE_TAG plus a random suffix, and adds a new parameter to generate that suffix so the job no longer relies on Kubernetes generateName, which is unsupported by qontract-reconcile.

File-Level Changes

Change Details Files
Replace generateName-based db-migration CJI naming with an explicit name composed of IMAGE_TAG and a random suffix.
  • Change the db-migration ClowdJobInvocation metadata from using generateName to a concrete name template including IMAGE_TAG and a suffix variable.
  • Ensure the name incorporates IMAGE_TAG so different image deployments get distinct db-migration jobs.
  • Aligns naming with qontract-reconcile limitations by avoiding unsupported generateName usage.
deploy/clowdapp.yaml
Add a parameter to generate a random suffix for the db-migration CJI name.
  • Introduce a CJI_UID parameter for db-migration naming.
  • Configure the parameter to be auto-generated via an expression that yields a 6-character lowercase alphanumeric string.
  • Document the parameter as a unique suffix for the db-migration CJI name.
deploy/clowdapp.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Using name: db-migration-${IMAGE_TAG}-${CJI_UID} may produce invalid Kubernetes resource names if IMAGE_TAG contains characters like /, :, or uppercase; consider normalizing/sanitizing the tag (e.g., replacing non-DNS-1123 characters) before interpolating it into the name.
  • It might be safer to bound the total length of db-migration-${IMAGE_TAG}-${CJI_UID} (e.g., by truncating the tag portion) to avoid exceeding Kubernetes’ 63-character name limit in cases where IMAGE_TAG is long.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using `name: db-migration-${IMAGE_TAG}-${CJI_UID}` may produce invalid Kubernetes resource names if `IMAGE_TAG` contains characters like `/`, `:`, or uppercase; consider normalizing/sanitizing the tag (e.g., replacing non-DNS-1123 characters) before interpolating it into the name.
- It might be safer to bound the total length of `db-migration-${IMAGE_TAG}-${CJI_UID}` (e.g., by truncating the tag portion) to avoid exceeding Kubernetes’ 63-character name limit in cases where `IMAGE_TAG` is long.

## Individual Comments

### Comment 1
<location path="deploy/clowdapp.yaml" line_range="572" />
<code_context>
     labels:
       app: patchman
-    generateName: db-migration-
+    name: db-migration-${IMAGE_TAG}-${CJI_UID}
   spec:
     appName: patchman
</code_context>
<issue_to_address>
**issue (bug_risk):** Including IMAGE_TAG in the resource name risks invalid characters or excessive length for Kubernetes object names.

Kubernetes names must be DNS-1123 compliant and ≤253 chars, but IMAGE_TAG values often contain `:`/`/` (e.g. `quay.io/...:1.2.3`), which would make this name invalid and long tags could exceed the limit. Please either sanitize/slugify IMAGE_TAG before using it here (e.g. drop the repo part and replace invalid chars) or derive a shorter, valid identifier (e.g. a hash).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread deploy/clowdapp.yaml
labels:
app: patchman
generateName: db-migration-
name: db-migration-${IMAGE_TAG}-${CJI_UID}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Including IMAGE_TAG in the resource name risks invalid characters or excessive length for Kubernetes object names.

Kubernetes names must be DNS-1123 compliant and ≤253 chars, but IMAGE_TAG values often contain :// (e.g. quay.io/...:1.2.3), which would make this name invalid and long tags could exceed the limit. Please either sanitize/slugify IMAGE_TAG before using it here (e.g. drop the repo part and replace invalid chars) or derive a shorter, valid identifier (e.g. a hash).

@swadeley swadeley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK

@swadeley swadeley self-assigned this Jun 24, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.06%. Comparing base (8a7b8c3) to head (1d62b5c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2246   +/-   ##
=======================================
  Coverage   59.06%   59.06%           
=======================================
  Files         138      138           
  Lines        8848     8848           
=======================================
  Hits         5226     5226           
  Misses       3076     3076           
  Partials      546      546           
Flag Coverage Δ
unittests 59.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TenSt TenSt enabled auto-merge (squash) June 24, 2026 12:34
@TenSt TenSt merged commit c64b6f3 into RedHatInsights:master Jun 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants