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

PMM-9965 Remove VM operator #1135

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
github.com/hashicorp/go-version v1.4.0
github.com/lib/pq v1.10.6
github.com/minio/minio-go/v7 v7.0.27
github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472
github.com/percona-platform/dbaas-api v0.0.0-20220525210215-cc4aa3b918e0
github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16
github.com/percona/pmm v0.0.0-20220520150831-23069cdf1bb8
github.com/percona/promconfig v0.2.4-0.20211110115058-98687f586f54
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ github.com/percona-lab/crypto v0.0.0-20220413143500-70ef7e9f1813 h1:Jb/t6zDMQMwt
github.com/percona-lab/crypto v0.0.0-20220413143500-70ef7e9f1813/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472 h1:Henk22VMEBX2jwxAW/pHmiJ9s/w8uwRD4ErPidAS9Vs=
github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472/go.mod h1:WZZ3Hi+lAWCaGWmsrfkkvRQPkIa8n1OZ0s8Su+vbgus=
github.com/percona-platform/dbaas-api v0.0.0-20220525210215-cc4aa3b918e0 h1:R5bHvc6hHCV6bNUl26Yt8Th75ThPpv9JaWZHSLkl+0E=
github.com/percona-platform/dbaas-api v0.0.0-20220525210215-cc4aa3b918e0/go.mod h1:VsQuyV8PabFGg0gkc40vmBcnmxrkl/PCvuissmlztJM=
github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16 h1:0fx16uGtl4MwrBwm9/VSoNEhjL0cXYxS0quEhLthGcc=
github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16/go.mod h1:gFUwaFp6Ugu5qsBwiOVJYbDlzgZ77tmXdXGO7tG5xVI=
github.com/percona/pmm v0.0.0-20220520150831-23069cdf1bb8 h1:P5iuV4GRUIviRg/5/FM6ZOKdiBPdwUPbrHld/epM3hk=
Expand Down
7 changes: 7 additions & 0 deletions services/dbaas/dbaas_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,10 @@ func (c *Client) StartMonitoring(ctx context.Context, in *controllerv1beta1.Star
defer c.connM.RUnlock()
return c.kubernetesClient.StartMonitoring(ctx, in, opts...)
}

// StartMonitoring sets up victoria metrics operator to monitor kubernetes cluster.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think comment should start with StopMonitoring.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

func (c *Client) StopMonitoring(ctx context.Context, in *controllerv1beta1.StopMonitoringRequest, opts ...grpc.CallOption) (*controllerv1beta1.StopMonitoringResponse, error) {
c.connM.RLock()
defer c.connM.RUnlock()
return c.kubernetesClient.StopMonitoring(ctx, in, opts...)
}
2 changes: 2 additions & 0 deletions services/management/dbaas/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ type dbaasClient interface {
InstallPSMDBOperator(ctx context.Context, in *controllerv1beta1.InstallPSMDBOperatorRequest, opts ...grpc.CallOption) (*controllerv1beta1.InstallPSMDBOperatorResponse, error)
// StartMonitoring sets up victoria metrics operator to monitor kubernetes cluster.
StartMonitoring(ctx context.Context, in *controllerv1beta1.StartMonitoringRequest, opts ...grpc.CallOption) (*controllerv1beta1.StartMonitoringResponse, error)
// StopMonitoring removes victoria metrics operator from the cluster.
StopMonitoring(ctx context.Context, in *controllerv1beta1.StopMonitoringRequest, opts ...grpc.CallOption) (*controllerv1beta1.StopMonitoringResponse, error)
}

type versionService interface {
Expand Down
10 changes: 10 additions & 0 deletions services/management/dbaas/kubernetes_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,16 @@ func (k kubernetesServer) UnregisterKubernetesCluster(ctx context.Context, req *
return models.RemoveKubernetesCluster(t.Querier, req.KubernetesClusterName)
}

_, err = k.dbaasClient.StopMonitoring(ctx, &dbaascontrollerv1beta1.StopMonitoringRequest{
KubeAuth: &dbaascontrollerv1beta1.KubeAuth{
Kubeconfig: kubernetesCluster.KubeConfig,
},
})

if err != nil {
return errors.Wrap(err, "cannot stop monitoring")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's for now just log the message and go on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to log.Warn

}

pxcClusters, err := k.dbaasClient.ListPXCClusters(ctx,
&dbaascontrollerv1beta1.ListPXCClustersRequest{
KubeAuth: &dbaascontrollerv1beta1.KubeAuth{
Expand Down
2 changes: 2 additions & 0 deletions services/management/dbaas/kubernetes_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func TestKubernetesServer(t *testing.T) {

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

dc.On("StopMonitoring", mock.Anything, mock.Anything).Return(&controllerv1beta1.StopMonitoringResponse{}, nil)

kubernetesClusterName := "test-cluster"
registerKubernetesClusterResponse, err := ks.RegisterKubernetesCluster(ctx, &dbaasv1beta1.RegisterKubernetesClusterRequest{
KubernetesClusterName: kubernetesClusterName,
Expand Down
30 changes: 30 additions & 0 deletions services/management/dbaas/mock_dbaas_client_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.