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

Delete compatibility code for job level update stanza #3979

Merged
merged 2 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
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
79 changes: 0 additions & 79 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1784,85 +1784,6 @@ func (j *Job) Canonicalize() (warnings error) {
j.Periodic.Canonicalize()
}

// COMPAT: Remove in 0.7.0
// Rewrite any job that has an update block with pre 0.6.0 syntax.
jobHasOldUpdate := j.Update.Stagger > 0 && j.Update.MaxParallel > 0
if jobHasOldUpdate && j.Type != JobTypeBatch {
// Build an appropriate update block and copy it down to each task group
base := DefaultUpdateStrategy.Copy()
base.MaxParallel = j.Update.MaxParallel
base.MinHealthyTime = j.Update.Stagger

// Add to each task group, modifying as needed
upgraded := false
l := len(j.TaskGroups)
for _, tg := range j.TaskGroups {
// The task group doesn't need upgrading if it has an update block with the new syntax
u := tg.Update
if u != nil && u.Stagger > 0 && u.MaxParallel > 0 &&
u.HealthCheck != "" && u.MinHealthyTime > 0 && u.HealthyDeadline > 0 {
continue
}

upgraded = true

// The MaxParallel for the job should be 10% of the total count
// unless there is just one task group then we can infer the old
// max parallel should be the new
tgu := base.Copy()
if l != 1 {
// RoundTo 10%
var percent float64 = float64(tg.Count) * 0.1
tgu.MaxParallel = int(percent + 0.5)
}

// Safety guards
if tgu.MaxParallel == 0 {
tgu.MaxParallel = 1
} else if tgu.MaxParallel > tg.Count {
tgu.MaxParallel = tg.Count
}

tg.Update = tgu
}

if upgraded {
w := "A best effort conversion to new update stanza introduced in v0.6.0 applied. " +
"Please update upgrade stanza before v0.7.0."
multierror.Append(&mErr, fmt.Errorf(w))
}
}

// Ensure that the batch job doesn't have new style or old style update
// stanza. Unfortunately are scanning here because we have to deprecate over
// a release so we can't check in the task group since that may be new style
// but wouldn't capture the old style and we don't want to have duplicate
// warnings.
if j.Type == JobTypeBatch {
displayWarning := jobHasOldUpdate
j.Update.Stagger = 0
j.Update.MaxParallel = 0
j.Update.HealthCheck = ""
j.Update.MinHealthyTime = 0
j.Update.HealthyDeadline = 0
j.Update.AutoRevert = false
j.Update.Canary = 0

// Remove any update spec from the task groups
for _, tg := range j.TaskGroups {
if tg.Update != nil {
displayWarning = true
tg.Update = nil
}
}

if displayWarning {
w := "Update stanza is disallowed for batch jobs since v0.6.0. " +
"The update block has automatically been removed"
multierror.Append(&mErr, fmt.Errorf(w))
}
}

return mErr.ErrorOrNil()
}

Expand Down
Loading