feat: added retry last action support for workspaces and new failure states

This commit is contained in:
Andrey Melnikov
2020-09-10 12:30:18 -07:00
parent 076422e8ac
commit fc7ef5ffac
11 changed files with 693 additions and 107 deletions

View File

@@ -3,7 +3,7 @@
"info": { "info": {
"title": "Onepanel", "title": "Onepanel",
"description": "Onepanel API", "description": "Onepanel API",
"version": "0.12.0-rc.0", "version": "0.12.1",
"contact": { "contact": {
"name": "Onepanel project", "name": "Onepanel project",
"url": "https://github.com/onepanelio/core" "url": "https://github.com/onepanelio/core"
@@ -2339,6 +2339,42 @@
] ]
} }
}, },
"/apis/v1beta1/{namespace}/workspaces/{uid}/retry": {
"put": {
"operationId": "RetryLastWorkspaceAction",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"properties": {}
}
},
"default": {
"description": "An unexpected error response",
"schema": {
"$ref": "#/definitions/grpc.gateway.runtime.Error"
}
}
},
"parameters": [
{
"name": "namespace",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "uid",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"WorkspaceService"
]
}
},
"/apis/v1beta1/{namespace}/workspaces/{uid}/status": { "/apis/v1beta1/{namespace}/workspaces/{uid}/status": {
"put": { "put": {
"operationId": "UpdateWorkspaceStatus", "operationId": "UpdateWorkspaceStatus",

View File

@@ -890,6 +890,61 @@ func (x *DeleteWorkspaceRequest) GetUid() string {
return "" return ""
} }
type RetryActionWorkspaceRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"`
}
func (x *RetryActionWorkspaceRequest) Reset() {
*x = RetryActionWorkspaceRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_workspace_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RetryActionWorkspaceRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RetryActionWorkspaceRequest) ProtoMessage() {}
func (x *RetryActionWorkspaceRequest) ProtoReflect() protoreflect.Message {
mi := &file_workspace_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RetryActionWorkspaceRequest.ProtoReflect.Descriptor instead.
func (*RetryActionWorkspaceRequest) Descriptor() ([]byte, []int) {
return file_workspace_proto_rawDescGZIP(), []int{13}
}
func (x *RetryActionWorkspaceRequest) GetNamespace() string {
if x != nil {
return x.Namespace
}
return ""
}
func (x *RetryActionWorkspaceRequest) GetUid() string {
if x != nil {
return x.Uid
}
return ""
}
var File_workspace_proto protoreflect.FileDescriptor var File_workspace_proto protoreflect.FileDescriptor
var file_workspace_proto_rawDesc = []byte{ var file_workspace_proto_rawDesc = []byte{
@@ -1012,71 +1067,85 @@ var file_workspace_proto_rawDesc = []byte{
0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61,
0x63, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x63, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x75, 0x69, 0x64, 0x32, 0x86, 0x08, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x03, 0x75, 0x69, 0x64, 0x22, 0x4d, 0x0a, 0x1b, 0x52, 0x65, 0x74, 0x72, 0x79, 0x41, 0x63, 0x74,
0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x72, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x69, 0x6f, 0x6e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75,
0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1b, 0x2e, 0x61, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65,
0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63,
0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x75, 0x69, 0x64, 0x32, 0x97, 0x09, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63,
0x2c, 0x22, 0x24, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x72, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61,
0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1b, 0x2e, 0x61, 0x70,
0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x6c, 0x0a, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63,
0x0c, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x18, 0x2e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x57,
0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x57, 0x6f, 0x22, 0x24, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f,
0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x12, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b,
0x2a, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x6c, 0x0a, 0x0c,
0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x18, 0x2e, 0x61,
0x70, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x12, 0x75, 0x0a, 0x0e, 0x4c, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52,
0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x57, 0x6f, 0x72,
0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x12, 0x2a,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e,
0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x26, 0x12, 0x24, 0x2f, 0x61, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x12, 0x75, 0x0a, 0x0e, 0x4c, 0x69,
0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x61,
0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65,
0x65, 0x73, 0x12, 0x95, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69,
0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x2e, 0x61, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x70, 0x69, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x26, 0x12, 0x24, 0x2f, 0x61, 0x70,
0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x41, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3b, 0x1a,
0x31, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b,
0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73,
0x70, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x2f, 0x73, 0x74, 0x61, 0x74,
0x75, 0x73, 0x3a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x80, 0x01, 0x0a, 0x0f, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1b,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73,
0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d,
0x70, 0x74, 0x79, 0x22, 0x38, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x32, 0x1a, 0x2a, 0x2f, 0x61, 0x70,
0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65,
0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65,
0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x7e, 0x0a, 0x73, 0x12, 0x95, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b,
0x0e, 0x50, 0x61, 0x75, 0x73, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x2e, 0x61, 0x70,
0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x75, 0x73, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x69, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63,
0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x41, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3b, 0x1a, 0x31,
0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e,
0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70,
0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75,
0x73, 0x3a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x80, 0x01, 0x0a, 0x0f, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1b, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70,
0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70,
0x74, 0x79, 0x22, 0x38, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x32, 0x1a, 0x2a, 0x2f, 0x61, 0x70, 0x69,
0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x73,
0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73,
0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x7e, 0x0a, 0x0e,
0x50, 0x61, 0x75, 0x73, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1a,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x75, 0x73, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70,
0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70,
0x74, 0x79, 0x22, 0x38, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x32, 0x1a, 0x30, 0x2f, 0x61, 0x70, 0x69,
0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x73,
0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73,
0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x2f, 0x70, 0x61, 0x75, 0x73, 0x65, 0x12, 0x81, 0x01, 0x0a,
0x0f, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65,
0x12, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x57, 0x6f, 0x72,
0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x39, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x33, 0x1a, 0x31, 0x2f,
0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e, 0x61,
0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61,
0x63, 0x65, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x2f, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65,
0x12, 0x7a, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70,
0x61, 0x63, 0x65, 0x12, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c,
0x2a, 0x2a, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f,
0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b,
0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x12, 0x8e, 0x01, 0x0a,
0x18, 0x52, 0x65, 0x74, 0x72, 0x79, 0x4c, 0x61, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70,
0x61, 0x63, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x52, 0x65, 0x74, 0x72, 0x79, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x6f, 0x72, 0x6b, 0x73,
0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d,
0x70, 0x74, 0x79, 0x22, 0x38, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x32, 0x1a, 0x30, 0x2f, 0x61, 0x70, 0x70, 0x74, 0x79, 0x22, 0x38, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x32, 0x1a, 0x30, 0x2f, 0x61, 0x70,
0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65,
0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65,
0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x2f, 0x70, 0x61, 0x75, 0x73, 0x65, 0x12, 0x81, 0x01, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x2f, 0x72, 0x65, 0x74, 0x72, 0x79, 0x62, 0x06, 0x70,
0x0a, 0x0f, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63,
0x65, 0x12, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x57, 0x6f,
0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x39, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x33, 0x1a, 0x31,
0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x7b, 0x6e,
0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70,
0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x2f, 0x72, 0x65, 0x73, 0x75, 0x6d,
0x65, 0x12, 0x7a, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73,
0x70, 0x61, 0x63, 0x65, 0x12, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02,
0x2c, 0x2a, 0x2a, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x77, 0x6f, 0x72,
0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
@@ -1092,7 +1161,7 @@ func file_workspace_proto_rawDescGZIP() []byte {
return file_workspace_proto_rawDescData return file_workspace_proto_rawDescData
} }
var file_workspace_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_workspace_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_workspace_proto_goTypes = []interface{}{ var file_workspace_proto_goTypes = []interface{}{
(*Workspace)(nil), // 0: api.Workspace (*Workspace)(nil), // 0: api.Workspace
(*WorkspaceStatus)(nil), // 1: api.WorkspaceStatus (*WorkspaceStatus)(nil), // 1: api.WorkspaceStatus
@@ -1107,23 +1176,24 @@ var file_workspace_proto_goTypes = []interface{}{
(*PauseWorkspaceRequest)(nil), // 10: api.PauseWorkspaceRequest (*PauseWorkspaceRequest)(nil), // 10: api.PauseWorkspaceRequest
(*ResumeWorkspaceRequest)(nil), // 11: api.ResumeWorkspaceRequest (*ResumeWorkspaceRequest)(nil), // 11: api.ResumeWorkspaceRequest
(*DeleteWorkspaceRequest)(nil), // 12: api.DeleteWorkspaceRequest (*DeleteWorkspaceRequest)(nil), // 12: api.DeleteWorkspaceRequest
(*Parameter)(nil), // 13: api.Parameter (*RetryActionWorkspaceRequest)(nil), // 13: api.RetryActionWorkspaceRequest
(*WorkspaceTemplate)(nil), // 14: api.WorkspaceTemplate (*Parameter)(nil), // 14: api.Parameter
(*KeyValue)(nil), // 15: api.KeyValue (*WorkspaceTemplate)(nil), // 15: api.WorkspaceTemplate
(*empty.Empty)(nil), // 16: google.protobuf.Empty (*KeyValue)(nil), // 16: api.KeyValue
(*empty.Empty)(nil), // 17: google.protobuf.Empty
} }
var file_workspace_proto_depIdxs = []int32{ var file_workspace_proto_depIdxs = []int32{
13, // 0: api.Workspace.parameters:type_name -> api.Parameter 14, // 0: api.Workspace.parameters:type_name -> api.Parameter
14, // 1: api.Workspace.workspaceTemplate:type_name -> api.WorkspaceTemplate 15, // 1: api.Workspace.workspaceTemplate:type_name -> api.WorkspaceTemplate
1, // 2: api.Workspace.status:type_name -> api.WorkspaceStatus 1, // 2: api.Workspace.status:type_name -> api.WorkspaceStatus
15, // 3: api.Workspace.labels:type_name -> api.KeyValue 16, // 3: api.Workspace.labels:type_name -> api.KeyValue
13, // 4: api.Workspace.templateParameters:type_name -> api.Parameter 14, // 4: api.Workspace.templateParameters:type_name -> api.Parameter
13, // 5: api.CreateWorkspaceBody.parameters:type_name -> api.Parameter 14, // 5: api.CreateWorkspaceBody.parameters:type_name -> api.Parameter
15, // 6: api.CreateWorkspaceBody.labels:type_name -> api.KeyValue 16, // 6: api.CreateWorkspaceBody.labels:type_name -> api.KeyValue
2, // 7: api.CreateWorkspaceRequest.body:type_name -> api.CreateWorkspaceBody 2, // 7: api.CreateWorkspaceRequest.body:type_name -> api.CreateWorkspaceBody
1, // 8: api.UpdateWorkspaceStatusRequest.status:type_name -> api.WorkspaceStatus 1, // 8: api.UpdateWorkspaceStatusRequest.status:type_name -> api.WorkspaceStatus
13, // 9: api.UpdateWorkspaceBody.parameters:type_name -> api.Parameter 14, // 9: api.UpdateWorkspaceBody.parameters:type_name -> api.Parameter
15, // 10: api.UpdateWorkspaceBody.labels:type_name -> api.KeyValue 16, // 10: api.UpdateWorkspaceBody.labels:type_name -> api.KeyValue
6, // 11: api.UpdateWorkspaceRequest.body:type_name -> api.UpdateWorkspaceBody 6, // 11: api.UpdateWorkspaceRequest.body:type_name -> api.UpdateWorkspaceBody
0, // 12: api.ListWorkspaceResponse.workspaces:type_name -> api.Workspace 0, // 12: api.ListWorkspaceResponse.workspaces:type_name -> api.Workspace
3, // 13: api.WorkspaceService.CreateWorkspace:input_type -> api.CreateWorkspaceRequest 3, // 13: api.WorkspaceService.CreateWorkspace:input_type -> api.CreateWorkspaceRequest
@@ -1134,16 +1204,18 @@ var file_workspace_proto_depIdxs = []int32{
10, // 18: api.WorkspaceService.PauseWorkspace:input_type -> api.PauseWorkspaceRequest 10, // 18: api.WorkspaceService.PauseWorkspace:input_type -> api.PauseWorkspaceRequest
11, // 19: api.WorkspaceService.ResumeWorkspace:input_type -> api.ResumeWorkspaceRequest 11, // 19: api.WorkspaceService.ResumeWorkspace:input_type -> api.ResumeWorkspaceRequest
12, // 20: api.WorkspaceService.DeleteWorkspace:input_type -> api.DeleteWorkspaceRequest 12, // 20: api.WorkspaceService.DeleteWorkspace:input_type -> api.DeleteWorkspaceRequest
0, // 21: api.WorkspaceService.CreateWorkspace:output_type -> api.Workspace 13, // 21: api.WorkspaceService.RetryLastWorkspaceAction:input_type -> api.RetryActionWorkspaceRequest
0, // 22: api.WorkspaceService.GetWorkspace:output_type -> api.Workspace 0, // 22: api.WorkspaceService.CreateWorkspace:output_type -> api.Workspace
9, // 23: api.WorkspaceService.ListWorkspaces:output_type -> api.ListWorkspaceResponse 0, // 23: api.WorkspaceService.GetWorkspace:output_type -> api.Workspace
16, // 24: api.WorkspaceService.UpdateWorkspaceStatus:output_type -> google.protobuf.Empty 9, // 24: api.WorkspaceService.ListWorkspaces:output_type -> api.ListWorkspaceResponse
16, // 25: api.WorkspaceService.UpdateWorkspace:output_type -> google.protobuf.Empty 17, // 25: api.WorkspaceService.UpdateWorkspaceStatus:output_type -> google.protobuf.Empty
16, // 26: api.WorkspaceService.PauseWorkspace:output_type -> google.protobuf.Empty 17, // 26: api.WorkspaceService.UpdateWorkspace:output_type -> google.protobuf.Empty
16, // 27: api.WorkspaceService.ResumeWorkspace:output_type -> google.protobuf.Empty 17, // 27: api.WorkspaceService.PauseWorkspace:output_type -> google.protobuf.Empty
16, // 28: api.WorkspaceService.DeleteWorkspace:output_type -> google.protobuf.Empty 17, // 28: api.WorkspaceService.ResumeWorkspace:output_type -> google.protobuf.Empty
21, // [21:29] is the sub-list for method output_type 17, // 29: api.WorkspaceService.DeleteWorkspace:output_type -> google.protobuf.Empty
13, // [13:21] is the sub-list for method input_type 17, // 30: api.WorkspaceService.RetryLastWorkspaceAction:output_type -> google.protobuf.Empty
22, // [22:31] is the sub-list for method output_type
13, // [13:22] is the sub-list for method input_type
13, // [13:13] is the sub-list for extension type_name 13, // [13:13] is the sub-list for extension type_name
13, // [13:13] is the sub-list for extension extendee 13, // [13:13] is the sub-list for extension extendee
0, // [0:13] is the sub-list for field type_name 0, // [0:13] is the sub-list for field type_name
@@ -1314,6 +1386,18 @@ func file_workspace_proto_init() {
return nil return nil
} }
} }
file_workspace_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RetryActionWorkspaceRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@@ -1321,7 +1405,7 @@ func file_workspace_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_workspace_proto_rawDesc, RawDescriptor: file_workspace_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 13, NumMessages: 14,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },
@@ -1355,6 +1439,7 @@ type WorkspaceServiceClient interface {
PauseWorkspace(ctx context.Context, in *PauseWorkspaceRequest, opts ...grpc.CallOption) (*empty.Empty, error) PauseWorkspace(ctx context.Context, in *PauseWorkspaceRequest, opts ...grpc.CallOption) (*empty.Empty, error)
ResumeWorkspace(ctx context.Context, in *ResumeWorkspaceRequest, opts ...grpc.CallOption) (*empty.Empty, error) ResumeWorkspace(ctx context.Context, in *ResumeWorkspaceRequest, opts ...grpc.CallOption) (*empty.Empty, error)
DeleteWorkspace(ctx context.Context, in *DeleteWorkspaceRequest, opts ...grpc.CallOption) (*empty.Empty, error) DeleteWorkspace(ctx context.Context, in *DeleteWorkspaceRequest, opts ...grpc.CallOption) (*empty.Empty, error)
RetryLastWorkspaceAction(ctx context.Context, in *RetryActionWorkspaceRequest, opts ...grpc.CallOption) (*empty.Empty, error)
} }
type workspaceServiceClient struct { type workspaceServiceClient struct {
@@ -1437,6 +1522,15 @@ func (c *workspaceServiceClient) DeleteWorkspace(ctx context.Context, in *Delete
return out, nil return out, nil
} }
func (c *workspaceServiceClient) RetryLastWorkspaceAction(ctx context.Context, in *RetryActionWorkspaceRequest, opts ...grpc.CallOption) (*empty.Empty, error) {
out := new(empty.Empty)
err := c.cc.Invoke(ctx, "/api.WorkspaceService/RetryLastWorkspaceAction", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// WorkspaceServiceServer is the server API for WorkspaceService service. // WorkspaceServiceServer is the server API for WorkspaceService service.
type WorkspaceServiceServer interface { type WorkspaceServiceServer interface {
CreateWorkspace(context.Context, *CreateWorkspaceRequest) (*Workspace, error) CreateWorkspace(context.Context, *CreateWorkspaceRequest) (*Workspace, error)
@@ -1447,6 +1541,7 @@ type WorkspaceServiceServer interface {
PauseWorkspace(context.Context, *PauseWorkspaceRequest) (*empty.Empty, error) PauseWorkspace(context.Context, *PauseWorkspaceRequest) (*empty.Empty, error)
ResumeWorkspace(context.Context, *ResumeWorkspaceRequest) (*empty.Empty, error) ResumeWorkspace(context.Context, *ResumeWorkspaceRequest) (*empty.Empty, error)
DeleteWorkspace(context.Context, *DeleteWorkspaceRequest) (*empty.Empty, error) DeleteWorkspace(context.Context, *DeleteWorkspaceRequest) (*empty.Empty, error)
RetryLastWorkspaceAction(context.Context, *RetryActionWorkspaceRequest) (*empty.Empty, error)
} }
// UnimplementedWorkspaceServiceServer can be embedded to have forward compatible implementations. // UnimplementedWorkspaceServiceServer can be embedded to have forward compatible implementations.
@@ -1477,6 +1572,9 @@ func (*UnimplementedWorkspaceServiceServer) ResumeWorkspace(context.Context, *Re
func (*UnimplementedWorkspaceServiceServer) DeleteWorkspace(context.Context, *DeleteWorkspaceRequest) (*empty.Empty, error) { func (*UnimplementedWorkspaceServiceServer) DeleteWorkspace(context.Context, *DeleteWorkspaceRequest) (*empty.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteWorkspace not implemented") return nil, status.Errorf(codes.Unimplemented, "method DeleteWorkspace not implemented")
} }
func (*UnimplementedWorkspaceServiceServer) RetryLastWorkspaceAction(context.Context, *RetryActionWorkspaceRequest) (*empty.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method RetryLastWorkspaceAction not implemented")
}
func RegisterWorkspaceServiceServer(s *grpc.Server, srv WorkspaceServiceServer) { func RegisterWorkspaceServiceServer(s *grpc.Server, srv WorkspaceServiceServer) {
s.RegisterService(&_WorkspaceService_serviceDesc, srv) s.RegisterService(&_WorkspaceService_serviceDesc, srv)
@@ -1626,6 +1724,24 @@ func _WorkspaceService_DeleteWorkspace_Handler(srv interface{}, ctx context.Cont
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _WorkspaceService_RetryLastWorkspaceAction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RetryActionWorkspaceRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WorkspaceServiceServer).RetryLastWorkspaceAction(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/api.WorkspaceService/RetryLastWorkspaceAction",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WorkspaceServiceServer).RetryLastWorkspaceAction(ctx, req.(*RetryActionWorkspaceRequest))
}
return interceptor(ctx, in, info, handler)
}
var _WorkspaceService_serviceDesc = grpc.ServiceDesc{ var _WorkspaceService_serviceDesc = grpc.ServiceDesc{
ServiceName: "api.WorkspaceService", ServiceName: "api.WorkspaceService",
HandlerType: (*WorkspaceServiceServer)(nil), HandlerType: (*WorkspaceServiceServer)(nil),
@@ -1662,6 +1778,10 @@ var _WorkspaceService_serviceDesc = grpc.ServiceDesc{
MethodName: "DeleteWorkspace", MethodName: "DeleteWorkspace",
Handler: _WorkspaceService_DeleteWorkspace_Handler, Handler: _WorkspaceService_DeleteWorkspace_Handler,
}, },
{
MethodName: "RetryLastWorkspaceAction",
Handler: _WorkspaceService_RetryLastWorkspaceAction_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "workspace.proto", Metadata: "workspace.proto",

View File

@@ -658,6 +658,82 @@ func local_request_WorkspaceService_DeleteWorkspace_0(ctx context.Context, marsh
} }
func request_WorkspaceService_RetryLastWorkspaceAction_0(ctx context.Context, marshaler runtime.Marshaler, client WorkspaceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq RetryActionWorkspaceRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["namespace"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace")
}
protoReq.Namespace, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace", err)
}
val, ok = pathParams["uid"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uid")
}
protoReq.Uid, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uid", err)
}
msg, err := client.RetryLastWorkspaceAction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_WorkspaceService_RetryLastWorkspaceAction_0(ctx context.Context, marshaler runtime.Marshaler, server WorkspaceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq RetryActionWorkspaceRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["namespace"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace")
}
protoReq.Namespace, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace", err)
}
val, ok = pathParams["uid"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uid")
}
protoReq.Uid, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uid", err)
}
msg, err := server.RetryLastWorkspaceAction(ctx, &protoReq)
return msg, metadata, err
}
// RegisterWorkspaceServiceHandlerServer registers the http handlers for service WorkspaceService to "mux". // RegisterWorkspaceServiceHandlerServer registers the http handlers for service WorkspaceService to "mux".
// UnaryRPC :call WorkspaceServiceServer directly. // UnaryRPC :call WorkspaceServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -823,6 +899,26 @@ func RegisterWorkspaceServiceHandlerServer(ctx context.Context, mux *runtime.Ser
}) })
mux.Handle("PUT", pattern_WorkspaceService_RetryLastWorkspaceAction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_WorkspaceService_RetryLastWorkspaceAction_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_WorkspaceService_RetryLastWorkspaceAction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
@@ -1024,6 +1120,26 @@ func RegisterWorkspaceServiceHandlerClient(ctx context.Context, mux *runtime.Ser
}) })
mux.Handle("PUT", pattern_WorkspaceService_RetryLastWorkspaceAction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WorkspaceService_RetryLastWorkspaceAction_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_WorkspaceService_RetryLastWorkspaceAction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
@@ -1043,6 +1159,8 @@ var (
pattern_WorkspaceService_ResumeWorkspace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"apis", "v1beta1", "namespace", "workspaces", "uid", "resume"}, "", runtime.AssumeColonVerbOpt(true))) pattern_WorkspaceService_ResumeWorkspace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"apis", "v1beta1", "namespace", "workspaces", "uid", "resume"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_WorkspaceService_DeleteWorkspace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"apis", "v1beta1", "namespace", "workspaces", "uid"}, "", runtime.AssumeColonVerbOpt(true))) pattern_WorkspaceService_DeleteWorkspace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"apis", "v1beta1", "namespace", "workspaces", "uid"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_WorkspaceService_RetryLastWorkspaceAction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"apis", "v1beta1", "namespace", "workspaces", "uid", "retry"}, "", runtime.AssumeColonVerbOpt(true)))
) )
var ( var (
@@ -1061,4 +1179,6 @@ var (
forward_WorkspaceService_ResumeWorkspace_0 = runtime.ForwardResponseMessage forward_WorkspaceService_ResumeWorkspace_0 = runtime.ForwardResponseMessage
forward_WorkspaceService_DeleteWorkspace_0 = runtime.ForwardResponseMessage forward_WorkspaceService_DeleteWorkspace_0 = runtime.ForwardResponseMessage
forward_WorkspaceService_RetryLastWorkspaceAction_0 = runtime.ForwardResponseMessage
) )

View File

@@ -59,6 +59,12 @@ service WorkspaceService {
delete: "/apis/v1beta1/{namespace}/workspaces/{uid}" delete: "/apis/v1beta1/{namespace}/workspaces/{uid}"
}; };
} }
rpc RetryLastWorkspaceAction (RetryActionWorkspaceRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
put: "/apis/v1beta1/{namespace}/workspaces/{uid}/retry"
};
}
} }
message Workspace { message Workspace {
@@ -145,3 +151,8 @@ message DeleteWorkspaceRequest {
string namespace = 1; string namespace = 1;
string uid = 2; string uid = 2;
} }
message RetryActionWorkspaceRequest {
string namespace = 1;
string uid = 2;
}

36
pkg/util/router/api.go Normal file
View File

@@ -0,0 +1,36 @@
package router
import "fmt"
// API provides methods to generate urls for the API
type API interface {
UpdateWorkspaceStatus(namespace, uid string) string
}
// api is a basic implementation of router.API
type api struct {
protocol string
fqdn string
}
// UpdateWorkspaceStatus generates a url to update the status of a workspace
func (a *api) UpdateWorkspaceStatus(namespace, uid string) string {
// <protocol><fqdn>/apis/v1beta1/{namespace}/workspaces/{uid}/status
return fmt.Sprintf("%v%v/apis/v1beta1/%v/workspaces/%v/status", a.protocol, a.fqdn, namespace, uid)
}
// NewAPIRouter creates a new api router used to generate urls for the api
func NewAPIRouter(protocol, fqdn string) (API, error) {
return &api{
protocol: protocol,
fqdn: fqdn,
}, nil
}
// NewRelativeAPIRouter creates an api router that does relative routes, with no protocol or fqdn
func NewRelativeAPIRouter() (API, error) {
return &api{
protocol: "",
fqdn: "",
}, nil
}

View File

@@ -10,7 +10,7 @@ type Web interface {
WorkflowExecution(namespace, uid string) string WorkflowExecution(namespace, uid string) string
} }
// web is a basic implementation of WebRouter // web is a basic implementation of router.Web
type web struct { type web struct {
protocol string protocol string
fqdn string fqdn string
@@ -18,7 +18,7 @@ type web struct {
// WorkflowExecution generates a url to view a specific workflow // WorkflowExecution generates a url to view a specific workflow
func (w *web) WorkflowExecution(namespace, uid string) string { func (w *web) WorkflowExecution(namespace, uid string) string {
// <protocol>:<fqdn>/<namespace>/workflows/<uid> // <protocol><fqdn>/<namespace>/workflows/<uid>
return fmt.Sprintf("%v%v/%v/workflows/%v", w.protocol, w.fqdn, namespace, uid) return fmt.Sprintf("%v%v/%v/workflows/%v", w.protocol, w.fqdn, namespace, uid)
} }
@@ -29,3 +29,11 @@ func NewWebRouter(protocol, fqdn string) (Web, error) {
fqdn: fqdn, fqdn: fqdn,
}, nil }, nil
} }
// NewRelativeWebRouter creates a web router that does relative routes, with no protocol or fqdn
func NewRelativeWebRouter() (Web, error) {
return &web{
protocol: "",
fqdn: "",
}, nil
}

