Skip to content

updating ImageRebuildTriggerGeneration in module status#1756

Merged
openshift-merge-bot[bot] merged 1 commit intorh-ecosystem-edge:mainfrom
TomerNewman:cherrypick/fix-imageretrigger-modul-status
Mar 5, 2026
Merged

updating ImageRebuildTriggerGeneration in module status#1756
openshift-merge-bot[bot] merged 1 commit intorh-ecosystem-edge:mainfrom
TomerNewman:cherrypick/fix-imageretrigger-modul-status

Conversation

@TomerNewman
Copy link
Member

@TomerNewman TomerNewman commented Feb 26, 2026

ImageRebuildTriggerGeneration field that was introduced in #1725 commit was never updated in the Module's status, even when MIC already finished to re-build the image and ImageRebuildTriggerGeneration field was updated in the MIC's status.

This commit fixes it by updating ImageRebuildTriggerGeneration in the Module's status at the end of the Module's reconciliation.


/cc @yevgeny-shnaidman @ybettan


fixes #1755

Summary by CodeRabbit

  • Bug Fixes

    • Improved module status synchronization by retrieving and propagating image rebuild trigger information from related configuration objects.
  • Tests

    • Enhanced test coverage for module status update workflows, including error handling scenarios.

ImageRebuildTriggerGeneration field that was intorduced in
e6e0871 commit
was never updated in the Module's status, even when MIC already finished to re-build the
image and ImageRebuildTriggerGeneration field was updated in the MIC's status.
This commit fixes it by updating ImageRebuildTriggerGeneration in the Module's status
at the end of the Module's reconciliation.
@netlify
Copy link

netlify bot commented Feb 26, 2026

Deploy Preview for openshift-kmm ready!

Name Link
🔨 Latest commit 43ef5d2
🔍 Latest deploy log https://app.netlify.com/projects/openshift-kmm/deploys/69a065f107281200085c098b
😎 Deploy Preview https://deploy-preview-1756--openshift-kmm.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci
Copy link

openshift-ci bot commented Feb 26, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TomerNewman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Walkthrough

The PR adds logic to propagate the ImageRebuildTriggerGeneration field from ModuleImagesConfig status to Module status during the moduleUpdateWorkerPodsStatus reconciliation path. The implementation includes MIC fetching with graceful error handling and corresponding test coverage.

Changes

Cohort / File(s) Summary
Module Reconciler Implementation
internal/controllers/module_reconciler.go
Adds MIC object fetching in moduleUpdateWorkerPodsStatus to retrieve and propagate micObj.Status.ImageRebuildTriggerGeneration into mod.Status.ImageRebuildTriggerGeneration. Includes error logging for failed MIC retrieval.
Module Reconciler Tests
internal/controllers/module_reconciler_test.go
Introduces mock MIC API (mockMicAPI) for test suite, updates test setup with MIC integration, adds MIC Get expectations across test flows, and includes new test cases to verify ImageRebuildTriggerGeneration propagation on success and error handling on MIC retrieval failure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

approved, lgtm

Suggested reviewers

  • yevgeny-shnaidman
  • ybettan
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: updating the ImageRebuildTriggerGeneration field in module status.
Linked Issues check ✅ Passed The PR successfully implements the manual cherry-pick of commit bc864b8d addressing issue #1755 by updating ImageRebuildTriggerGeneration propagation from MIC to Module status.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of propagating ImageRebuildTriggerGeneration from MIC to Module status with corresponding test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/controllers/module_reconciler_test.go (1)

1208-1234: Split MIC error-path tests by error type (NotFound vs transient).

