Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.

Commit 2b81d2b

Browse files
Merge 1ef560d into 1011fab
2 parents 1011fab + 1ef560d commit 2b81d2b

File tree

7 files changed

+54
-1
lines changed

7 files changed

+54
-1
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ require (
3535
github.com/hashicorp/go-version v1.5.0
3636
github.com/lib/pq v1.10.6
3737
github.com/minio/minio-go/v7 v7.0.27
38-
github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472
38+
github.com/percona-platform/dbaas-api v0.0.0-20220525210215-cc4aa3b918e0
3939
github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16
4040
github.com/percona/pmm v0.0.0-20220609163826-96fb5593d69b
4141
github.com/percona/promconfig v0.2.4-0.20211110115058-98687f586f54

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ github.com/percona-lab/crypto v0.0.0-20220413143500-70ef7e9f1813 h1:Jb/t6zDMQMwt
465465
github.com/percona-lab/crypto v0.0.0-20220413143500-70ef7e9f1813/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
466466
github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472 h1:Henk22VMEBX2jwxAW/pHmiJ9s/w8uwRD4ErPidAS9Vs=
467467
github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472/go.mod h1:WZZ3Hi+lAWCaGWmsrfkkvRQPkIa8n1OZ0s8Su+vbgus=
468+
github.com/percona-platform/dbaas-api v0.0.0-20220525210215-cc4aa3b918e0 h1:R5bHvc6hHCV6bNUl26Yt8Th75ThPpv9JaWZHSLkl+0E=
469+
github.com/percona-platform/dbaas-api v0.0.0-20220525210215-cc4aa3b918e0/go.mod h1:VsQuyV8PabFGg0gkc40vmBcnmxrkl/PCvuissmlztJM=
468470
github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16 h1:0fx16uGtl4MwrBwm9/VSoNEhjL0cXYxS0quEhLthGcc=
469471
github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16/go.mod h1:gFUwaFp6Ugu5qsBwiOVJYbDlzgZ77tmXdXGO7tG5xVI=
470472
github.com/percona/pmm v0.0.0-20220609163826-96fb5593d69b h1:b3MUqjYU1L85FExBgewV9xFluJEFRO129pRHskgxW+0=

services/dbaas/dbaas_client.go

+7
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,10 @@ func (c *Client) StartMonitoring(ctx context.Context, in *controllerv1beta1.Star
237237
defer c.connM.RUnlock()
238238
return c.kubernetesClient.StartMonitoring(ctx, in, opts...)
239239
}
240+
241+
// StopMonitoring removes victoria metrics operator from the kubernetes cluster.
242+
func (c *Client) StopMonitoring(ctx context.Context, in *controllerv1beta1.StopMonitoringRequest, opts ...grpc.CallOption) (*controllerv1beta1.StopMonitoringResponse, error) {
243+
c.connM.RLock()
244+
defer c.connM.RUnlock()
245+
return c.kubernetesClient.StopMonitoring(ctx, in, opts...)
246+
}

services/management/dbaas/deps.go

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ type dbaasClient interface {
6666
InstallPSMDBOperator(ctx context.Context, in *controllerv1beta1.InstallPSMDBOperatorRequest, opts ...grpc.CallOption) (*controllerv1beta1.InstallPSMDBOperatorResponse, error)
6767
// StartMonitoring sets up victoria metrics operator to monitor kubernetes cluster.
6868
StartMonitoring(ctx context.Context, in *controllerv1beta1.StartMonitoringRequest, opts ...grpc.CallOption) (*controllerv1beta1.StartMonitoringResponse, error)
69+
// StopMonitoring removes victoria metrics operator from the cluster.
70+
StopMonitoring(ctx context.Context, in *controllerv1beta1.StopMonitoringRequest, opts ...grpc.CallOption) (*controllerv1beta1.StopMonitoringResponse, error)
6971
}
7072

7173
type versionService interface {

services/management/dbaas/kubernetes_server.go

+10
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,16 @@ func (k kubernetesServer) UnregisterKubernetesCluster(ctx context.Context, req *
357357
return models.RemoveKubernetesCluster(t.Querier, req.KubernetesClusterName)
358358
}
359359

360+
_, err = k.dbaasClient.StopMonitoring(ctx, &dbaascontrollerv1beta1.StopMonitoringRequest{
361+
KubeAuth: &dbaascontrollerv1beta1.KubeAuth{
362+
Kubeconfig: kubernetesCluster.KubeConfig,
363+
},
364+
})
365+
366+
if err != nil {
367+
k.l.Warnf("cannot stop monitoring: %s", err)
368+
}
369+
360370
pxcClusters, err := k.dbaasClient.ListPXCClusters(ctx,
361371
&dbaascontrollerv1beta1.ListPXCClustersRequest{
362372
KubeAuth: &dbaascontrollerv1beta1.KubeAuth{

services/management/dbaas/kubernetes_server_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ func TestKubernetesServer(t *testing.T) {
7676

7777
dc.On("InstallPXCOperator", mock.Anything, mock.Anything).Return(&controllerv1beta1.InstallPXCOperatorResponse{}, nil)
7878

79+
dc.On("StopMonitoring", mock.Anything, mock.Anything).Return(&controllerv1beta1.StopMonitoringResponse{}, nil)
80+
7981
kubernetesClusterName := "test-cluster"
8082
registerKubernetesClusterResponse, err := ks.RegisterKubernetesCluster(ctx, &dbaasv1beta1.RegisterKubernetesClusterRequest{
8183
KubernetesClusterName: kubernetesClusterName,

services/management/dbaas/mock_dbaas_client_test.go

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)