-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_delete.go
42 lines (33 loc) · 1.13 KB
/
node_delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package server
import (
"context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
iReq "github.com/chef/automate/api/external/ingest/request"
api "github.com/chef/automate/api/interservice/deployment"
ingest "github.com/chef/automate/api/interservice/ingest"
)
func (s *server) InfrastructureNodeDelete(ctx context.Context,
req *api.InfrastructureNodeDeleteRequest) (*api.InfrastructureNodeDeleteResponse, error) {
ingestAddr := s.AddressForService("ingest-service")
ingestConnection, err := s.connFactory.DialContext(
ctx,
"ingest-service",
ingestAddr,
grpc.WithBlock(),
)
if err != nil {
return nil, status.Errorf(codes.Unavailable, "error connecting to ingest-service: %s", err.Error())
}
defer ingestConnection.Close() // nolint: errcheck
ingestClient := ingest.NewChefIngesterClient(ingestConnection)
nodesRequest := &iReq.Delete{
NodeId: req.NodeId,
}
_, err = ingestClient.ProcessNodeDelete(ctx, nodesRequest)
if err != nil {
return nil, status.Errorf(codes.Unavailable, "error deleting node: %s", err.Error())
}
return &api.InfrastructureNodeDeleteResponse{}, nil
}