At Line [1208], the test currently codifies “all MIC get errors are non-fatal.” It’s safer to assert separate behavior:

  • NotFound: non-fatal + clear/keep explicit nil semantics.
  • Transient API error: reconciliation should fail and retry.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controllers/module_reconciler_test.go` around lines 1208 - 1234,
Split the single MIC-error test into two tests: one that simulates a NotFound
error and one that simulates a transient API error. For the NotFound case, have
mockMicAPI.EXPECT().Get(...) return apierrors.NewNotFound(...), call
moduleUpdateWorkerPodsStatus(ctx, &mod, targetedNodes) and assert no error and
the same nil/unchanged Status semantics (e.g., ImageRebuildTriggerGeneration
remains nil) as currently done; for the transient case, have
mockMicAPI.EXPECT().Get(...) return a regular fmt.Errorf("transient") (or
similar), call moduleUpdateWorkerPodsStatus and assert it returns an error
(reconciliation should fail/retry). Ensure gomock.InOrder expectations around
clnt.List, helper.GetModuleSpecEntry, mockMicAPI.Get, clnt.Status().Patch(...)
are adjusted per test to match the expected flow and that the NotFound test
still expects the Patch call while the transient test expects no Patch and an
error return from moduleUpdateWorkerPodsStatus.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/controllers/module_reconciler.go`:
- Around line 550-555: The current branch ignores all errors from mrh.micAPI.Get
so mod.Status.ImageRebuildTriggerGeneration can stay stale; change the logic in
the reconcile where mrh.micAPI.Get is called so that: if Get returns a NotFound
(use the Kubernetes apierrors.IsNotFound check) clear/zero
mod.Status.ImageRebuildTriggerGeneration, if Get returns any other error return
that error so the reconcile will be retried, and only when Get succeeds copy
micObj.Status.ImageRebuildTriggerGeneration into
mod.Status.ImageRebuildTriggerGeneration; update any log messages (logger.Info)
to reflect the NotFound vs transient error handling.

---

Nitpick comments:
In `@internal/controllers/module_reconciler_test.go`:
- Around line 1208-1234: Split the single MIC-error test into two tests: one
that simulates a NotFound error and one that simulates a transient API error.
For the NotFound case, have mockMicAPI.EXPECT().Get(...) return
apierrors.NewNotFound(...), call moduleUpdateWorkerPodsStatus(ctx, &mod,
targetedNodes) and assert no error and the same nil/unchanged Status semantics
(e.g., ImageRebuildTriggerGeneration remains nil) as currently done; for the
transient case, have mockMicAPI.EXPECT().Get(...) return a regular
fmt.Errorf("transient") (or similar), call moduleUpdateWorkerPodsStatus and
assert it returns an error (reconciliation should fail/retry). Ensure
gomock.InOrder expectations around clnt.List, helper.GetModuleSpecEntry,
mockMicAPI.Get, clnt.Status().Patch(...) are adjusted per test to match the
expected flow and that the NotFound test still expects the Patch call while the
transient test expects no Patch and an error return from
moduleUpdateWorkerPodsStatus.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5efc539 and 43ef5d2.

📒 Files selected for processing (2)
  • internal/controllers/module_reconciler.go
  • internal/controllers/module_reconciler_test.go

