Skip to content

Commit eb39d03

Browse files
Pavani-Panakantiorsenthil
authored andcommitted
Add grpc call to fetch networkpolicymode from NP (#3202)
* add rpc call to fetch np mode * go generate * nit: change print %t to %v
1 parent 847372a commit eb39d03

File tree

4 files changed

+549
-122
lines changed

4 files changed

+549
-122
lines changed

pkg/ipamd/rpc_handler.go

+14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
healthpb "google.golang.org/grpc/health/grpc_health_v1"
3131
"google.golang.org/grpc/reflection"
3232
"google.golang.org/grpc/status"
33+
"google.golang.org/protobuf/types/known/emptypb"
3334

3435
"github.com/aws/amazon-vpc-cni-k8s/pkg/ipamd/datastore"
3536
"github.com/aws/amazon-vpc-cni-k8s/pkg/networkutils"
@@ -320,6 +321,18 @@ func (s *server) DelNetwork(ctx context.Context, in *rpc.DelNetworkRequest) (*rp
320321
return &rpc.DelNetworkReply{Success: err == nil, IPv4Addr: ipv4Addr, IPv6Addr: ipv6Addr, DeviceNumber: int32(deviceNumber)}, err
321322
}
322323

324+
func (s *server) GetNetworkPolicyConfigs(ctx context.Context, e *emptypb.Empty) (*rpc.NetworkPolicyAgentConfigReply, error) {
325+
326+
log.Infof("Received request for Network Policy Agent configs")
327+
328+
resp := &rpc.NetworkPolicyAgentConfigReply{
329+
NetworkPolicyMode: s.ipamContext.networkPolicyMode,
330+
}
331+
332+
log.Infof("Send NetworkPolicyAgentConfigReply: NetworkPolicyMode: %v", resp.NetworkPolicyMode)
333+
return resp, nil
334+
}
335+
323336
// RunRPCHandler handles request from gRPC
324337
func (c *IPAMContext) RunRPCHandler(version string) error {
325338
log.Infof("Serving RPC Handler version %s on %s", version, ipamdgRPCaddress)
@@ -330,6 +343,7 @@ func (c *IPAMContext) RunRPCHandler(version string) error {
330343
}
331344
grpcServer := grpc.NewServer()
332345
rpc.RegisterCNIBackendServer(grpcServer, &server{version: version, ipamContext: c})
346+
rpc.RegisterConfigServerBackendServer(grpcServer, &server{version: version, ipamContext: c})
333347
healthServer := health.NewServer()
334348
// If ipamd can talk to the API server and to the EC2 API, the pod is healthy.
335349
// No need to ever change this to HealthCheckResponse_NOT_SERVING since it's a local service only

rpc/mocks/rpc_mocks.go

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

0 commit comments

Comments
 (0)