View File

@@ -43,20 +43,16 @@ func workspaceStatusToFieldMap(status *WorkspaceStatus) sq.Eq {
case WorkspaceLaunching: case WorkspaceLaunching:
fieldMap["paused_at"] = pq.NullTime{} fieldMap["paused_at"] = pq.NullTime{}
fieldMap["started_at"] = time.Now().UTC() fieldMap["started_at"] = time.Now().UTC()
break
case WorkspacePausing: case WorkspacePausing:
fieldMap["started_at"] = pq.NullTime{} fieldMap["started_at"] = pq.NullTime{}
fieldMap["paused_at"] = time.Now().UTC() fieldMap["paused_at"] = time.Now().UTC()
break
case WorkspaceUpdating: case WorkspaceUpdating:
fieldMap["paused_at"] = pq.NullTime{} fieldMap["paused_at"] = pq.NullTime{}
fieldMap["updated_at"] = time.Now().UTC() fieldMap["updated_at"] = time.Now().UTC()
break
case WorkspaceTerminating: case WorkspaceTerminating:
fieldMap["started_at"] = pq.NullTime{} fieldMap["started_at"] = pq.NullTime{}
fieldMap["paused_at"] = pq.NullTime{} fieldMap["paused_at"] = pq.NullTime{}
fieldMap["terminated_at"] = time.Now().UTC() fieldMap["terminated_at"] = time.Now().UTC()
break
} }
return fieldMap return fieldMap
@@ -66,6 +62,13 @@ func workspaceStatusToFieldMap(status *WorkspaceStatus) sq.Eq {
func updateWorkspaceStatusBuilder(namespace, uid string, status *WorkspaceStatus) sq.UpdateBuilder { func updateWorkspaceStatusBuilder(namespace, uid string, status *WorkspaceStatus) sq.UpdateBuilder {
fieldMap := workspaceStatusToFieldMap(status) fieldMap := workspaceStatusToFieldMap(status)
log.WithFields(log.Fields{
"Namespace": namespace,
"Workspace": uid,
"Final Phase": fieldMap["phase"],
}).Info("Updating workspace status")
// Failed, Error, Succeeded
ub := sb.Update("workspaces"). ub := sb.Update("workspaces").
SetMap(fieldMap). SetMap(fieldMap).
Where(sq.And{ Where(sq.And{
@@ -215,17 +218,99 @@ func (c *Client) createWorkspace(namespace string, parameters []byte, workspace
return workspace, nil return workspace, nil
} }
// CreateWorkspace creates a workspace by triggering the corresponding workflow // startWorkspace starts a workspace and related resources. It assumes a DB record already exists
func (c *Client) CreateWorkspace(namespace string, workspace *Workspace) (*Workspace, error) { // The following are required on the workspace:
config, err := c.GetSystemConfig() // WorkspaceTemplate.WorkflowTemplate.UID
// WorkspaceTemplate.WorkflowTemplate.Version
func (c *Client) startWorkspace(namespace string, parameters []byte, workspace *Workspace) (*Workspace, error) {
if workspace == nil {
return nil, fmt.Errorf("workspace is nil")
}
if workspace.WorkspaceTemplate == nil {
return nil, fmt.Errorf("workspace.WorkspaceTemplate is nil")
}
if workspace.WorkspaceTemplate.WorkflowTemplate == nil {
return nil, fmt.Errorf("workspace.WorkspaceTemplate.WorkflowTemplate is nil")
}
systemConfig, err := c.GetSystemConfig()
if err != nil { if err != nil {
return nil, err return nil, err
} }
workflowTemplate, err := c.GetWorkflowTemplate(namespace, workspace.WorkspaceTemplate.WorkflowTemplate.UID, workspace.WorkspaceTemplate.WorkflowTemplate.Version)
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
"Workspace": workspace,
"Error": err.Error(),
}).Error("Error with getting workflow template.")
return nil, util.NewUserError(codes.NotFound, "Error with getting workflow template.")
}
runtimeParameters, err := generateRuntimeParameters(systemConfig)
if err != nil {
return nil, err
}
runtimeParametersMap := make(map[string]*string)
for _, p := range runtimeParameters {
runtimeParametersMap[p.Name] = p.Value
}
argoTemplate := workflowTemplate.ArgoWorkflowTemplate
for i, p := range argoTemplate.Spec.Arguments.Parameters {
value := runtimeParametersMap[p.Name]
if value != nil {
argoTemplate.Spec.Arguments.Parameters[i].Value = value
}
}
_, err = c.CreateWorkflowExecution(namespace, &WorkflowExecution{
Parameters: workspace.Parameters,
}, workflowTemplate)
if err != nil {
return nil, err
}
_, err = sb.Update("workspaces").
SetMap(sq.Eq{
"phase": WorkspaceLaunching,
"started_at": time.Now().UTC(),
}).
Where(sq.Eq{"id": workspace.ID}).
RunWith(c.DB).
Exec()
if err != nil {
if strings.Contains(err.Error(), "invalid input syntax for type json") {
return nil, util.NewUserError(codes.InvalidArgument, err.Error())
}
return nil, util.NewUserError(codes.Unknown, err.Error())
}
return workspace, nil
}
// CreateWorkspace creates a workspace by triggering the corresponding workflow
func (c *Client) CreateWorkspace(namespace string, workspace *Workspace) (*Workspace, error) {
if err := workspace.GenerateUID(workspace.Name); err != nil { if err := workspace.GenerateUID(workspace.Name); err != nil {
return nil, err return nil, err
} }
existingWorkspace, err := c.GetWorkspace(namespace, workspace.UID)
if err != nil {
return nil, err
}
if existingWorkspace != nil {
return nil, util.NewUserError(codes.AlreadyExists, "Workspace already exists.")
}
config, err := c.GetSystemConfig()
if err != nil {
return nil, err
}
parameters, err := json.Marshal(workspace.Parameters) parameters, err := json.Marshal(workspace.Parameters)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -245,12 +330,55 @@ func (c *Client) CreateWorkspace(namespace string, workspace *Workspace) (*Works
return nil, fmt.Errorf("sys-host parameter not found") return nil, fmt.Errorf("sys-host parameter not found")
} }
existingWorkspace, err := c.GetWorkspace(namespace, workspace.UID) // Validate workspace fields
valid, err := govalidator.ValidateStruct(workspace)
if err != nil || !valid {
return nil, util.NewUserError(codes.InvalidArgument, err.Error())
}
workspaceTemplate, err := c.GetWorkspaceTemplate(namespace, workspace.WorkspaceTemplate.UID, workspace.WorkspaceTemplate.Version)
if err != nil || workspaceTemplate == nil {
return nil, util.NewUserError(codes.NotFound, "Workspace template not found.")
}
workspace.WorkspaceTemplate = workspaceTemplate
workspace, err = c.createWorkspace(namespace, parameters, workspace)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if existingWorkspace != nil {
return nil, util.NewUserError(codes.AlreadyExists, "Workspace already exists.") return workspace, nil
}
// StartWorkspace starts a workspace
func (c *Client) StartWorkspace(namespace string, workspace *Workspace) (*Workspace, error) {
// If already started and not failed, return an error
if workspace.ID != 0 && workspace.Status.Phase != WorkspaceFailedToLaunch {
return workspace, fmt.Errorf("unable to start a workspace with phase %v", workspace.Status.Phase)
}
config, err := c.GetSystemConfig()
if err != nil {
return nil, err
}
parameters, err := json.Marshal(workspace.Parameters)
if err != nil {
return nil, err
}
err = injectWorkspaceSystemParameters(namespace, workspace, "create", "apply", config)
if err != nil {
return nil, err
}
workspace.Parameters = append(workspace.Parameters, Parameter{
Name: "sys-uid",
Value: ptr.String(workspace.UID),
})
sysHost := workspace.GetParameterValue("sys-host")
if sysHost == nil {
return nil, fmt.Errorf("sys-host parameter not found")
} }
// Validate workspace fields // Validate workspace fields
@@ -265,7 +393,7 @@ func (c *Client) CreateWorkspace(namespace string, workspace *Workspace) (*Works
} }
workspace.WorkspaceTemplate = workspaceTemplate workspace.WorkspaceTemplate = workspaceTemplate
workspace, err = c.createWorkspace(namespace, parameters, workspace) workspace, err = c.startWorkspace(namespace, parameters, workspace)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -312,6 +440,30 @@ func (c *Client) GetWorkspace(namespace, uid string) (workspace *Workspace, err
// UpdateWorkspaceStatus updates workspace status and times based on phase // UpdateWorkspaceStatus updates workspace status and times based on phase
func (c *Client) UpdateWorkspaceStatus(namespace, uid string, status *WorkspaceStatus) (err error) { func (c *Client) UpdateWorkspaceStatus(namespace, uid string, status *WorkspaceStatus) (err error) {
// A succeeded status is passed in when a DAG succeeds. We don't need to do anything in this case.
if status.Phase == "Succeeded" {
return nil
}
if status.Phase == "Failed" || status.Phase == "Error" {
workspace, err := c.GetWorkspace(namespace, uid)
if err != nil {
return err
}
if workspace.Status.Phase == WorkspaceLaunching && workspace.Status.PausedAt == nil {
status.Phase = WorkspaceFailedToLaunch
} else if workspace.Status.Phase == WorkspaceLaunching && workspace.Status.PausedAt != nil {
status.Phase = WorkspaceFailedToResume
} else if workspace.Status.Phase == WorkspacePausing {
status.Phase = WorkspaceFailedToPause
} else if workspace.Status.Phase == WorkspaceTerminating {
status.Phase = WorkspaceFailedToTerminate
} else if workspace.Status.Phase == WorkspaceUpdating {
status.Phase = WorkspaceFailedToUpdate
}
}
result, err := updateWorkspaceStatusBuilder(namespace, uid, status). result, err := updateWorkspaceStatusBuilder(namespace, uid, status).
RunWith(c.DB). RunWith(c.DB).
Exec() Exec()

View File

@@ -12,6 +12,7 @@ import (
"github.com/onepanelio/core/pkg/util/env" "github.com/onepanelio/core/pkg/util/env"
"github.com/onepanelio/core/pkg/util/pagination" "github.com/onepanelio/core/pkg/util/pagination"
"github.com/onepanelio/core/pkg/util/ptr" "github.com/onepanelio/core/pkg/util/ptr"
"github.com/onepanelio/core/pkg/util/router"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
networking "istio.io/api/networking/v1alpha3" networking "istio.io/api/networking/v1alpha3"
@@ -468,6 +469,17 @@ metadata:
name: {{inputs.parameters.sys-pvc-name}}-{{workflow.parameters.sys-uid}}-0 name: {{inputs.parameters.sys-pvc-name}}-{{workflow.parameters.sys-uid}}-0
` `
templates := []wfv1.Template{ templates := []wfv1.Template{
{
Name: "handleExit",
DAG: &wfv1.DAGTemplate{
Tasks: []wfv1.DAGTask{
{
Name: "exit-handler",
Template: "sys-update-workspace-status",
},
},
},
},
{ {
Name: "workspace", Name: "workspace",
DAG: &wfv1.DAGTemplate{ DAG: &wfv1.DAGTemplate{
@@ -648,16 +660,36 @@ metadata:
}, },
}, },
} }
// Add curl template
curlPath := fmt.Sprintf("/apis/v1beta1/{{workflow.namespace}}/workspaces/{{workflow.parameters.sys-uid}}/status") webRouter, err := router.NewRelativeAPIRouter()
if err != nil {
return "", err
}
curlUpdateWorkspaceStatusPath := webRouter.UpdateWorkspaceStatus("{{workflow.namespace}}", "{{workflow.parameters.sys-uid}}")
status := map[string]interface{}{ status := map[string]interface{}{
"phase": "{{inputs.parameters.sys-workspace-phase}}", "phase": "{{workflow.status}}",
} }
statusBytes, err := json.Marshal(status) statusBytes, err := json.Marshal(status)
if err != nil { if err != nil {
return return
} }
inputs := wfv1.Inputs{ inputs := wfv1.Inputs{}
curlUpdateWorkspaceNodeTemplate, err := getCURLNodeTemplate("sys-update-workspace-status", http.MethodPut, curlUpdateWorkspaceStatusPath, string(statusBytes), inputs)
if err != nil {
return
}
templates = append(templates, *curlUpdateWorkspaceNodeTemplate)
// Add curl template
curlPath := fmt.Sprintf("/apis/v1beta1/{{workflow.namespace}}/workspaces/{{workflow.parameters.sys-uid}}/status")
status = map[string]interface{}{
"phase": "{{inputs.parameters.sys-workspace-phase}}",
}
statusBytes, err = json.Marshal(status)
if err != nil {
return
}
inputs = wfv1.Inputs{
Parameters: []wfv1.Parameter{ Parameters: []wfv1.Parameter{
{Name: "sys-workspace-phase"}, {Name: "sys-workspace-phase"},
}, },
@@ -683,6 +715,7 @@ metadata:
workflowTemplateSpec := map[string]interface{}{ workflowTemplateSpec := map[string]interface{}{
"arguments": spec.Arguments, "arguments": spec.Arguments,
"entrypoint": "workspace", "entrypoint": "workspace",
"onExit": "handleExit",
"templates": templates, "templates": templates,
} }

View File

@@ -15,13 +15,18 @@ type WorkspacePhase string
// Workspace phases // Workspace phases
const ( const (
WorkspaceLaunching WorkspacePhase = "Launching" WorkspaceLaunching WorkspacePhase = "Launching"
WorkspaceRunning WorkspacePhase = "Running" WorkspaceRunning WorkspacePhase = "Running"
WorkspaceUpdating WorkspacePhase = "Updating" WorkspaceUpdating WorkspacePhase = "Updating"
WorkspacePausing WorkspacePhase = "Pausing" WorkspacePausing WorkspacePhase = "Pausing"
WorkspacePaused WorkspacePhase = "Paused" WorkspacePaused WorkspacePhase = "Paused"
WorkspaceTerminating WorkspacePhase = "Terminating" WorkspaceTerminating WorkspacePhase = "Terminating"
WorkspaceTerminated WorkspacePhase = "Terminated" WorkspaceTerminated WorkspacePhase = "Terminated"
WorkspaceFailedToPause WorkspacePhase = "Failed to pause"
WorkspaceFailedToResume WorkspacePhase = "Failed to resume"
WorkspaceFailedToTerminate WorkspacePhase = "Failed to terminate"
WorkspaceFailedToLaunch WorkspacePhase = "Failed to launch"
WorkspaceFailedToUpdate WorkspacePhase = "Failed to upgrade"
) )
type WorkspaceStatus struct { type WorkspaceStatus struct {

View File

@@ -178,6 +178,9 @@ func (s *WorkflowServer) GetWorkflowExecution(ctx context.Context, req *api.GetW
if err != nil { if err != nil {
return nil, err return nil, err
} }
if wf == nil {
return nil, util.NewUserError(codes.NotFound, "Workflow not found")
}
wf.Namespace = req.Namespace wf.Namespace = req.Namespace

View File

@@ -177,6 +177,7 @@ func (s *WorkspaceServer) UpdateWorkspaceStatus(ctx context.Context, req *api.Up
status := &v1.WorkspaceStatus{ status := &v1.WorkspaceStatus{
Phase: v1.WorkspacePhase(req.Status.Phase), Phase: v1.WorkspacePhase(req.Status.Phase),
} }
err = client.UpdateWorkspaceStatus(req.Namespace, req.Uid, status) err = client.UpdateWorkspaceStatus(req.Namespace, req.Uid, status)
return &empty.Empty{}, err return &empty.Empty{}, err
@@ -276,3 +277,64 @@ func (s *WorkspaceServer) DeleteWorkspace(ctx context.Context, req *api.DeleteWo
return &empty.Empty{}, err return &empty.Empty{}, err
} }
// RetryLastWorkspaceAction will attempt the last action on the workspace again.
func (s *WorkspaceServer) RetryLastWorkspaceAction(ctx context.Context, req *api.RetryActionWorkspaceRequest) (*empty.Empty, error) {
client := getClient(ctx)
workspace, err := client.GetWorkspace(req.Namespace, req.Uid)
if err != nil {
return nil, err
}
if workspace == nil {
return nil, util.NewUserError(codes.NotFound, "workspace not found")
}
verb := ""
switch workspace.Status.Phase {
case v1.WorkspaceFailedToLaunch:
verb = "create"
case v1.WorkspaceFailedToPause:
verb = "update"
case v1.WorkspaceFailedToResume:
verb = "update"
case v1.WorkspaceFailedToTerminate:
verb = "delete"
case v1.WorkspaceFailedToUpdate:
verb = "update"
default:
return nil, util.NewUserError(codes.InvalidArgument, "Workspace is not in a failed state")
}
allowed, err := auth.IsAuthorized(client, req.Namespace, verb, "onepanel.io", "workspaces", req.Uid)
if err != nil || !allowed {
return &empty.Empty{}, err
}
switch workspace.Status.Phase {
case v1.WorkspaceFailedToLaunch:
if _, err := client.StartWorkspace(req.Namespace, workspace); err != nil {
return nil, err
}
case v1.WorkspaceFailedToPause:
if err := client.PauseWorkspace(req.Namespace, workspace.UID); err != nil {
return nil, err
}
case v1.WorkspaceFailedToResume:
if err := client.ResumeWorkspace(req.Namespace, workspace.UID); err != nil {
return nil, err
}
case v1.WorkspaceFailedToTerminate:
if err := client.DeleteWorkspace(req.Namespace, workspace.UID); err != nil {
return nil, err
}
case v1.WorkspaceFailedToUpdate:
if err := client.UpdateWorkspace(req.Namespace, workspace.UID, workspace.Parameters); err != nil {
return nil, err
}
default:
return nil, util.NewUserError(codes.InvalidArgument, "Workspace is not in a failed state")
}
return &empty.Empty{}, err
}