Skip to content

Commit

Permalink
[dhctl] (feat/dhctl-server): add abort, destroy, import, converge rpc
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Mayorov <ilya.mayorov@flant.com>
  • Loading branch information
distorhead authored and faroyam committed May 22, 2024
1 parent b6893ed commit a719d12
Show file tree
Hide file tree
Showing 34 changed files with 6,466 additions and 858 deletions.
6 changes: 5 additions & 1 deletion dhctl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ protoc:
pkg/server/api/dhctl/dhctl.proto \
pkg/server/api/dhctl/common.proto \
pkg/server/api/dhctl/check.proto \
pkg/server/api/dhctl/bootstrap.proto
pkg/server/api/dhctl/bootstrap.proto \
pkg/server/api/dhctl/destroy.proto \
pkg/server/api/dhctl/abort.proto \
pkg/server/api/dhctl/converge.proto \
pkg/server/api/dhctl/import.proto

generate: protoc
go generate ./...
Expand Down
3 changes: 2 additions & 1 deletion dhctl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/Masterminds/semver/v3 v3.2.1
github.com/Masterminds/sprig/v3 v3.2.3
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/alessio/shellescape v1.4.1
github.com/deckhouse/deckhouse/go_lib/registry-packages-proxy v0.0.0-00010101000000-000000000000
github.com/flant/addon-operator v1.3.12
Expand All @@ -30,7 +31,6 @@ require (
github.com/werf/logboek v0.5.5
go.cypherpunks.ru/gogost/v5 v5.13.0
golang.org/x/crypto v0.21.0
golang.org/x/sync v0.6.0
golang.org/x/term v0.18.0
google.golang.org/grpc v1.63.0
google.golang.org/protobuf v1.33.0
Expand Down Expand Up @@ -111,6 +111,7 @@ require (
go.mongodb.org/mongo-driver v1.5.4 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions dhctl/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBa
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/alecthomas/kingpin v1.3.8-0.20200323085623-b6657d9477a6 h1:nesv3dEn8GDv0ZMxkoCSvrxOE5KbzXXHtWEqJvYA/gw=
github.com/alecthomas/kingpin v1.3.8-0.20200323085623-b6657d9477a6/go.mod h1:b6br6/pDFSfMkBgC96TbpOji05q5pa+v5rIlS0Y6XtI=
Expand Down
72 changes: 72 additions & 0 deletions dhctl/pkg/server/api/dhctl/abort.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright 2024 Flant JSC
//
// 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.

syntax = "proto3";

option go_package = "pb/dhctl";

package dhctl;

import "google/protobuf/duration.proto";
import "common.proto";

message AbortRequest {
oneof message {
AbortStart start = 1;
AbortContinue continue = 2;
}
}

message AbortResponse {
oneof message {
AbortResult result = 1;
AbortPhaseEnd phase_end = 2;
Logs logs = 3;
}
}

message AbortStart {
string connection_config = 1;
string init_config = 2;
string cluster_config = 3;
string provider_specific_cluster_config = 4;
string init_resources = 5;
string resources = 6;
string state = 7;
AbortStartOptions options = 8;
}

message AbortPhaseEnd {
string completed_phase = 1;
map<string, bytes> completed_phase_state = 2;
string next_phase = 3;
bool next_phase_critical = 4;
}

message AbortContinue {
Continue continue = 1;
string err = 2;
}

message AbortStartOptions {
bool commander_mode = 1;
int32 log_width = 2;
google.protobuf.Duration resources_timeout = 3;
google.protobuf.Duration deckhouse_timeout = 4;
}

message AbortResult {
string state = 1;
string err = 2;
}
17 changes: 7 additions & 10 deletions dhctl/pkg/server/api/dhctl/bootstrap.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ package dhctl;
import "google/protobuf/duration.proto";
import "common.proto";


message BootstrapRequest {
oneof message {
BootstrapStart start = 1;
BootstrapStop stop = 2;
BootstrapContinue continue = 3;
BootstrapContinue continue = 2;
}
}

Expand All @@ -50,8 +48,6 @@ message BootstrapStart {
BootstrapStartOptions options = 9;
}

message BootstrapStop {}

message BootstrapPhaseEnd {
string completed_phase = 1;
map<string, bytes> completed_phase_state = 2;
Expand All @@ -60,17 +56,18 @@ message BootstrapPhaseEnd {
}

message BootstrapContinue {
string error = 1;
Continue continue = 1;
string err = 2;
}

message BootstrapStartOptions {
bool commander_mode = 1;
bool sanity_check = 2;
int32 log_width = 3;
google.protobuf.Duration resources_timeout = 4;
google.protobuf.Duration deckhouse_timeout = 5;
int32 log_width = 2;
google.protobuf.Duration resources_timeout = 3;
google.protobuf.Duration deckhouse_timeout = 4;
}

message BootstrapResult {
string state = 1;
string err = 2;
}
11 changes: 4 additions & 7 deletions dhctl/pkg/server/api/dhctl/check.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import "common.proto";
message CheckRequest {
oneof message {
CheckStart start = 1;
CheckStop stop = 2;
}
}

Expand All @@ -43,16 +42,14 @@ message CheckStart {
CheckStartOptions options = 5;
}

message CheckStop {}

message CheckStartOptions {
bool commander_mode = 1;
bool sanity_check = 2;
int32 log_width = 3;
google.protobuf.Duration resources_timeout = 4;
google.protobuf.Duration deckhouse_timeout = 5;
int32 log_width = 2;
google.protobuf.Duration resources_timeout = 3;
google.protobuf.Duration deckhouse_timeout = 4;
}

message CheckResult {
string result = 1;
string err = 2;
}
9 changes: 8 additions & 1 deletion dhctl/pkg/server/api/dhctl/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ option go_package = "pb/dhctl";

package dhctl;

enum Continue {
CONTINUE_UNSPECIFIED = 0;
CONTINUE_NEXT_PHASE = 1;
CONTINUE_STOP_OPERATION = 2;
CONTINUE_ERROR = 3;
}

message Logs {
bytes logs = 1;
repeated string logs = 1;
}
71 changes: 71 additions & 0 deletions dhctl/pkg/server/api/dhctl/converge.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright 2024 Flant JSC
//
// 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.

syntax = "proto3";

option go_package = "pb/dhctl";

package dhctl;

import "google/protobuf/duration.proto";
import "common.proto";

message ConvergeRequest {
oneof message {
ConvergeStart start = 1;
ConvergeContinue continue = 2;
}
}

message ConvergeResponse {
oneof message {
ConvergeResult result = 1;
ConvergePhaseEnd phase_end = 2;
Logs logs = 3;
}
}

message ConvergeStart {
string connection_config = 1;
string cluster_config = 2;
string provider_specific_cluster_config = 3;
string state = 4;
string approve_destruction_change_id = 5;
ConvergeStartOptions options = 6;
}

message ConvergePhaseEnd {
string completed_phase = 1;
map<string, bytes> completed_phase_state = 2;
string next_phase = 3;
bool next_phase_critical = 4;
}

message ConvergeContinue {
Continue continue = 1;
string err = 2;
}

message ConvergeStartOptions {
bool commander_mode = 1;
int32 log_width = 2;
google.protobuf.Duration resources_timeout = 3;
google.protobuf.Duration deckhouse_timeout = 4;
}

message ConvergeResult {
string state = 1;
string result = 2;
string err = 3;
}
70 changes: 70 additions & 0 deletions dhctl/pkg/server/api/dhctl/destroy.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2024 Flant JSC
//
// 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.

syntax = "proto3";

option go_package = "pb/dhctl";

package dhctl;

import "google/protobuf/duration.proto";
import "common.proto";

message DestroyRequest {
oneof message {
DestroyStart start = 1;
DestroyContinue continue = 2;
}
}

message DestroyResponse {
oneof message {
DestroyResult result = 1;
DestroyPhaseEnd phase_end = 2;
Logs logs = 3;
}
}

message DestroyStart {
string connection_config = 1;
string init_config = 2;
string cluster_config = 3;
string provider_specific_cluster_config = 4;
string state = 5;
DestroyStartOptions options = 6;
}

message DestroyPhaseEnd {
string completed_phase = 1;
map<string, bytes> completed_phase_state = 2;
string next_phase = 3;
bool next_phase_critical = 4;
}

message DestroyContinue {
Continue continue = 1;
string err = 2;
}

message DestroyStartOptions {
bool commander_mode = 1;
int32 log_width = 2;
google.protobuf.Duration resources_timeout = 3;
google.protobuf.Duration deckhouse_timeout = 4;
}

message DestroyResult {
string state = 1;
string err = 2;
}
8 changes: 8 additions & 0 deletions dhctl/pkg/server/api/dhctl/dhctl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ package dhctl;

import "check.proto";
import "bootstrap.proto";
import "destroy.proto";
import "abort.proto";
import "converge.proto";
import "import.proto";

service DHCTL {
rpc Check (stream CheckRequest) returns (stream CheckResponse) {}
rpc Bootstrap (stream BootstrapRequest) returns (stream BootstrapResponse) {}
rpc Destroy (stream DestroyRequest) returns (stream DestroyResponse) {}
rpc Abort (stream AbortRequest) returns (stream AbortResponse) {}
rpc Converge (stream ConvergeRequest) returns (stream ConvergeResponse) {}
rpc Import (stream ImportRequest) returns (stream ImportResponse) {}
}

0 comments on commit a719d12

Please sign in to comment.