diff --git a/components/agent/internal/grpc/client.go b/components/agent/internal/grpc/client.go index c95a0a780..4d376c296 100644 --- a/components/agent/internal/grpc/client.go +++ b/components/agent/internal/grpc/client.go @@ -226,6 +226,38 @@ func (client *client) Start(ctx context.Context) error { if err := client.k8sClient.Delete(ctx, msg.DeletedStack.ClusterName); err != nil { sharedlogging.FromContext(ctx).Errorf("creating deleting cluster side: %s", err) } + case *generated.ConnectResponse_DisabledStack: + existingStack, err := client.k8sClient.Get(ctx, msg.DisabledStack.ClusterName, metav1.GetOptions{}) + if err != nil { + if controllererrors.IsNotFound(err) { + sharedlogging.FromContext(ctx).Infof("cannot disable not existing stack: %s", msg.DisabledStack.ClusterName) + continue + } + sharedlogging.FromContext(ctx).Errorf("reading stack cluster side: %s", err) + continue + } + existingStack.Spec.Disabled = true + if _, err := client.k8sClient.Update(ctx, existingStack); err != nil { + sharedlogging.FromContext(ctx).Errorf("updating stack cluster side: %s", err) + continue + } + sharedlogging.FromContext(ctx).Infof("stack %s updated", msg.DisabledStack.ClusterName) + case *generated.ConnectResponse_EnabledStack: + existingStack, err := client.k8sClient.Get(ctx, msg.EnabledStack.ClusterName, metav1.GetOptions{}) + if err != nil { + if controllererrors.IsNotFound(err) { + sharedlogging.FromContext(ctx).Infof("cannot enable not existing stack: %s", msg.EnabledStack.ClusterName) + continue + } + sharedlogging.FromContext(ctx).Errorf("reading stack cluster side: %s", err) + continue + } + existingStack.Spec.Disabled = false + if _, err := client.k8sClient.Update(ctx, existingStack); err != nil { + sharedlogging.FromContext(ctx).Errorf("updating stack cluster side: %s", err) + continue + } + sharedlogging.FromContext(ctx).Infof("stack %s updated", msg.EnabledStack.ClusterName) case *generated.ConnectResponse_UpdateUsageReport: total, err := CountDocument(msg.UpdateUsageReport.ClusterName) if err != nil { diff --git a/components/agent/internal/grpc/generated/server.pb.go b/components/agent/internal/grpc/generated/server.pb.go index f47524175..455dbfca5 100644 --- a/components/agent/internal/grpc/generated/server.pb.go +++ b/components/agent/internal/grpc/generated/server.pb.go @@ -102,6 +102,8 @@ type ConnectResponse struct { // *ConnectResponse_DeletedStack // *ConnectResponse_Ping // *ConnectResponse_UpdateUsageReport + // *ConnectResponse_DisabledStack + // *ConnectResponse_EnabledStack Message isConnectResponse_Message `protobuf_oneof:"message"` } @@ -179,6 +181,20 @@ func (x *ConnectResponse) GetUpdateUsageReport() *UpdateUsageReport { return nil } +func (x *ConnectResponse) GetDisabledStack() *DisabledStack { + if x, ok := x.GetMessage().(*ConnectResponse_DisabledStack); ok { + return x.DisabledStack + } + return nil +} + +func (x *ConnectResponse) GetEnabledStack() *EnabledStack { + if x, ok := x.GetMessage().(*ConnectResponse_EnabledStack); ok { + return x.EnabledStack + } + return nil +} + type isConnectResponse_Message interface { isConnectResponse_Message() } @@ -203,6 +219,14 @@ type ConnectResponse_UpdateUsageReport struct { UpdateUsageReport *UpdateUsageReport `protobuf:"bytes,5,opt,name=updateUsageReport,proto3,oneof"` } +type ConnectResponse_DisabledStack struct { + DisabledStack *DisabledStack `protobuf:"bytes,6,opt,name=disabledStack,proto3,oneof"` +} + +type ConnectResponse_EnabledStack struct { + EnabledStack *EnabledStack `protobuf:"bytes,7,opt,name=enabledStack,proto3,oneof"` +} + func (*ConnectResponse_Connected) isConnectResponse_Message() {} func (*ConnectResponse_ExistingStack) isConnectResponse_Message() {} @@ -213,6 +237,10 @@ func (*ConnectResponse_Ping) isConnectResponse_Message() {} func (*ConnectResponse_UpdateUsageReport) isConnectResponse_Message() {} +func (*ConnectResponse_DisabledStack) isConnectResponse_Message() {} + +func (*ConnectResponse_EnabledStack) isConnectResponse_Message() {} + type Connected struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -470,6 +498,100 @@ func (x *DeletedStack) GetClusterName() string { return "" } +type DisabledStack struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ClusterName string `protobuf:"bytes,1,opt,name=clusterName,proto3" json:"clusterName,omitempty"` +} + +func (x *DisabledStack) Reset() { + *x = DisabledStack{} + if protoimpl.UnsafeEnabled { + mi := &file_server_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DisabledStack) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisabledStack) ProtoMessage() {} + +func (x *DisabledStack) ProtoReflect() protoreflect.Message { + mi := &file_server_proto_msgTypes[7] + 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 DisabledStack.ProtoReflect.Descriptor instead. +func (*DisabledStack) Descriptor() ([]byte, []int) { + return file_server_proto_rawDescGZIP(), []int{7} +} + +func (x *DisabledStack) GetClusterName() string { + if x != nil { + return x.ClusterName + } + return "" +} + +type EnabledStack struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ClusterName string `protobuf:"bytes,1,opt,name=clusterName,proto3" json:"clusterName,omitempty"` +} + +func (x *EnabledStack) Reset() { + *x = EnabledStack{} + if protoimpl.UnsafeEnabled { + mi := &file_server_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EnabledStack) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnabledStack) ProtoMessage() {} + +func (x *EnabledStack) ProtoReflect() protoreflect.Message { + mi := &file_server_proto_msgTypes[8] + 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 EnabledStack.ProtoReflect.Descriptor instead. +func (*EnabledStack) Descriptor() ([]byte, []int) { + return file_server_proto_rawDescGZIP(), []int{8} +} + +func (x *EnabledStack) GetClusterName() string { + if x != nil { + return x.ClusterName + } + return "" +} + type UpdateUsageReport struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -483,7 +605,7 @@ type UpdateUsageReport struct { func (x *UpdateUsageReport) Reset() { *x = UpdateUsageReport{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[7] + mi := &file_server_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -496,7 +618,7 @@ func (x *UpdateUsageReport) String() string { func (*UpdateUsageReport) ProtoMessage() {} func (x *UpdateUsageReport) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[7] + mi := &file_server_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -509,7 +631,7 @@ func (x *UpdateUsageReport) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateUsageReport.ProtoReflect.Descriptor instead. func (*UpdateUsageReport) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{7} + return file_server_proto_rawDescGZIP(), []int{9} } func (x *UpdateUsageReport) GetClusterName() string { @@ -546,7 +668,7 @@ type AuthConfig struct { func (x *AuthConfig) Reset() { *x = AuthConfig{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[8] + mi := &file_server_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -559,7 +681,7 @@ func (x *AuthConfig) String() string { func (*AuthConfig) ProtoMessage() {} func (x *AuthConfig) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[8] + mi := &file_server_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -572,7 +694,7 @@ func (x *AuthConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthConfig.ProtoReflect.Descriptor instead. func (*AuthConfig) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{8} + return file_server_proto_rawDescGZIP(), []int{10} } func (x *AuthConfig) GetClientId() string { @@ -608,7 +730,7 @@ type AuthClient struct { func (x *AuthClient) Reset() { *x = AuthClient{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[9] + mi := &file_server_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -621,7 +743,7 @@ func (x *AuthClient) String() string { func (*AuthClient) ProtoMessage() {} func (x *AuthClient) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[9] + mi := &file_server_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -634,7 +756,7 @@ func (x *AuthClient) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthClient.ProtoReflect.Descriptor instead. func (*AuthClient) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{9} + return file_server_proto_rawDescGZIP(), []int{11} } func (x *AuthClient) GetPublic() bool { @@ -668,7 +790,7 @@ var file_server_proto_rawDesc = []byte{ 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x22, 0xb1, 0x02, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, + 0x38, 0x01, 0x22, 0xac, 0x03, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x48, 0x00, 0x52, 0x09, @@ -686,28 +808,42 @@ var file_server_proto_rawDesc = []byte{ 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x00, 0x52, 0x11, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x0b, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, - 0x74, 0x65, 0x64, 0x22, 0x06, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x22, 0xeb, 0x01, 0x0a, 0x05, + 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x3d, 0x0a, 0x0d, 0x64, + 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x44, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x64, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x0d, 0x64, 0x69, 0x73, + 0x61, 0x62, 0x6c, 0x65, 0x64, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x3a, 0x0a, 0x0c, 0x65, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x64, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x0c, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x22, 0x0b, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x06, + 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x22, 0xeb, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x63, 0x6b, + 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x73, 0x65, 0x65, 0x64, 0x12, 0x32, 0x0a, 0x0a, 0x61, 0x75, 0x74, 0x68, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0a, + 0x61, 0x75, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x38, 0x0a, 0x0d, 0x73, 0x74, + 0x61, 0x74, 0x69, 0x63, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3e, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x67, 0x61, 0x74, 0x65, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x67, 0x61, 0x74, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x67, 0x61, 0x74, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3c, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x72, 0x67, 0x61, 0x74, 0x65, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, + 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, + 0x72, 0x6c, 0x22, 0x30, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x53, 0x74, 0x61, + 0x63, 0x6b, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x31, 0x0a, 0x0d, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x65, 0x65, 0x64, 0x12, 0x32, 0x0a, 0x0a, 0x61, - 0x75, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x0a, 0x61, 0x75, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x38, 0x0a, 0x0d, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, - 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, - 0x41, 0x75, 0x74, 0x68, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x74, - 0x69, 0x63, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3e, 0x0a, 0x0e, 0x73, 0x74, 0x61, - 0x72, 0x67, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x67, - 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x67, - 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3c, 0x0a, 0x0e, 0x53, 0x74, 0x61, - 0x72, 0x67, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, - 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, - 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x30, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x30, 0x0a, 0x0c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x87, 0x01, 0x0a, 0x11, 0x55, 0x70, @@ -752,7 +888,7 @@ func file_server_proto_rawDescGZIP() []byte { return file_server_proto_rawDescData } -var file_server_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_server_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_server_proto_goTypes = []interface{}{ (*ConnectRequest)(nil), // 0: server.ConnectRequest (*ConnectResponse)(nil), // 1: server.ConnectResponse @@ -761,28 +897,32 @@ var file_server_proto_goTypes = []interface{}{ (*Stack)(nil), // 4: server.Stack (*StargateConfig)(nil), // 5: server.StargateConfig (*DeletedStack)(nil), // 6: server.DeletedStack - (*UpdateUsageReport)(nil), // 7: server.UpdateUsageReport - (*AuthConfig)(nil), // 8: server.AuthConfig - (*AuthClient)(nil), // 9: server.AuthClient - nil, // 10: server.ConnectRequest.TagsEntry + (*DisabledStack)(nil), // 7: server.DisabledStack + (*EnabledStack)(nil), // 8: server.EnabledStack + (*UpdateUsageReport)(nil), // 9: server.UpdateUsageReport + (*AuthConfig)(nil), // 10: server.AuthConfig + (*AuthClient)(nil), // 11: server.AuthClient + nil, // 12: server.ConnectRequest.TagsEntry } var file_server_proto_depIdxs = []int32{ - 10, // 0: server.ConnectRequest.tags:type_name -> server.ConnectRequest.TagsEntry + 12, // 0: server.ConnectRequest.tags:type_name -> server.ConnectRequest.TagsEntry 2, // 1: server.ConnectResponse.connected:type_name -> server.Connected 4, // 2: server.ConnectResponse.existingStack:type_name -> server.Stack 6, // 3: server.ConnectResponse.deletedStack:type_name -> server.DeletedStack 3, // 4: server.ConnectResponse.ping:type_name -> server.Ping - 7, // 5: server.ConnectResponse.updateUsageReport:type_name -> server.UpdateUsageReport - 8, // 6: server.Stack.authConfig:type_name -> server.AuthConfig - 9, // 7: server.Stack.staticClients:type_name -> server.AuthClient - 5, // 8: server.Stack.stargateConfig:type_name -> server.StargateConfig - 0, // 9: server.Server.Connect:input_type -> server.ConnectRequest - 1, // 10: server.Server.Connect:output_type -> server.ConnectResponse - 10, // [10:11] is the sub-list for method output_type - 9, // [9:10] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 9, // 5: server.ConnectResponse.updateUsageReport:type_name -> server.UpdateUsageReport + 7, // 6: server.ConnectResponse.disabledStack:type_name -> server.DisabledStack + 8, // 7: server.ConnectResponse.enabledStack:type_name -> server.EnabledStack + 10, // 8: server.Stack.authConfig:type_name -> server.AuthConfig + 11, // 9: server.Stack.staticClients:type_name -> server.AuthClient + 5, // 10: server.Stack.stargateConfig:type_name -> server.StargateConfig + 0, // 11: server.Server.Connect:input_type -> server.ConnectRequest + 1, // 12: server.Server.Connect:output_type -> server.ConnectResponse + 12, // [12:13] is the sub-list for method output_type + 11, // [11:12] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_server_proto_init() } @@ -876,7 +1016,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateUsageReport); i { + switch v := v.(*DisabledStack); i { case 0: return &v.state case 1: @@ -888,7 +1028,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthConfig); i { + switch v := v.(*EnabledStack); i { case 0: return &v.state case 1: @@ -900,6 +1040,30 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateUsageReport); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_server_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AuthConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_server_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AuthClient); i { case 0: return &v.state @@ -918,6 +1082,8 @@ func file_server_proto_init() { (*ConnectResponse_DeletedStack)(nil), (*ConnectResponse_Ping)(nil), (*ConnectResponse_UpdateUsageReport)(nil), + (*ConnectResponse_DisabledStack)(nil), + (*ConnectResponse_EnabledStack)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -925,7 +1091,7 @@ func file_server_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_server_proto_rawDesc, NumEnums: 0, - NumMessages: 11, + NumMessages: 13, NumExtensions: 0, NumServices: 1, }, diff --git a/components/agent/server.proto b/components/agent/server.proto index 368991563..ad85df3f8 100644 --- a/components/agent/server.proto +++ b/components/agent/server.proto @@ -22,6 +22,8 @@ message ConnectResponse { DeletedStack deletedStack = 3; Ping ping = 4; UpdateUsageReport updateUsageReport = 5; + DisabledStack disabledStack = 6; + EnabledStack enabledStack = 7; } } @@ -46,6 +48,14 @@ message DeletedStack { string clusterName = 1; } +message DisabledStack { + string clusterName = 1; +} + +message EnabledStack { + string clusterName = 1; +} + message UpdateUsageReport { string clusterName = 1; string stripeKey = 2; diff --git a/components/operator/.gitignore b/components/operator/.gitignore index 1e9a97ea7..ad47f584a 100644 --- a/components/operator/.gitignore +++ b/components/operator/.gitignore @@ -89,5 +89,5 @@ garden/local-registries.yaml garden.default.env ca.crt helm/operator/charts -helm/operator/templates/rbac/kustomization.yaml +helm/templates/rbac/kustomization.yaml operator diff --git a/components/operator/apis/stack/v1beta3/stack_types.go b/components/operator/apis/stack/v1beta3/stack_types.go index 862e7899c..b78614d5c 100644 --- a/components/operator/apis/stack/v1beta3/stack_types.go +++ b/components/operator/apis/stack/v1beta3/stack_types.go @@ -113,6 +113,9 @@ type StackSpec struct { // +optional // +kubebuilder:default:="http" Scheme string `json:"scheme"` + + // +optional + Disabled bool `json:"disabled"` } type ControlAuthentication struct { diff --git a/components/operator/config/crd/bases/stack.formance.com_stacks.yaml b/components/operator/config/crd/bases/stack.formance.com_stacks.yaml index fde07dded..e9060f618 100644 --- a/components/operator/config/crd/bases/stack.formance.com_stacks.yaml +++ b/components/operator/config/crd/bases/stack.formance.com_stacks.yaml @@ -1918,6 +1918,8 @@ spec: type: boolean dev: type: boolean + disabled: + type: boolean host: type: string scheme: diff --git a/components/operator/helm/templates/gen/apiextensions.k8s.io_v1_customresourcedefinition_stacks.stack.formance.com.yaml b/components/operator/helm/templates/gen/apiextensions.k8s.io_v1_customresourcedefinition_stacks.stack.formance.com.yaml index cdbd5a340..15e58cda6 100644 --- a/components/operator/helm/templates/gen/apiextensions.k8s.io_v1_customresourcedefinition_stacks.stack.formance.com.yaml +++ b/components/operator/helm/templates/gen/apiextensions.k8s.io_v1_customresourcedefinition_stacks.stack.formance.com.yaml @@ -1929,6 +1929,8 @@ spec: type: boolean dev: type: boolean + disabled: + type: boolean host: type: string scheme: diff --git a/components/operator/internal/modules/module.go b/components/operator/internal/modules/module.go index 6ab4bdab5..49c91e55e 100644 --- a/components/operator/internal/modules/module.go +++ b/components/operator/internal/modules/module.go @@ -16,6 +16,18 @@ import ( func HandleStack(ctx Context, deployer *ResourceDeployer) error { + if ctx.Stack.Spec.Disabled { + if err := deployer.client.DeleteAllOf(ctx, &v1.Deployment{}, + client.InNamespace(ctx.Stack.Name), + client.MatchingLabels{ + "stack": "true", + }, + ); err != nil { + return err + } + return nil + } + var ( portAllocator PortAllocator = StaticPortAllocator(8080) podDeployer PodDeployer = NewDefaultPodDeployer(deployer)