-
Notifications
You must be signed in to change notification settings - Fork 2k
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
auto promote canaries #5719
Merged
Merged
auto promote canaries #5719
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
55b91ad
new deploymentwatcher/doc.go for package level documentation
langmartin 2f23357
state_store typo in a comment
langmartin 1ba04fc
deployments_watcher comments
langmartin 2753b51
deployment_watcher when it's ok to autopromote, do so
langmartin 2165f8b
sched reconcile copy AutoPromote to DeploymentState
langmartin 0643a01
deployments_watcher_test new TestWatcher_AutoPromoteDeployment
langmartin 9621c07
add update AutoPromote bool
langmartin 5ac416a
website update auto_promote doc
langmartin 21dccdf
describe a pending deployment with auto_promote accurately
langmartin 84307d9
describe a pending deployment without auto_promote more explicitly
langmartin 8b64574
e2e util split new alloc and await placement, new WaitForDeployment
langmartin 2422991
new e2e deployment test
langmartin 1a99a0f
e2e utils error format arg match
langmartin 03c69c8
api/jobs add AutoPromote to Canonicalize
langmartin 2772cc2
log error on autoPromoteDeployment failure
langmartin d867cbf
structs validate requires Canary for AutoPromote
langmartin c009381
CHANGELOG add improvement entry
langmartin 78b9aef
e2e README typo
langmartin 3a3c442
e2e utils remove ineffectual assignment of allocs
langmartin 7d40ffd
api/jobs diff tests expect AutoPromote
langmartin f4701e6
Update website/source/docs/job-specification/update.html.md
langmartin 0da3ee5
website more explicit auto_promote instructions
langmartin 1e9f314
e2e readme minor changes to command + env val templates and order
langmartin dd2f16a
e2e add deployment to the list of e2e tests, minor fixes
langmartin 28dbf73
deployment_watcher auto promote iff every task group is auto promotable
langmartin c086b5f
api use job.update as the default for taskgroup.update
langmartin a5e3e8e
e2e/deployment comment the job files for clarity
langmartin a234550
Update e2e/deployment/deployment.go
langmartin 71338ab
structs job warnings for taskgroup with mixed auto_promote settings
langmartin b09b0be
structs comment todo DeploymentStatus & DeploymentStatusDescription
langmartin 9f74b22
comment replace COMPAT 0.7.0 for job.Update with more current info
langmartin c9a837c
structs check TaskGroup.Update for nil
langmartin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package deployment | ||
|
||
import ( | ||
"github.com/hashicorp/nomad/api" | ||
"github.com/hashicorp/nomad/e2e/framework" | ||
"github.com/hashicorp/nomad/nomad/structs" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/hashicorp/nomad/e2e/e2eutil" | ||
"github.com/hashicorp/nomad/helper/uuid" | ||
) | ||
|
||
type DeploymentTest struct { | ||
framework.TC | ||
jobIds []string | ||
} | ||
|
||
func init() { | ||
framework.AddSuites(&framework.TestSuite{ | ||
Component: "Deployment", | ||
CanRunLocal: true, | ||
Cases: []framework.TestCase{ | ||
new(DeploymentTest), | ||
}, | ||
}) | ||
} | ||
|
||
func (tc *DeploymentTest) BeforeAll(f *framework.F) { | ||
// Ensure cluster has leader before running tests | ||
e2eutil.WaitForLeader(f.T(), tc.Nomad()) | ||
e2eutil.WaitForNodesReady(f.T(), tc.Nomad(), 4) | ||
} | ||
|
||
func (tc *DeploymentTest) TestDeploymentAutoPromote(f *framework.F) { | ||
t := f.T() | ||
nomadClient := tc.Nomad() | ||
uuid := uuid.Generate() | ||
jobId := "deployment" + uuid[0:8] | ||
tc.jobIds = append(tc.jobIds, jobId) | ||
e2eutil.RegisterAndWaitForAllocs(t, nomadClient, "deployment/input/deployment_auto0.nomad", jobId) | ||
|
||
// Upgrade | ||
e2eutil.RegisterAllocs(t, nomadClient, "deployment/input/deployment_auto1.nomad", jobId) | ||
var deploy *api.Deployment | ||
ds, _, err := nomadClient.Deployments().List(nil) | ||
require.NoError(t, err) | ||
|
||
// Find the deployment | ||
for _, d := range ds { | ||
if d.JobID == jobId { | ||
deploy = d | ||
break | ||
} | ||
} | ||
|
||
// Deployment is auto pending the upgrade of "two" which has a longer time to health | ||
run := structs.DeploymentStatusRunning | ||
require.Equal(t, run, deploy.Status) | ||
require.Equal(t, structs.DeploymentStatusDescriptionRunningAutoPromotion, deploy.StatusDescription) | ||
|
||
// Deployment is eventually running | ||
e2eutil.WaitForDeployment(t, nomadClient, deploy.ID, run, structs.DeploymentStatusDescriptionRunning) | ||
|
||
deploy, _, _ = nomadClient.Deployments().Info(deploy.ID, nil) | ||
require.Equal(t, run, deploy.Status) | ||
require.Equal(t, structs.DeploymentStatusDescriptionRunning, deploy.StatusDescription) | ||
} | ||
|
||
func (tc *DeploymentTest) AfterEach(f *framework.F) { | ||
nomadClient := tc.Nomad() | ||
jobs := nomadClient.Jobs() | ||
// Stop all jobs in test | ||
for _, id := range tc.jobIds { | ||
jobs.Deregister(id, true, nil) | ||
} | ||
langmartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tc.jobIds = []string{} | ||
// Garbage collect | ||
nomadClient.System().GarbageCollect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
job "deployment_auto.nomad" { | ||
notnoop marked this conversation as resolved.
Show resolved
Hide resolved
|
||
datacenters = ["dc1"] | ||
|
||
group "one" { | ||
count = 3 | ||
|
||
update { | ||
max_parallel = 3 | ||
auto_promote = true | ||
canary = 2 | ||
} | ||
|
||
task "one" { | ||
driver = "raw_exec" | ||
|
||
config { | ||
command = "/bin/sleep" | ||
# change args to update the job, the only changes | ||
args = ["1000000"] | ||
} | ||
|
||
resources { | ||
cpu = 20 | ||
memory = 20 | ||
} | ||
} | ||
} | ||
|
||
group "two" { | ||
count = 3 | ||
|
||
update { | ||
max_parallel = 2 | ||
auto_promote = true | ||
canary = 2 | ||
min_healthy_time = "2s" | ||
} | ||
|
||
task "two" { | ||
driver = "raw_exec" | ||
|
||
config { | ||
command = "/bin/sleep" | ||
# change args to update the job, the only changes | ||
args = ["2000000"] | ||
} | ||
|
||
resources { | ||
cpu = 20 | ||
memory = 20 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest updating changelog after merging PR as the changelog is common cause of conflicts.