@@ -141,12 +141,16 @@ func (s *HTTPServer) jobPlan(resp http.ResponseWriter, req *http.Request,
141
141
return nil , CodedError (400 , "Job ID does not match" )
142
142
}
143
143
144
- // Http region takes precedence over hcl region
144
+ // Region in http request query param takes precedence over region in job hcl config
145
145
if args .WriteRequest .Region != "" {
146
146
args .Job .Region = helper .StringToPtr (args .WriteRequest .Region )
147
147
}
148
+ // If 'global' region is specified or if no region is given,
149
+ // default to region of the node you're submitting to
150
+ if args .Job .Region == nil || * args .Job .Region == "" || * args .Job .Region == api .GlobalRegion {
151
+ args .Job .Region = & s .agent .config .Region
152
+ }
148
153
149
- // If no region given, region is canonicalized to 'global'
150
154
sJob := ApiJobToStructJob (args .Job )
151
155
152
156
planReq := structs.JobPlanRequest {
@@ -157,6 +161,8 @@ func (s *HTTPServer) jobPlan(resp http.ResponseWriter, req *http.Request,
157
161
Region : sJob .Region ,
158
162
},
159
163
}
164
+ // parseWriteRequest overrides Namespace, Region and AuthToken
165
+ // based on values from the original http request
160
166
s .parseWriteRequest (req , & planReq .WriteRequest )
161
167
planReq .Namespace = sJob .Namespace
162
168
@@ -384,12 +390,16 @@ func (s *HTTPServer) jobUpdate(resp http.ResponseWriter, req *http.Request,
384
390
return nil , CodedError (400 , "Job ID does not match name" )
385
391
}
386
392
387
- // Http region takes precedence over hcl region
393
+ // Region in http request query param takes precedence over region in job hcl config
388
394
if args .WriteRequest .Region != "" {
389
395
args .Job .Region = helper .StringToPtr (args .WriteRequest .Region )
390
396
}
397
+ // If 'global' region is specified or if no region is given,
398
+ // default to region of the node you're submitting to
399
+ if args .Job .Region == nil || * args .Job .Region == "" || * args .Job .Region == api .GlobalRegion {
400
+ args .Job .Region = & s .agent .config .Region
401
+ }
391
402
392
- // If no region given, region is canonicalized to 'global'
393
403
sJob := ApiJobToStructJob (args .Job )
394
404
395
405
regReq := structs.JobRegisterRequest {
@@ -402,6 +412,8 @@ func (s *HTTPServer) jobUpdate(resp http.ResponseWriter, req *http.Request,
402
412
AuthToken : args .WriteRequest .SecretID ,
403
413
},
404
414
}
415
+ // parseWriteRequest overrides Namespace, Region and AuthToken
416
+ // based on values from the original http request
405
417
s .parseWriteRequest (req , & regReq .WriteRequest )
406
418
regReq .Namespace = sJob .Namespace
407
419
0 commit comments