Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
e784378b
Unverified
Commit
e784378b
authored
3 years ago
by
Luiz Aoqui
Committed by
GitHub
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Don't emit scaling event error when a deployment is underway (#11556)
parent
416b14ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.changelog/11556.txt
+3
-0
.changelog/11556.txt
nomad/job_endpoint.go
+1
-25
nomad/job_endpoint.go
nomad/job_endpoint_test.go
+0
-16
nomad/job_endpoint_test.go
with
4 additions
and
41 deletions
+4
-41
.changelog/11556.txt
0 → 100644
+
3
-
0
View file @
e784378b
```release-note:improvement
scaling: Don't emit scaling action with error in case of active deployment
```
This diff is collapsed.
Click to expand it.
nomad/job_endpoint.go
+
1
-
25
View file @
e784378b
...
...
@@ -1103,31 +1103,7 @@ func (j *Job) Scale(args *structs.JobScaleRequest, reply *structs.JobRegisterRes
}
if
deployment
!=
nil
&&
deployment
.
Active
()
&&
deployment
.
JobCreateIndex
==
job
.
CreateIndex
{
msg
:=
"job scaling blocked due to active deployment"
_
,
_
,
err
:=
j
.
srv
.
raftApply
(
structs
.
ScalingEventRegisterRequestType
,
&
structs
.
ScalingEventRequest
{
Namespace
:
job
.
Namespace
,
JobID
:
job
.
ID
,
TaskGroup
:
groupName
,
ScalingEvent
:
&
structs
.
ScalingEvent
{
Time
:
now
,
PreviousCount
:
prevCount
,
Message
:
msg
,
Error
:
true
,
Meta
:
map
[
string
]
interface
{}{
"OriginalMessage"
:
args
.
Message
,
"OriginalCount"
:
*
args
.
Count
,
"OriginalMeta"
:
args
.
Meta
,
},
},
},
)
if
err
!=
nil
{
// just log the error, this was a best-effort attempt
j
.
logger
.
Error
(
"scaling event create failed during block scaling action"
,
"error"
,
err
)
}
return
structs
.
NewErrRPCCoded
(
400
,
msg
)
return
structs
.
NewErrRPCCoded
(
400
,
"job scaling blocked due to active deployment"
)
}
// Commit the job update
...
...
This diff is collapsed.
Click to expand it.
nomad/job_endpoint_test.go
+
0
-
16
View file @
e784378b
...
...
@@ -6769,22 +6769,6 @@ func TestJobEndpoint_Scale_DeploymentBlocking(t *testing.T) {
require
.
NotEmpty
(
resp
.
EvalID
)
require
.
Greater
(
resp
.
EvalCreateIndex
,
resp
.
JobModifyIndex
)
}
events
,
_
,
_
:=
state
.
ScalingEventsByJob
(
nil
,
job
.
Namespace
,
job
.
ID
)
require
.
Equal
(
1
,
len
(
events
[
groupName
]))
latestEvent
:=
events
[
groupName
][
0
]
if
dLatest
.
Active
()
{
require
.
True
(
latestEvent
.
Error
)
require
.
Nil
(
latestEvent
.
Count
)
require
.
Contains
(
latestEvent
.
Message
,
"blocked due to active deployment"
)
require
.
Equal
(
latestEvent
.
Meta
[
"OriginalCount"
],
newCount
)
require
.
Equal
(
latestEvent
.
Meta
[
"OriginalMessage"
],
scalingMessage
)
require
.
Equal
(
latestEvent
.
Meta
[
"OriginalMeta"
],
scalingMetadata
)
}
else
{
require
.
False
(
latestEvent
.
Error
)
require
.
NotNil
(
latestEvent
.
Count
)
require
.
Equal
(
newCount
,
*
latestEvent
.
Count
)
}
}
}
...
...
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