-
Notifications
You must be signed in to change notification settings - Fork 109
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
[SHIPA-2322] adds wait-retry to helm update & delete #233
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
894e26f
adds wait-retry to helm update & delete
stinkyfingers b9e8b85
avoids wait loop; returns error on non-actionable statuses; clean up …
stinkyfingers 15e2dee
adds default timeout/update to helm chart checks
stinkyfingers a064225
rm duplicated code
stinkyfingers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package chart | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
"helm.sh/helm/v3/pkg/action" | ||
"helm.sh/helm/v3/pkg/release" | ||
helmTime "helm.sh/helm/v3/pkg/time" | ||
"sigs.k8s.io/controller-runtime/pkg/log" | ||
) | ||
|
||
func TestIsHelmChartStatusActionable(t *testing.T) { | ||
tests := []struct { | ||
description string | ||
status release.Status | ||
statusMap map[release.Status]int // helmStatusActionMapUpdate or helmStatusActionMapDelete | ||
expected bool | ||
expectedError string | ||
}{ | ||
{ | ||
description: "update - deployed", | ||
status: release.StatusDeployed, | ||
statusMap: helmStatusActionMapUpdate, | ||
expected: true, | ||
}, | ||
{ | ||
description: "update - not found", | ||
status: notFound, | ||
statusMap: helmStatusActionMapUpdate, | ||
expected: true, | ||
}, | ||
{ | ||
description: "update - unknown", | ||
status: release.StatusUnknown, | ||
statusMap: helmStatusActionMapUpdate, | ||
expected: false, | ||
expectedError: "helm chart for app testapp in non-actionable status unknown", | ||
}, | ||
{ | ||
description: "update - superseded", | ||
status: release.StatusSuperseded, | ||
statusMap: helmStatusActionMapUpdate, | ||
expected: false, | ||
}, | ||
{ | ||
description: "delete - deployed", | ||
status: release.StatusDeployed, | ||
statusMap: helmStatusActionMapDelete, | ||
expected: true, | ||
}, | ||
{ | ||
description: "delete - not found", | ||
status: notFound, | ||
statusMap: helmStatusActionMapDelete, | ||
expected: false, | ||
}, | ||
{ | ||
description: "delete - unknown", | ||
status: release.StatusUnknown, | ||
statusMap: helmStatusActionMapDelete, | ||
expected: false, | ||
expectedError: "helm chart for app testapp in non-actionable status unknown", | ||
}, | ||
{ | ||
description: "delete - superseded", | ||
status: release.StatusSuperseded, | ||
statusMap: helmStatusActionMapDelete, | ||
expected: false, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.description, func(t *testing.T) { | ||
c := &HelmClient{ | ||
log: log.NullLogger{}, | ||
} | ||
mockStatusFunc := func(cfg *action.Configuration, appName string) (*release.Release, release.Status, error) { | ||
status := tc.status | ||
currentRelease := &release.Release{Info: &release.Info{FirstDeployed: helmTime.Time{Time: time.Now()}}} | ||
return currentRelease, status, nil | ||
} | ||
|
||
ok, err := c.isHelmChartStatusActionable(mockStatusFunc, "testapp", tc.statusMap) | ||
if tc.expectedError != "" { | ||
require.EqualError(t, err, tc.expectedError) | ||
} else { | ||
require.Nil(t, err) | ||
} | ||
require.Equal(t, tc.expected, ok) | ||
}) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
would it help if we implement something like
ketch/internal/chart/helm_client.go
Lines 129 to 136 in b9e8b85
i
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, that makes sense. This PR's addition almost duplicates that
FirstDeployed.Before
check, but considers additionalstatuses
. I removed the original block of code.