Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal condition sets ResourceSynced=False #94

Merged
merged 1 commit into from
Jun 15, 2022

Conversation

jaypipes
Copy link
Collaborator

This patch updates the resourceReconciler.ensureConditions() method to
set the ACK.ResourceSynced Condition value to False when a Terminal
error has been returned from the resource manager. Previously, the
ACK.ResourceSynced Condition value was erroneously being set to True
due to a misunderstanding of what ACK.ResourceSynced means.

ACK.ResourceSynced is a Condition that informs the Kubernetes user
whether the desired state of a resource matches the latest observed
state of the resource
. In the case of a Terminal error, the desired
state of a resource will never match the latest observed state of the
resource because there is something invalid about the desired resource
state.

Further, this patch changes the default value for ACK.ResourceSynced
Condition to be Unknown instead of False for any non-Terminal
reconciler error. The reasoning behind this change is that for
non-Terminal errors, we simply do not know whether the desired resource
state matches the latest observed state or not.

Signed-off-by: Jay Pipes jaypipes@gmail.com

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

Copy link
Contributor

@RedbackThomson RedbackThomson left a comment

Choose a reason for hiding this comment

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

I just checked and I see that nowhere do we explicitly check Synced == false. We always check for Synced != true. Happy with these changes - just had a question about our messaging.

@@ -29,8 +29,9 @@ var (
NotManagedReason = "This resource already exists but is not managed by ACK. " +
"To bring the resource under ACK management, you should explicitly adopt " +
"the resource by creating a services.k8s.aws/AdoptedResource"
NotSyncedMessage = "Resource not synced"
SyncedMessage = "Resource synced successfully"
UnknownSyncedMessage = "Unable to determine if desired resource state matches latest observed state"
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of desired resource state do we want to just plainly say spec?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead of desired resource state do we want to just plainly say spec?

The issue with saying "spec" is that the spec can contain both the desired and latest state :) We compare full AWSResource objects to determine desired versus latest because some fields representing the latest state are set in the spec...

Copy link
Contributor

@vijtrip2 vijtrip2 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Nicely explained.
This may spur some test failures in various controller's e2e assertions that we will have to update upon the new release.

// desired state of a resource, the resource's desired state
// will never match the latest observed state. Thus,
// ACK.ResourceSynced must be False.
condStatus = corev1.ConditionFalse
condMessage = ackcondition.SyncedMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
condMessage = ackcondition.SyncedMessage
condMessage = ackcondition.NotSyncedMessage

This patch updates the `resourceReconciler.ensureConditions()` method to
set the `ACK.ResourceSynced` Condition value to `False` when a Terminal
error has been returned from the resource manager. Previously, the
`ACK.ResourceSynced` Condition value was erroneously being set to `True`
due to a misunderstanding of what `ACK.ResourceSynced` means.

`ACK.ResourceSynced` is a Condition that informs the Kubernetes user
*whether the desired state of a resource matches the latest observed
state of the resource*. In the case of a Terminal error, the desired
state of a resource will *never* match the latest observed state of the
resource because there is something invalid about the desired resource
state.

Further, this patch changes the default value for `ACK.ResourceSynced`
Condition to be `Unknown` instead of `False` for any non-Terminal
reconciler error. The reasoning behind this change is that for
non-Terminal errors, we simply do not know whether the desired resource
state matches the latest observed state or not.

Signed-off-by: Jay Pipes <jaypipes@gmail.com>
@vijtrip2
Copy link
Contributor

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 15, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Jun 15, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jaypipes, RedbackThomson, vijtrip2

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 [RedbackThomson,jaypipes,vijtrip2]

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

@ack-bot ack-bot merged commit 35dd8c1 into aws-controllers-k8s:main Jun 15, 2022
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
4 participants