This repository was archived by the owner on Jun 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +84
-9
lines changed Expand file tree Collapse file tree 3 files changed +84
-9
lines changed Original file line number Diff line number Diff line change @@ -181,15 +181,17 @@ func (l *levantDeployment) deploy() (success bool) {
181181 return
182182 }
183183
184- // If the job is not a canary job, then run the auto-revert checker, the
185- // current checking mechanism is slightly hacky and should be updated.
186- // The reason for this is currently the config.Job is populate from the
187- // rendered job and so a user could potentially not set canary meaning
188- // the field shows a null.
189- if l .config .Template .Job .Update .Canary == nil {
190- l .checkAutoRevert (dep )
191- } else if * l .config .Template .Job .Update .Canary == 0 {
192- l .checkAutoRevert (dep )
184+ if l .config .Template .Job .Update != nil {
185+ // If the job is not a canary job, then run the auto-revert checker, the
186+ // current checking mechanism is slightly hacky and should be updated.
187+ // The reason for this is currently the config.Job is populates from the
188+ // rendered job and so a user could potentially not set canary meaning
189+ // the field shows a null.
190+ if l .config .Template .Job .Update .Canary == nil {
191+ l .checkAutoRevert (dep )
192+ } else if * l .config .Template .Job .Update .Canary == 0 {
193+ l .checkAutoRevert (dep )
194+ }
193195 }
194196
195197 case nomad .JobTypeBatch :
Original file line number Diff line number Diff line change @@ -135,6 +135,21 @@ func TestDeploy_canary(t *testing.T) {
135135 })
136136}
137137
138+ func TestDeploy_failed_deploy_with_no_update (t * testing.T ) {
139+ acctest .Test (t , acctest.TestCase {
140+ Steps : []acctest.TestStep {
141+ {
142+ Runner : acctest.DeployTestStepRunner {
143+ FixtureName : "deploy_fail_with_no_update.nomad" ,
144+ },
145+ ExpectErr : true ,
146+ Check : acctest .CheckDeploymentStatus ("failed" ),
147+ },
148+ },
149+ CleanupFunc : acctest .CleanupPurgeJob ,
150+ })
151+ }
152+
138153func TestDeploy_lifecycle (t * testing.T ) {
139154 acctest .Test (t , acctest.TestCase {
140155 Steps : []acctest.TestStep {
Original file line number Diff line number Diff line change 1+ job "[[.job_name]]" {
2+ datacenters = [" dc1" ]
3+ type = " service"
4+
5+ group "test" {
6+ count = 1
7+
8+ restart {
9+ attempts = 1
10+ interval = " 5s"
11+ delay = " 1s"
12+ mode = " fail"
13+ }
14+
15+ ephemeral_disk {
16+ size = 300
17+ }
18+
19+ update {
20+ max_parallel = 1
21+ min_healthy_time = " 10s"
22+ healthy_deadline = " 1m"
23+ }
24+
25+ network {
26+ port "http" {
27+ to = 80
28+ }
29+ }
30+
31+ service {
32+ name = " fake-service"
33+ port = " http"
34+
35+ check {
36+ name = " alive"
37+ type = " tcp"
38+ interval = " 10s"
39+ timeout = " 2s"
40+ }
41+ }
42+
43+ task "alpine" {
44+ driver = " docker"
45+ config {
46+ image = " alpine"
47+ command = " sleep 1 && exit 1"
48+ }
49+ resources {
50+ cpu = 100
51+ memory = 20
52+ network {
53+ mbits = 10
54+ }
55+ }
56+ }
57+ }
58+ }
You can’t perform that action at this time.
0 commit comments