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

fix: (helm) - in some rare helm install cases, status is missing InstallSuccessful #3735

Merged
merged 4 commits into from
Aug 14, 2020
Merged

Conversation

mikeshng
Copy link
Contributor

Signed-off-by: Mike Ng [email protected]

Description of the change:
In some rare cases, the InstallSuccessful reason is not stamped to the helm operator based CR after a successful helm install.
This fix is to make sure that it will keep trying to put the InstallSuccessful into the status.

Motivation for the change:
Closes #3728

Checklist

If the pull request includes user-facing changes, extra documentation is required:

Comment on lines 231 to 236
status.SetCondition(types.HelmAppCondition{
Type: types.ConditionDeployed,
Status: types.StatusTrue,
Reason: types.ReasonInstallSuccessful,
Message: manager.ReleaseMessage(),
})
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this to line ~334? We should just always set the condition.

At that point, we can also look at expectedRelease, so I don't think we need the extra manager functions.

Lastly, we should look at the release version to know whether to set ReasonInstallSuccessful or ReasonUpgradeSuccessful.

WDYT? Will the problem be still be solved if those tweaks are made?

@joelanford
Copy link
Member

Also, I think this would be a bug fix that should have a changelog fragment. Would you mind adding that as well?

@@ -0,0 +1,4 @@
entries:
- description: Fixed a bug that caused the Helm operator not to set the `InstallSuccessful` status.
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
- description: Fixed a bug that caused the Helm operator not to set the `InstallSuccessful` status.
- description: Ensures that the `InstallSuccessful` status will be set always by checking if the release info.

Copy link
Contributor

Choose a reason for hiding this comment

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

IHMO ^

Copy link
Member

Choose a reason for hiding this comment

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

I think @mikeshng's version reads more clearly with one tweak though.

Suggested change
- description: Fixed a bug that caused the Helm operator not to set the `InstallSuccessful` status.
- description: Fixed a bug that caused the Helm operator not to set the `InstallSuccessful` and `UpgradeSuccessful` status reasons when the status update fails during installation and upgrade.

Comment on lines +319 to +322
reason := types.ReasonUpgradeSuccessful
if expectedRelease.Version == 1 {
reason = types.ReasonInstallSuccessful
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Now it makes more sense for me 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I ran the helm ls command it showed:

NAME        	NAMESPACE	REVISION	UPDATED                                	STATUS  	CHART      	APP VERSION
nginx-sample	default  	1       	2020-08-13 14:09:57.443165995 -0400 EDT	deployed	nginx-0.1.0	1.16.0  

So I thought Version is APP VERSION which means its not going to be 1 for fresh install case. Then I double checked and it seems like Version is infact the REVISION from the output above so I changed it back to what Joe suggested earlier.

Type: types.ConditionDeployed,
Status: types.StatusTrue,
Reason: reason,
Message: expectedRelease.Info.Notes,
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to check if the info is not nil. Such as :

message := ""
if installedRelease.Info != nil {
message = installedRelease.Info.Notes
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the good catch.

Comment on lines 132 to 143
// ContainsCondition checks if the condition with the passed condition type from
// the status object is already present. If present then return true.
// Otherwise, return false.
func (s *HelmAppStatus) ContainsCondition(conditionType HelmAppConditionType) bool {
for i := range s.Conditions {
if s.Conditions[i].Type == conditionType {
return true
}
}
return false
}

Copy link
Member

Choose a reason for hiding this comment

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

This function is no longer necessary, right?

…ion because it's no longer necessary

Signed-off-by: Mike Ng <[email protected]>
camilamacedo86
camilamacedo86 previously approved these changes Aug 13, 2020
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Now it shows ok for me 👍 Great work btw 🥇
But I did not test it locally yet.

Let's see what @joelanford think about.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 13, 2020
@camilamacedo86 camilamacedo86 removed the lgtm Indicates that a PR is ready to be merged. label Aug 13, 2020
@camilamacedo86 camilamacedo86 self-requested a review August 13, 2020 19:47
Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks for the contribution! Great find and fix!

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 13, 2020
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/lgtm

@camilamacedo86 camilamacedo86 merged commit e0b27a9 into operator-framework:master Aug 14, 2020
joelanford pushed a commit to joelanford/operator-sdk that referenced this pull request Sep 17, 2020
…allSuccessful (operator-framework#3735)

Fixed a bug that caused the Helm operator not to set the `InstallSuccessful` and `UpgradeSuccessful` status reasons when the status update fails during installation and upgrade. Closes operator-framework#3728
@mikeshng mikeshng deleted the helm-install-status branch October 19, 2021 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Helm operator sometimes doesn't update the CR with the InstallSuccessful status condition
4 participants