Skip to content

Conversation

Donnerbart
Copy link
Contributor

Fixes #3006

…herTest for better type safety

Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
@Copilot Copilot AI review requested due to automatic review settings October 21, 2025 11:32
@openshift-ci openshift-ci bot requested review from metacosm and xstefank October 21, 2025 11:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the PodTemplateSpec sanitizer to handle GKE Autopilot environments, which automatically inject additional resource requirements like ephemeral-storage that may not be present in the desired state.

Key Changes:

  • Removed the resource map size equality check that prevented sanitization when actual and desired resources had different numbers of entries
  • Added test coverage for scenarios where additional resources (e.g., ephemeral-storage) are injected by external operators like GKE Autopilot
  • Updated test type parameters for better type safety

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
PodTemplateSpecSanitizer.java Removed size mismatch filter to allow sanitization when actual resources contain additional entries injected by the platform
PodTemplateSpecSanitizerTest.java Removed obsolete size mismatch test and added new tests covering GKE Autopilot scenarios with ephemeral-storage injection
SSABasedGenericKubernetesResourceMatcherTest.java Improved type safety by adding explicit generic type parameters to test classes and builders

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

private static class ConfigMapDR extends KubernetesDependentResource<ConfigMap, ConfigMap> {
private static class ConfigMapDR extends KubernetesDependentResource<ConfigMap, HasMetadata> {
Copy link
Collaborator

@csviri csviri Oct 21, 2025

Choose a reason for hiding this comment

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

nit: What is the reason for this change?

Copy link
Contributor Author

@Donnerbart Donnerbart Oct 21, 2025

Choose a reason for hiding this comment

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

To make the existing field mockedContext re-useable without any casts or warnings.

I've changed the context from Context<?> to Context<HasMetadata>, which works for all existing tests. And then aligned ConfigMapDR to use HasMetadata as primary resource as well.

The whole test class is now warning free in my IDEA.

Copy link
Collaborator

@csviri csviri left a comment

Choose a reason for hiding this comment

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

LGTM

thank you!!

@csviri csviri merged commit fa288d1 into operator-framework:main Oct 21, 2025
25 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.

Early return in PodTemplateSpecSanitizer causes constant resource mismatch due to enforced resource requests/limits in GKE Autopilot clusters

2 participants