diff --git a/pkg/kapp/clusterapply/applying_changes.go b/pkg/kapp/clusterapply/applying_changes.go index 0487c0b06..d29c93b78 100644 --- a/pkg/kapp/clusterapply/applying_changes.go +++ b/pkg/kapp/clusterapply/applying_changes.go @@ -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 @@ -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