Skip to content

ROX-33178: GetImagesForDeployment should pass imageIdV2s to imageV2DataStore#19169

Open
charmik-redhat wants to merge 3 commits intomasterfrom
ROX-33178/fix-dry-run-policies-not-working-for-image-related-criteria
Open

ROX-33178: GetImagesForDeployment should pass imageIdV2s to imageV2DataStore#19169
charmik-redhat wants to merge 3 commits intomasterfrom
ROX-33178/fix-dry-run-policies-not-working-for-image-related-criteria

Conversation

@charmik-redhat
Copy link
Contributor

@charmik-redhat charmik-redhat commented Feb 25, 2026

Description

GetImagesForDeployment function passed image SHAs as IDs to imageV2DataStore. This would result in no images being found for the deployment. Instead, the function should pass ImageV2IDs to the datastore. This function is also used in DryRun of policies. Because of this, the dry run endpoint did not return any violations for image related criteria.

Additionally, updated fixtures/deployment.go to set ImageName.FullName when generating test image, which resulted in having to update expected ImageName in other tests that used the fixture too. This is needed because the ImgeV2 ID generation requires non-empty image name and sha. In reality too, the imageName is only initialized in two places except for the test files:

  • pkg/images/utils/utils.go : GenerateImageFromString (and similar functions) always set the FullName to a non-empty value. So it is never empty.
  • sensor/kubernetes/eventpipeline/pipeline_impl.go : processInvalidateImageCache is only used to invalidate images from sensor cache. Even for that, the fullName is always set to a non-empty value when central with FlattenImageData capability sends InvalidateImageCache message with.

All that to say that FullName being empty does not seem like a bug for ImageV2 generation because it is always set to a non-empty value when an image object is initialized.

Note that central/clusters/deployer.go also generates ImageNames and here fullName can be empty but those ImageNames are used only to fill Helm chart values for secured-cluster installs and are never stored in the database or scanned/enriched by Central.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • Updated unit test
  • Manual test
40ECAE6B-72F8-4A2B-98FE-80A276BBAED0 AF84C18A-12AF-40A1-A1CC-A9E1DF4C988F

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Feb 25, 2026

Images are ready for the commit at 9c116c7.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-157-g9c116c7c76.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The runGetImagesForDeploymentTest helper now branches on features.FlattenImageData, which makes the test behavior depend on global feature configuration; consider structuring this as an explicit table-driven test that exercises both code paths deterministically instead of relying on the runtime feature flag state.
  • In GetImagesForDeployment, the feature-flag-specific logic for collecting image IDs is now nested and somewhat repetitive; consider extracting the ID selection into a small helper or using a single loop that switches the field based on the flag to keep this function easier to read and maintain.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `runGetImagesForDeploymentTest` helper now branches on `features.FlattenImageData`, which makes the test behavior depend on global feature configuration; consider structuring this as an explicit table-driven test that exercises both code paths deterministically instead of relying on the runtime feature flag state.
- In `GetImagesForDeployment`, the feature-flag-specific logic for collecting image IDs is now nested and somewhat repetitive; consider extracting the ID selection into a small helper or using a single loop that switches the field based on the flag to keep this function easier to read and maintain.

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.

@openshift-ci
Copy link

openshift-ci bot commented Feb 26, 2026

@charmik-redhat: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocp-4-12-qa-e2e-tests cf46beb link false /test ocp-4-12-qa-e2e-tests
ci/prow/ocp-4-20-operator-e2e-tests 8e3c73e link false /test ocp-4-20-operator-e2e-tests
ci/prow/ocp-4-20-qa-e2e-tests 9c116c7 link false /test ocp-4-20-qa-e2e-tests
ci/prow/gke-scanner-v4-install-tests 9c116c7 link false /test gke-scanner-v4-install-tests

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@charmik-redhat charmik-redhat requested a review from a team February 26, 2026 08:34
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.

2 participants