Skip to content

Commit

Permalink
lib/resourcebuilder/apps: Explicit mode instead of 'Generation > 1'
Browse files Browse the repository at this point in the history
deploymentBuilder and daemonsetBuilder grow mode properties.  They had
been using 'actual.Generation > 1' as a proxy for "post-install" since
14fab0b (add generic 2-way merge handler for random types,
2018-09-27, #26), but generation 1 is just "we haven't changed the
object since it was created", not "we're installing a fresh cluster".
For example, a new Deployment or DaemonSet could be added as part of a
cluster update, and we don't want special install-time "we don't care
about specific manifest failures" then.
  • Loading branch information
wking committed Jul 8, 2020
1 parent 8b9931b commit 1e38ab0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/resourcebuilder/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type deploymentBuilder struct {
proxyGetter configv1.ProxiesGetter
raw []byte
modifier MetaV1ObjectModifierFunc
mode Mode
}

func newDeploymentBuilder(config *rest.Config, m lib.Manifest) Interface {
Expand All @@ -37,6 +38,7 @@ func newDeploymentBuilder(config *rest.Config, m lib.Manifest) Interface {
}

func (b *deploymentBuilder) WithMode(m Mode) Interface {
b.mode = m
return b
}

Expand Down Expand Up @@ -74,7 +76,7 @@ func (b *deploymentBuilder) Do(ctx context.Context) error {
if err != nil {
return err
}
if updated && actual.Generation > 1 {
if updated && b.mode != InitializingMode {
return waitForDeploymentCompletion(ctx, b.client, deployment)
}
return nil
Expand Down Expand Up @@ -174,6 +176,7 @@ type daemonsetBuilder struct {
proxyGetter configv1.ProxiesGetter
raw []byte
modifier MetaV1ObjectModifierFunc
mode Mode
}

func newDaemonsetBuilder(config *rest.Config, m lib.Manifest) Interface {
Expand All @@ -185,6 +188,7 @@ func newDaemonsetBuilder(config *rest.Config, m lib.Manifest) Interface {
}

func (b *daemonsetBuilder) WithMode(m Mode) Interface {
b.mode = m
return b
}

Expand Down Expand Up @@ -222,7 +226,7 @@ func (b *daemonsetBuilder) Do(ctx context.Context) error {
if err != nil {
return err
}
if updated && actual.Generation > 1 {
if updated && b.mode != InitializingMode {
return waitForDaemonsetRollout(ctx, b.client, daemonset)
}
return nil
Expand Down

0 comments on commit 1e38ab0

Please sign in to comment.