Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
926da222
Commit
926da222
authored
7 years ago
by
Alex Dadgar
Browse files
Options
Download
Email Patches
Plain Diff
Status description shows requiring promotion
parent
f2e63242
Branches unavailable
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
nomad/state/state_store.go
+5
-0
nomad/state/state_store.go
nomad/state/state_store_test.go
+4
-0
nomad/state/state_store_test.go
nomad/structs/structs.go
+22
-7
nomad/structs/structs.go
scheduler/reconcile.go
+9
-0
scheduler/reconcile.go
scheduler/reconcile_test.go
+4
-0
scheduler/reconcile_test.go
with
44 additions
and
7 deletions
+44
-7
nomad/state/state_store.go
+
5
-
0
View file @
926da222
...
...
@@ -2015,6 +2015,11 @@ func (s *StateStore) UpdateDeploymentPromotion(index uint64, req *structs.ApplyD
status
.
Promoted
=
true
}
// If the deployment no longer needs promotion, update its status
if
!
copy
.
RequiresPromotion
()
&&
copy
.
Status
==
structs
.
DeploymentStatusRunning
{
copy
.
StatusDescription
=
structs
.
DeploymentStatusDescriptionRunning
}
// Insert the deployment
if
err
:=
s
.
upsertDeploymentImpl
(
index
,
copy
,
txn
);
err
!=
nil
{
return
err
...
...
This diff is collapsed.
Click to expand it.
nomad/state/state_store_test.go
+
4
-
0
View file @
926da222
...
...
@@ -5008,6 +5008,7 @@ func TestStateStore_UpsertDeploymentPromotion_All(t *testing.T) {
// Create a deployment
d
:=
mock
.
Deployment
()
d
.
StatusDescription
=
structs
.
DeploymentStatusDescriptionRunningNeedsPromotion
d
.
JobID
=
j
.
ID
d
.
TaskGroups
=
map
[
string
]
*
structs
.
DeploymentState
{
"web"
:
&
structs
.
DeploymentState
{
...
...
@@ -5066,6 +5067,9 @@ func TestStateStore_UpsertDeploymentPromotion_All(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"bad: %v"
,
err
)
}
if
dout
.
StatusDescription
!=
structs
.
DeploymentStatusDescriptionRunning
{
t
.
Fatalf
(
"status description not updated: got %v; want %v"
,
dout
.
StatusDescription
,
structs
.
DeploymentStatusDescriptionRunning
)
}
if
len
(
dout
.
TaskGroups
)
!=
2
{
t
.
Fatalf
(
"bad: %#v"
,
dout
.
TaskGroups
)
}
...
...
This diff is collapsed.
Click to expand it.
nomad/structs/structs.go
+
22
-
7
View file @
926da222
...
...
@@ -3920,13 +3920,14 @@ const (
// DeploymentStatusDescriptions are the various descriptions of the states a
// deployment can be in.
DeploymentStatusDescriptionRunning
=
"Deployment is running"
DeploymentStatusDescriptionPaused
=
"Deployment is paused"
DeploymentStatusDescriptionSuccessful
=
"Deployment completed successfully"
DeploymentStatusDescriptionStoppedJob
=
"Cancelled because job is stopped"
DeploymentStatusDescriptionNewerJob
=
"Cancelled due to newer version of job"
DeploymentStatusDescriptionFailedAllocations
=
"Failed due to unhealthy allocations"
DeploymentStatusDescriptionFailedByUser
=
"Deployment marked as failed"
DeploymentStatusDescriptionRunning
=
"Deployment is running"
DeploymentStatusDescriptionRunningNeedsPromotion
=
"Deployment is running but requires promotion"
DeploymentStatusDescriptionPaused
=
"Deployment is paused"
DeploymentStatusDescriptionSuccessful
=
"Deployment completed successfully"
DeploymentStatusDescriptionStoppedJob
=
"Cancelled because job is stopped"
DeploymentStatusDescriptionNewerJob
=
"Cancelled due to newer version of job"
DeploymentStatusDescriptionFailedAllocations
=
"Failed due to unhealthy allocations"
DeploymentStatusDescriptionFailedByUser
=
"Deployment marked as failed"
)
// DeploymentStatusDescriptionRollback is used to get the status description of
...
...
@@ -4034,6 +4035,20 @@ func (d *Deployment) HasPlacedCanaries() bool {
return
false
}
// RequiresPromotion returns whether the deployment requires promotion to
// continue
func
(
d
*
Deployment
)
RequiresPromotion
()
bool
{
if
d
==
nil
||
len
(
d
.
TaskGroups
)
==
0
||
d
.
Status
!=
DeploymentStatusRunning
{
return
false
}
for
_
,
group
:=
range
d
.
TaskGroups
{
if
group
.
DesiredCanaries
>
0
&&
!
group
.
Promoted
{
return
true
}
}
return
false
}
func
(
d
*
Deployment
)
GoString
()
string
{
base
:=
fmt
.
Sprintf
(
"Deployment ID %q for job %q has status %q (%v):"
,
d
.
ID
,
d
.
JobID
,
d
.
Status
,
d
.
StatusDescription
)
for
group
,
state
:=
range
d
.
TaskGroups
{
...
...
This diff is collapsed.
Click to expand it.
scheduler/reconcile.go
+
9
-
0
View file @
926da222
...
...
@@ -166,6 +166,13 @@ func (a *allocReconciler) Compute() *reconcileResults {
})
}
// Set the description of a created deployment
if
d
:=
a
.
result
.
deployment
;
d
!=
nil
{
if
d
.
RequiresPromotion
()
{
d
.
StatusDescription
=
structs
.
DeploymentStatusDescriptionRunningNeedsPromotion
}
}
return
a
.
result
}
...
...
@@ -182,6 +189,8 @@ func (a *allocReconciler) cancelDeployments() {
}
// Nothing else to do
a
.
oldDeployment
=
a
.
deployment
a
.
deployment
=
nil
return
}
...
...
This diff is collapsed.
Click to expand it.
scheduler/reconcile_test.go
+
4
-
0
View file @
926da222
...
...
@@ -1904,6 +1904,7 @@ func TestReconciler_StopOldCanaries(t *testing.T) {
r
:=
reconciler
.
Compute
()
newD
:=
structs
.
NewDeployment
(
job
)
newD
.
StatusDescription
=
structs
.
DeploymentStatusDescriptionRunningNeedsPromotion
newD
.
TaskGroups
[
job
.
TaskGroups
[
0
]
.
Name
]
=
&
structs
.
DeploymentState
{
DesiredCanaries
:
2
,
DesiredTotal
:
10
,
...
...
@@ -1956,6 +1957,7 @@ func TestReconciler_NewCanaries(t *testing.T) {
r
:=
reconciler
.
Compute
()
newD
:=
structs
.
NewDeployment
(
job
)
newD
.
StatusDescription
=
structs
.
DeploymentStatusDescriptionRunningNeedsPromotion
newD
.
TaskGroups
[
job
.
TaskGroups
[
0
]
.
Name
]
=
&
structs
.
DeploymentState
{
DesiredCanaries
:
2
,
DesiredTotal
:
10
,
...
...
@@ -2002,6 +2004,7 @@ func TestReconciler_NewCanaries_ScaleUp(t *testing.T) {
r
:=
reconciler
.
Compute
()
newD
:=
structs
.
NewDeployment
(
job
)
newD
.
StatusDescription
=
structs
.
DeploymentStatusDescriptionRunningNeedsPromotion
newD
.
TaskGroups
[
job
.
TaskGroups
[
0
]
.
Name
]
=
&
structs
.
DeploymentState
{
DesiredCanaries
:
2
,
DesiredTotal
:
15
,
...
...
@@ -2049,6 +2052,7 @@ func TestReconciler_NewCanaries_ScaleDown(t *testing.T) {
r
:=
reconciler
.
Compute
()
newD
:=
structs
.
NewDeployment
(
job
)
newD
.
StatusDescription
=
structs
.
DeploymentStatusDescriptionRunningNeedsPromotion
newD
.
TaskGroups
[
job
.
TaskGroups
[
0
]
.
Name
]
=
&
structs
.
DeploymentState
{
DesiredCanaries
:
2
,
DesiredTotal
:
5
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help