Skip to content

fix: Update K8s Spec for read-only resources when AWS state diverges#250

Open
Mallikarjunadevops wants to merge 2 commits into
aws-controllers-k8s:mainfrom
Mallikarjunadevops:fix-readonly-spec-sync
Open

fix: Update K8s Spec for read-only resources when AWS state diverges#250
Mallikarjunadevops wants to merge 2 commits into
aws-controllers-k8s:mainfrom
Mallikarjunadevops:fix-readonly-spec-sync

Conversation

@Mallikarjunadevops

Copy link
Copy Markdown

Fixes aws-controllers-k8s/community#2856

What is this PR?

This PR fixes a bug where adopted resources with read-only mode enabled do not update their K8s Spec when the underlying AWS resource changes (e.g., an EKS cluster upgrade from 1.33 to 1.34).

Why?

When a resource is read-only, the aws-controllers-k8s/runtime reads the latest state from AWS, compares it to the desired state in K8s, and detects differences. However, previously the reconciler would log "desired resource state has changed, but resource is read-only - skipping update" and return the resource WITHOUT patching the K8s API. This caused the K8s resource to become perpetually stale.

With this PR, when the runtime detects a difference in Spec for a read-only resource, it will now correctly patch the K8s API with the latest state fetched from AWS.

Testing Evidence

Ran existing unit test suite in pkg/runtime/... via go test which successfully passed. Verified the changes apply exactly as intended for read-only sync logic.

@ack-prow ack-prow Bot requested review from a-hilaly and michaelhtm June 2, 2026 02:20
@ack-prow ack-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 2, 2026
@ack-prow

ack-prow Bot commented Jun 2, 2026

Copy link
Copy Markdown

Hi @Mallikarjunadevops. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@michaelhtm

Copy link
Copy Markdown
Member

Hey @Mallikarjunadevops
Skipping patching metadata.Spec when the resource is read-only was done by design. We can maybe try using a new annotation, or an annotation value read-only: always, that can patch the metadata.Spec
This may require a design PR exploring different options

Signed-off-by: Mallikarjunadevops <mallikarjunadevops@example.com>
@ack-prow

ack-prow Bot commented Jun 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Mallikarjunadevops
Once this PR has been reviewed and has the lgtm label, please ask for approval from michaelhtm. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@Mallikarjunadevops

Copy link
Copy Markdown
Author

@michaelhtm Thanks for the review and the insight! That makes total sense.

I have updated the PR to follow your suggestion: instead of always syncing the spec for read-only resources, I updated the logic so it strictly preserves the default read-only: true behavior (skips patching). It now specifically checks if the annotation value is read-only: always before proceeding to patch the K8s Spec and Metadata.

Testing Evidence:

  • I have run the existing unit test suite via go test ./pkg/runtime/... locally and all tests continue to pass cleanly with this modified logic.

Please let me know if this implementation looks good or if you'd still prefer a separate design PR to explore other options!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[eks controller] adopted resources with read only does not update the cluster version

2 participants