This repository has been archived by the owner on Jul 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
startfailure.go
159 lines (135 loc) · 5.03 KB
/
startfailure.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
// Copyright (c) 2016 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package payloads
import (
"github.com/golang/glog"
)
// StartFailureReason denotes the underlying error that prevented
// an SSNTP START command from launching a new instance on a CN
// or a NN. Most, but not all, of these errors are returned by
// ciao-launcher
type StartFailureReason string
const (
// FullCloud is returned by the scheduler when all nodes in the cluster
// are FULL and it is unable to satisfy a START request.
FullCloud StartFailureReason = "full_cloud"
// FullComputeNode indicates that the node to which the START command
// was sent had insufficient resources to start the requested instance.
FullComputeNode = "full_cn"
// NodeInMaintenance indicates that the node to which the START command
// was sent cannot host the instance as it is currently in maintenance
// mode.
NodeInMaintenance = "node_maintenance"
// NoComputeNodes is returned by the scheduler if no compute nodes are
// running in the cluster upon which the instance can be started.
NoComputeNodes = "no_cn"
// NoNetworkNodes is returned by the scheduler if no network nodes are
// running in the cluster upon which the instance can be started.
NoNetworkNodes = "no_net_cn"
// InvalidPayload indicates that the contents of the START payload are
// corrupt
InvalidPayload = "invalid_payload"
// InvalidData indicates that the start section of the payload is
// corrupt or missing information
InvalidData = "invalid_data"
// AlreadyRunning is returned when an attempt is made to start an
// instance on a node upon which that very same instance is already
// running.
AlreadyRunning = "already_running"
// InstanceExists is returned when an attempt is made to start an
// instance on a node upon which that very same instance already
// exists but is not currently running.
InstanceExists = "instance_exists"
// ImageFailure indicates that ciao-launcher is unable to locate
// the rootfs for the instance, e.g., a VM instance is started
// with no bootable volumes or a containers image cannot be
// downloaded.
ImageFailure = "image_failure"
// LaunchFailure indicates that the instance has been successfully
// created but could not be launched. Actually, this is sort of an
// odd situation as the START command partially succeeded.
// ciao-launcher returns an error code, but the instance has been
// created and could be booted a later stage via the RESTART command.
LaunchFailure = "launch_failure"
// NetworkFailure indicates that it was not possible to initialise
// networking for the instance.
NetworkFailure = "network_failure"
)
// ErrorStartFailure represents the unmarshalled version of the contents of a
// SSNTP ERROR frame whose type is set to ssntp.StartFailure.
type ErrorStartFailure struct {
// NodeUUID is the UUID of the node that generated this error.
NodeUUID string `yaml:"node_uuid"`
// InstanceUUID is the UUID of the instance that could not be started.
InstanceUUID string `yaml:"instance_uuid"`
// Reason provides the reason for the start failure, e.g.,
// LaunchFailure.
Reason StartFailureReason `yaml:"reason"`
// Restart is true if the failed start command was attempting to
// restart an existing instance.
Restart bool
}
func (r StartFailureReason) String() string {
switch r {
case FullCloud:
return "Cloud is full"
case FullComputeNode:
return "Compute node is full"
case NodeInMaintenance:
return "Node is undergoing maintenance"
case NoComputeNodes:
return "No compute node available"
case NoNetworkNodes:
return "No network node available"
case InvalidPayload:
return "YAML payload is corrupt"
case InvalidData:
return "Command section of YAML payload is corrupt or missing required information"
case AlreadyRunning:
return "Instance is already running"
case InstanceExists:
return "Instance already exists"
case ImageFailure:
return "Failed to create instance image"
case LaunchFailure:
return "Failed to launch instance"
case NetworkFailure:
return "Failed to create VNIC for instance"
}
return ""
}
// IsFatal indicates that the failure should be treated as a fatal failure
// indicating the instance did not start.
func (r StartFailureReason) IsFatal() bool {
switch r {
case FullCloud,
FullComputeNode,
NodeInMaintenance,
NoComputeNodes,
NoNetworkNodes,
InvalidPayload,
InvalidData,
ImageFailure,
LaunchFailure,
NetworkFailure:
return true
case AlreadyRunning,
InstanceExists:
return false
}
glog.Errorf("Unexpected StartFailureReason: %s", r)
return false
}