@@ -93,7 +93,7 @@ func ensureDownloadedImageFitWithinBudget(ctx context.Context, s *state.State, r
93
93
}
94
94
95
95
func createFromImage (s * state.State , r * http.Request , p api.Project , profiles []api.Profile , img * api.Image , imgAlias string , req * api.InstancesPost ) response.Response {
96
- if s .DB .Cluster .LocalNodeIsEvacuated () {
96
+ if s .ServerClustered && s . DB .Cluster .LocalNodeIsEvacuated () {
97
97
return response .Forbidden (fmt .Errorf ("Cluster member is evacuated" ))
98
98
}
99
99
@@ -156,7 +156,7 @@ func createFromImage(s *state.State, r *http.Request, p api.Project, profiles []
156
156
}
157
157
158
158
func createFromNone (s * state.State , r * http.Request , projectName string , profiles []api.Profile , req * api.InstancesPost ) response.Response {
159
- if s .DB .Cluster .LocalNodeIsEvacuated () {
159
+ if s .ServerClustered && s . DB .Cluster .LocalNodeIsEvacuated () {
160
160
return response .Forbidden (fmt .Errorf ("Cluster member is evacuated" ))
161
161
}
162
162
@@ -209,7 +209,7 @@ func createFromNone(s *state.State, r *http.Request, projectName string, profile
209
209
}
210
210
211
211
func createFromMigration (ctx context.Context , s * state.State , r * http.Request , projectName string , profiles []api.Profile , req * api.InstancesPost ) response.Response {
212
- if s .DB . Cluster . LocalNodeIsEvacuated () && r != nil && r .Context ().Value (request .CtxProtocol ) != "cluster" {
212
+ if s .ServerClustered && r != nil && r .Context ().Value (request .CtxProtocol ) != "cluster" && s . DB . Cluster . LocalNodeIsEvacuated () {
213
213
return response .Forbidden (fmt .Errorf ("Cluster member is evacuated" ))
214
214
}
215
215
@@ -474,7 +474,7 @@ func createFromMigration(ctx context.Context, s *state.State, r *http.Request, p
474
474
}
475
475
476
476
func createFromCopy (ctx context.Context , s * state.State , r * http.Request , projectName string , profiles []api.Profile , req * api.InstancesPost ) response.Response {
477
- if s .DB .Cluster .LocalNodeIsEvacuated () {
477
+ if s .ServerClustered && s . DB .Cluster .LocalNodeIsEvacuated () {
478
478
return response .Forbidden (fmt .Errorf ("Cluster member is evacuated" ))
479
479
}
480
480
@@ -956,12 +956,12 @@ func instancesPost(d *Daemon, r *http.Request) response.Response {
956
956
var targetMemberInfo * db.NodeInfo
957
957
var targetGroupName string
958
958
959
- err = s .DB .Cluster .Transaction (r .Context (), func (ctx context.Context , tx * db.ClusterTx ) error {
960
- target := request .QueryParam (r , "target" )
961
- if ! s .ServerClustered && target != "" {
962
- return api .StatusErrorf (http .StatusBadRequest , "Target only allowed when clustered" )
963
- }
959
+ target := request .QueryParam (r , "target" )
960
+ if ! s .ServerClustered && target != "" {
961
+ return response .BadRequest (fmt .Errorf ("Target only allowed when clustered" ))
962
+ }
964
963
964
+ err = s .DB .Cluster .Transaction (r .Context (), func (ctx context.Context , tx * db.ClusterTx ) error {
965
965
dbProject , err := dbCluster .GetProject (ctx , tx .Tx (), targetProjectName )
966
966
if err != nil {
967
967
return fmt .Errorf ("Failed loading project: %w" , err )
0 commit comments