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

KAPP-1000: Apply noop changes after everything else #1001

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions pkg/kapp/clusterapply/applying_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,29 @@ func (c *ApplyingChanges) Apply(allChanges []*ctldgraph.Change) ([]WaitingChange
applyThrottle := util.NewThrottle(c.opts.Concurrency)
applyCh := make(chan applyResult, len(nonAppliedChanges))

for _, change := range nonAppliedChanges {
change := change // copy

go func() {
applyThrottle.Take()
defer applyThrottle.Done()

clusterChange := change.Change.(wrappedClusterChange).ClusterChange
retryable, descMsgs, err := clusterChange.Apply()
// Perform noop changes after all other changes are applied
allChangesAreNoop := c.allChangesAreNoop(nonAppliedChanges)

applyCh <- applyResult{
Change: change,
ClusterChange: clusterChange,
DescMsgs: descMsgs,
Retryable: retryable,
Err: err,
}
}()
for _, change := range nonAppliedChanges {
if allChangesAreNoop || (change.Change.Op() != ctldgraph.ActualChangeOpNoop) {
change := change // copy

go func() {
applyThrottle.Take()
defer applyThrottle.Done()

clusterChange := change.Change.(wrappedClusterChange).ClusterChange
retryable, descMsgs, err := clusterChange.Apply()

applyCh <- applyResult{
Change: change,
ClusterChange: clusterChange,
DescMsgs: descMsgs,
Retryable: retryable,
Err: err,
}
}()
}
}

var appliedChanges []WaitingChange
Expand Down Expand Up @@ -138,6 +143,15 @@ func (c *ApplyingChanges) nonAppliedChanges(allChanges []*ctldgraph.Change) []*c
return result
}

func (c *ApplyingChanges) allChangesAreNoop(allChanges []*ctldgraph.Change) bool {
for _, change := range allChanges {
if change.Change.Op() != ctldgraph.ActualChangeOpNoop {
return false
}
}
return true
}

func (c *ApplyingChanges) isApplied(change *ctldgraph.Change) bool {
_, found := c.applied[change]
return found
Expand Down
Loading