-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix: Set manifest to deleting state; Raise errors on unexpected manager conditions #1833
fix: Set manifest to deleting state; Raise errors on unexpected manager conditions #1833
Conversation
@@ -360,6 +360,10 @@ func (r *Reconciler) syncResources(ctx context.Context, clnt Client, manifest *v | |||
} | |||
} | |||
|
|||
if !manifest.GetDeletionTimestamp().IsZero() { | |||
return r.setManifestState(manifest, shared.StateDeleting) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but inside this setManifestState
, we did same thing, set state to deleting when manifest has deletiontimestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but consider rename this setManifestState
, it's really misleading, if it's a set
method, I don't expect the input state
will be modified in the body of the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks! I removed modifying the state arg in setManifestState
. We need to check the deletion timestamp outside because we can't reliably determine the manager state if there is a deletion timestamp. And this way it is now also consistent. We first determine the state to transition to, then we call setManfiestState
with that state.
TBH, I am also a bit confused about the rest of the setManifestState
method. If I understand it right, we set Condition Installation
to True
and set Last Operator Message to installation is ready and resources can be used
whenever we transition between states other than Processing. So if we go from Reay to Warning, we will keep this condition and message. If we go from Ready to Error, we will keep this condition and message, If we go from Processing to Error, we will keep this condition and message.... Is this expected or do we need to straighten out a few things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the rest code is a bit bluring, I think we can improve it, but logically should fine I think.
When the reconcilation enter into setManifestState
, we don't have Error
state case, this should already requeued in previous steps.
So the rest state are Ready
, Processing
, Warning
, basically all of these state means installation should be finished.
if !meta.IsStatusConditionTrue(status.Conditions, installationCondition.Type) || status.State != state
this meaning:
- the actual manifest CR status in cluster (
status
), theInstallation
condition is false; basically this means the actual installation condition in cluster is false. - or actual manifest CR state (
status.State
) is different than the state to be updated (state
); this means we need to update the state,
in both case, we should update the installation condition to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I have created a follow-up to investigate this more thoroughly: #1846
Right now I don't know if I understand the setting of those conditions correctly. Let's discuss that.
But until then, we could merge this one as proposed if okay from your side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic prevents all follow steps, right? if Manifest CR is under deletion, it always requeue with set state to Deleting
I think you need to update if !manifest.GetDeletionTimestamp().IsZero() && manifest.status.state != "deleting"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I think it only requeus when we have a difference in state. First, we determine the "target" state which is "Deleting" if we have a deletion timestamp. With this we call the setManfiestState
function:
if !manifest.GetDeletionTimestamp().IsZero() {
return r.setManifestState(manifest, shared.StateDeleting)
}
And in the setManifestState
function, we only update the status and return the ErrInstallationConditionRequiresUpdate
error if it actually differs (if newState != status.State
). To my understanding, we use this error to determine if the requeue is required. If we return nil
, we don't requeue. I don't particularly like this, but I also think we should keep it for this chagne and then focus on improving with the created ticket.
func (r *Reconciler) setManifestState(manifest *v1beta2.Manifest, newState shared.State) error {
status := manifest.GetStatus()
if newState == shared.StateProcessing {
manifest.SetStatus(status.WithState(shared.StateProcessing).WithOperation(waitingForResourcesMsg))
return ErrInstallationConditionRequiresUpdate
}
installationCondition := newInstallationCondition(manifest)
if newState != status.State || !meta.IsStatusConditionTrue(status.Conditions, installationCondition.Type) {
installationCondition.Status = apimetav1.ConditionTrue
meta.SetStatusCondition(&status.Conditions, installationCondition)
manifest.SetStatus(status.WithState(newState).WithOperation(installationCondition.Message))
return ErrInstallationConditionRequiresUpdate
}
return nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls check the comment
Description
Changes proposed in this pull request:
Related issue(s)