Comment on lines +550 to +555
micObj, err := mrh.micAPI.Get(ctx, mod.Name, mod.Namespace)
if err != nil {
logger.Info("Could not get MIC to update ImageRebuildTriggerGeneration status, skipping", "error", err)
} else {
mod.Status.ImageRebuildTriggerGeneration = micObj.Status.ImageRebuildTriggerGeneration
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Handle MIC read failures explicitly to avoid stale Module status.

At Line [551], all MIC Get errors are ignored, so mod.Status.ImageRebuildTriggerGeneration can remain stale and diverge from MIC indefinitely. Prefer: clear on NotFound, but return error for transient failures so reconcile retries.

Proposed fix
 import (
 	"context"
 	"errors"
 	"fmt"
 	"reflect"
 	"strings"
@@
 	v1 "k8s.io/api/core/v1"
+	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@
 	micObj, err := mrh.micAPI.Get(ctx, mod.Name, mod.Namespace)
 	if err != nil {
-		logger.Info("Could not get MIC to update ImageRebuildTriggerGeneration status, skipping", "error", err)
+		if apierrors.IsNotFound(err) {
+			mod.Status.ImageRebuildTriggerGeneration = nil
+		} else {
+			return fmt.Errorf("failed to get MIC %s/%s: %w", mod.Namespace, mod.Name, err)
+		}
 	} else {
 		mod.Status.ImageRebuildTriggerGeneration = micObj.Status.ImageRebuildTriggerGeneration
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
micObj, err := mrh.micAPI.Get(ctx, mod.Name, mod.Namespace)
if err != nil {
logger.Info("Could not get MIC to update ImageRebuildTriggerGeneration status, skipping", "error", err)
} else {
mod.Status.ImageRebuildTriggerGeneration = micObj.Status.ImageRebuildTriggerGeneration
}
import (
"context"
"errors"
"fmt"
"reflect"
"strings"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
micObj, err := mrh.micAPI.Get(ctx, mod.Name, mod.Namespace)
if err != nil {
if apierrors.IsNotFound(err) {
mod.Status.ImageRebuildTriggerGeneration = nil
} else {
return fmt.Errorf("failed to get MIC %s/%s: %w", mod.Namespace, mod.Name, err)
}
} else {
mod.Status.ImageRebuildTriggerGeneration = micObj.Status.ImageRebuildTriggerGeneration
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controllers/module_reconciler.go` around lines 550 - 555, The
current branch ignores all errors from mrh.micAPI.Get so
mod.Status.ImageRebuildTriggerGeneration can stay stale; change the logic in the
reconcile where mrh.micAPI.Get is called so that: if Get returns a NotFound (use
the Kubernetes apierrors.IsNotFound check) clear/zero
mod.Status.ImageRebuildTriggerGeneration, if Get returns any other error return
that error so the reconcile will be retried, and only when Get succeeds copy
micObj.Status.ImageRebuildTriggerGeneration into
mod.Status.ImageRebuildTriggerGeneration; update any log messages (logger.Info)
to reflect the NotFound vs transient error handling.

@TomerNewman
Copy link
Member Author

/retest

7 similar comments
@TomerNewman
Copy link
Member Author

/retest

@TomerNewman
Copy link
Member Author

/retest

@TomerNewman
Copy link
Member Author

/retest

@TomerNewman
Copy link
Member Author

/retest

@TomerNewman
Copy link
Member Author

/retest

@TomerNewman
Copy link
Member Author

/retest

@TomerNewman
Copy link
Member Author

/retest

@TomerNewman
Copy link
Member Author

/test ci/prow/e2e

@TomerNewman
Copy link
Member Author

/test e2e

@TomerNewman
Copy link
Member Author

/retest

2 similar comments
@TomerNewman
Copy link
Member Author

/retest

@TomerNewman
Copy link
Member Author

/retest

Comment on lines +550 to +555
micObj, err := mrh.micAPI.Get(ctx, mod.Name, mod.Namespace)
if err != nil {
logger.Info("Could not get MIC to update ImageRebuildTriggerGeneration status, skipping", "error", err)
} else {
mod.Status.ImageRebuildTriggerGeneration = micObj.Status.ImageRebuildTriggerGeneration
}
Copy link
Member

Choose a reason for hiding this comment

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

Why are we doing it inside of moduleUpdateWorkerPodsStatus? This is not related to the worker pods.

I would create a new helper method called moduleUpdatePullerPodsStatus or something similar.

I know this is what we did u/s and I am OK merging this PR as is but I think we should fix it u/s and then pull this change m/s as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, I think also we should rename this function since its not updating worker pod status, maybe something like updateModuleLoaderStatus.

@TomerNewman
Copy link
Member Author

/retest

@yevgeny-shnaidman
Copy link
Member

/override ci/prow/e2e-hub

@openshift-ci
Copy link

openshift-ci bot commented Mar 5, 2026

@yevgeny-shnaidman: Overrode contexts on behalf of yevgeny-shnaidman: ci/prow/e2e-hub

Details

In response to this:

/override ci/prow/e2e-hub

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@yevgeny-shnaidman
Copy link
Member

/override ci/prow/operator-upgrade

@openshift-ci
Copy link

openshift-ci bot commented Mar 5, 2026

@yevgeny-shnaidman: Overrode contexts on behalf of yevgeny-shnaidman: ci/prow/operator-upgrade

Details

In response to this:

/override ci/prow/operator-upgrade

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@yevgeny-shnaidman
Copy link
Member

/override ci/prow/operator-hub-upgrade

@openshift-ci
Copy link

openshift-ci bot commented Mar 5, 2026

@yevgeny-shnaidman: Overrode contexts on behalf of yevgeny-shnaidman: ci/prow/operator-hub-upgrade

Details

In response to this:

/override ci/prow/operator-hub-upgrade

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@yevgeny-shnaidman
Copy link
Member

/override ci/prow/e2e

@openshift-ci
Copy link

openshift-ci bot commented Mar 5, 2026

@yevgeny-shnaidman: Overrode contexts on behalf of yevgeny-shnaidman: ci/prow/e2e

Details

In response to this:

/override ci/prow/e2e

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@yevgeny-shnaidman
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Mar 5, 2026
@openshift-merge-bot openshift-merge-bot bot merged commit d11e4f4 into rh-ecosystem-edge:main Mar 5, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cherry-picking error for bc864b8d1c2f16781d780cc4db19e6fbfaf32cd6

3 participants