|
26 | 26 | package core |
27 | 27 |
|
28 | 28 | import ( |
| 29 | + "fmt" |
| 30 | + "runtime" |
| 31 | + "time" |
| 32 | + |
29 | 33 | "golang.org/x/net/context" |
30 | | - "google.golang.org/grpc" |
| 34 | + "google.golang.org/grpc" |
31 | 35 |
|
| 36 | + "github.com/AliceO2Group/Control/core/environment" |
32 | 37 | "github.com/AliceO2Group/Control/core/protos" |
33 | | - "google.golang.org/grpc/reflection" |
34 | | - "github.com/mesos/mesos-go/api/v1/lib/extras/store" |
35 | | - "runtime" |
36 | | - "fmt" |
37 | | - "google.golang.org/grpc/status" |
38 | | - "google.golang.org/grpc/codes" |
39 | 38 | "github.com/looplab/fsm" |
| 39 | + "github.com/mesos/mesos-go/api/v1/lib/extras/store" |
40 | 40 | "github.com/pborman/uuid" |
41 | | - "time" |
42 | | - "github.com/AliceO2Group/Control/core/environment" |
| 41 | + "google.golang.org/grpc/codes" |
| 42 | + "google.golang.org/grpc/reflection" |
| 43 | + "google.golang.org/grpc/status" |
43 | 44 | ) |
44 | 45 |
|
45 | 46 |
|
@@ -269,9 +270,12 @@ func (m *RpcServer) DestroyEnvironment(cxt context.Context, req *pb.DestroyEnvir |
269 | 270 | return nil, status.Newf(codes.FailedPrecondition, "cannot destroy environment in state %s", env.CurrentState()).Err() |
270 | 271 | } |
271 | 272 |
|
272 | | - err = env.TryTransition(environment.MakeTransition(m.state.taskman, pb.ControlEnvironmentRequest_EXIT)) |
273 | | - if err != nil { |
274 | | - return &pb.DestroyEnvironmentReply{}, status.New(codes.Internal, err.Error()).Err() |
| 273 | + // This might transition to STANDBY if needed, of do nothing if we're already there |
| 274 | + if env.CurrentState() == "CONFIGURED" { |
| 275 | + err = env.TryTransition(environment.MakeTransition(m.state.taskman, pb.ControlEnvironmentRequest_RESET)) |
| 276 | + if err != nil { |
| 277 | + return &pb.DestroyEnvironmentReply{}, status.New(codes.Internal, err.Error()).Err() |
| 278 | + } |
275 | 279 | } |
276 | 280 |
|
277 | 281 | err = m.state.environments.TeardownEnvironment(env.Id()) |
|
0 commit comments