Skip to content

Conversation

@michaelhtm
Copy link
Member

@michaelhtm michaelhtm commented Nov 25, 2025

Issue #2682

Changes Made

reconciler.go:

  • Improved error handling: Initialize latest with desired.DeepCopy() to ensure consistent resource state is returned on errors
  • Fixed return values: Use named return parameters and return appropriate resource state in all error paths
  • Enhanced late initialization: Separate late initialization result handling to prevent state loss
  • Cleaner variable management: Removed redundant variable declarations

util.go:

  • Fixed adoption fields extraction: Return proper error when annotation is missing instead of empty string
  • Simplified field lookup: Use direct map access instead of iteration for better performance
  • Corrected JSON unmarshaling: Fix pointer usage in unmarshaling operation

reconciler_test.go:

  • Updated test mocks: Align mock expectations with new resource state handling
  • Fixed condition assertions: Correct expected condition states for error scenarios
  • Enhanced error path testing: Better validation of resource states during error conditions

Impact

  • Ensures consistent resource state is always returned from reconciler operations
  • Improves error handling reliability and debugging capabilities
  • Fixes potential nil pointer issues in error scenarios
  • Better test coverage alignment with actual implementation behavior

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from jlbutler and rushmash91 November 25, 2025 07:41
@ack-prow ack-prow bot added the approved label Nov 25, 2025
@michaelhtm michaelhtm changed the title ensure status is patched on adoption Fix resource state handling and error propagation in reconciler Nov 25, 2025
@a-hilaly
Copy link
Member

/retest

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thanks michael. Can we have an e2e tests for this either for ecr, s3 or both?

/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Nov 25, 2025
@michaelhtm michaelhtm force-pushed the fix/ensurestatusispatched branch from e2052ec to 1e070dd Compare November 25, 2025 11:07
@ack-prow ack-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 25, 2025
@michaelhtm michaelhtm force-pushed the fix/ensurestatusispatched branch 2 times, most recently from a9b9940 to 3e3bdc9 Compare November 26, 2025 00:23
@knottnt
Copy link

knottnt commented Nov 26, 2025

/retest

@michaelhtm
Copy link
Member Author

Tests will not pass for some controllers since they were not merged with the latest code-generator version, where we match the interface changes

adoptionPolicy, err := GetAdoptionPolicy(desired)
if err != nil {
return nil, err
return latest, err
Copy link

Choose a reason for hiding this comment

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

Q: What's the impact of return a copy of desired vs nil here?

Copy link
Member Author

Choose a reason for hiding this comment

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

latest is a deepCopy of desired.

Copy link

Choose a reason for hiding this comment

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

I've got that part. I'm wondering what the difference in behavior that returning latest instead of nil is expected to have. Is to ensure that HandleReconcilerErrors doesn't skip patching the resource due to the ackcompare.IsNotNil check?

Copy link
Member Author

Choose a reason for hiding this comment

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

that's correct

@michaelhtm michaelhtm force-pushed the fix/ensurestatusispatched branch from 3e3bdc9 to 13caeb5 Compare November 26, 2025 23:55
Copy link

@knottnt knottnt left a comment

Choose a reason for hiding this comment

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

Thanks @michaelhtm

@knottnt
Copy link

knottnt commented Nov 26, 2025

/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Nov 26, 2025
@ack-prow
Copy link

ack-prow bot commented Nov 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, knottnt, michaelhtm

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [a-hilaly,knottnt,michaelhtm]

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

@ack-prow
Copy link

ack-prow bot commented Nov 27, 2025

@michaelhtm: 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
verify-attribution 13caeb5 link false /test verify-attribution
sagemaker-controller-test 13caeb5 link true /test sagemaker-controller-test
sqs-controller-test 13caeb5 link true /test sqs-controller-test
ec2-controller-test 13caeb5 link true /test ec2-controller-test

Full PR test history. Your PR dashboard.

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

@michaelhtm michaelhtm merged commit 79724c6 into aws-controllers-k8s:main Nov 27, 2025
4 of 9 checks passed
michaelhtm added a commit to michaelhtm/ack-runtime that referenced this pull request Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants