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

Wait for pending deletions to complete before a deploy #4531

Merged
merged 1 commit into from
Jul 27, 2020

Conversation

dgageot
Copy link
Contributor

@dgageot dgageot commented Jul 22, 2020

When Skaffold tries to deploy resources, it now checks that none of those resources are marked for deletion. In case, there are at least one, it'll wait for the deletion to complete.
If it doesn't do that, it's going to update resources that are marked for deletion and which are going to disappear in the background.

Fixes #4519

Signed-off-by: David Gageot [email protected]

Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

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

I think this makes sense.

// Find resources with `metadata.deletionTimestamp` field.
for _, r := range result.Items {
if r.Metadata.DeletionTimestamp != "" {
list = append(list, r.Metadata.Name)
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 it's worth appending the group/kind too. I think there's some code in the pkg/diag that can be used here.

@dgageot dgageot force-pushed the wait-for-deletion branch 4 times, most recently from 1fc3468 to e6322d6 Compare July 24, 2020 10:31
@pull-request-size pull-request-size bot added size/L and removed size/M labels Jul 24, 2020
@codecov
Copy link

codecov bot commented Jul 24, 2020

Codecov Report

Merging #4531 into master will increase coverage by 0.02%.
The diff coverage is 79.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4531      +/-   ##
==========================================
+ Coverage   72.69%   72.71%   +0.02%     
==========================================
  Files         335      335              
  Lines       12971    13014      +43     
==========================================
+ Hits         9429     9463      +34     
- Misses       2949     2954       +5     
- Partials      593      597       +4     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/flags.go 86.36% <ø> (ø)
pkg/skaffold/config/options.go 100.00% <ø> (ø)
pkg/skaffold/deploy/kustomize.go 77.52% <40.00%> (-1.09%) ⬇️
pkg/skaffold/deploy/kubectl/cli.go 86.30% <79.31%> (-4.61%) ⬇️
pkg/skaffold/deploy/kubectl.go 69.41% <100.00%> (+0.92%) ⬆️
pkg/skaffold/kubectl/cli.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fedbae...5d203de. Read the comment docs.

@dgageot dgageot force-pushed the wait-for-deletion branch 2 times, most recently from 5ee591c to cc26713 Compare July 24, 2020 13:46
@dgageot dgageot marked this pull request as ready for review July 24, 2020 13:51
@dgageot dgageot requested a review from a team as a code owner July 24, 2020 13:51
@dgageot dgageot requested a review from gsquared94 July 24, 2020 13:51
@dgageot dgageot force-pushed the wait-for-deletion branch 2 times, most recently from 360a6da to 0b22ec0 Compare July 24, 2020 16:09
Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

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

Sorry, I didn't make it all the way through.

@dgageot dgageot force-pushed the wait-for-deletion branch from de0ebd6 to 5bd6bd8 Compare July 24, 2020 17:09
Comment on lines +37 to +38
MaxRetry: 30,
Delay: 2 * time.Second,
Copy link
Contributor

Choose a reason for hiding this comment

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

is this something a user would ever want to configure? maxDeletionWaitTime or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably, yes. I can add that in a second PR

previousList := ""
previousCount := 0

for try := 0; try < WaitDeletion.MaxRetry; try++ {
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to instead use a child context with a timeout? (I'm really just concerned about infinite loops waiting for an object that will never die.)

@dgageot dgageot force-pushed the wait-for-deletion branch from 5bd6bd8 to 5d203de Compare July 26, 2020 19:23
@dgageot dgageot merged commit 9463ceb into GoogleContainerTools:master Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Skaffold sometimes doesn't deploy all services
4 participants