Skip to content

Commit

Permalink
Add DnsSettings to CreateEndpointRequest
Browse files Browse the repository at this point in the history
To be able to set DNS configurations on the endpoint add a new DnsSettings message to
be used on the hcn endpoint.

This PR also fixes up a spelling mistake in subnet_ipadress_prefix -> subnet_ipaddress_prefix,
and a couple casing changes on the proto file.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
  • Loading branch information
dcantah committed Jun 1, 2021
1 parent 4b95424 commit 7e13d2c
Show file tree
Hide file tree
Showing 4 changed files with 555 additions and 127 deletions.
4 changes: 2 additions & 2 deletions cmd/ncproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func main() {

// If there's a node network service in the config, assign this to our global client.
if conf.NodeNetSvcAddr != "" {
log.G(ctx).Debugf("connecting to NodeNetworkService at address %s", conf.NodeNetSvcAddr)
log.G(ctx).Infof("connecting to NodeNetworkService at address %s", conf.NodeNetSvcAddr)

opts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{})}
if conf.Timeout > 0 {
Expand All @@ -78,7 +78,7 @@ func main() {
log.G(ctx).Fatalf("failed to connect to NodeNetworkService at address %s", conf.NodeNetSvcAddr)
}

log.G(ctx).Debugf("successfully connected to NodeNetworkService at address %s", conf.NodeNetSvcAddr)
log.G(ctx).Infof("successfully connected to NodeNetworkService at address %s", conf.NodeNetSvcAddr)

netSvcClient := nodenetsvc.NewNodeNetworkServiceClient(client)
nodeNetSvcClient = &nodeNetSvcConn{
Expand Down
20 changes: 18 additions & 2 deletions cmd/ncproxy/ncproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"strconv"
"sync"
"time"

"github.com/Microsoft/go-winio"
"github.com/Microsoft/hcsshim/cmd/ncproxy/ncproxygrpc"
Expand Down Expand Up @@ -214,8 +215,8 @@ func (s *grpcService) CreateNetwork(ctx context.Context, req *ncproxygrpc.Create
Settings: data,
}

subnets := make([]hcn.Subnet, len(req.SubnetIpadressPrefix))
for i, addrPrefix := range req.SubnetIpadressPrefix {
subnets := make([]hcn.Subnet, len(req.SubnetIpaddressPrefix))
for i, addrPrefix := range req.SubnetIpaddressPrefix {
subnet := hcn.Subnet{
IpAddressPrefix: addrPrefix,
Routes: []hcn.Route{
Expand Down Expand Up @@ -342,6 +343,14 @@ func (s *grpcService) CreateEndpoint(ctx context.Context, req *ncproxygrpc.Creat
},
}

if req.DnsSetting != nil {
endpoint.Dns = hcn.Dns{
ServerList: req.DnsSetting.ServerIpAddrs,
Domain: req.DnsSetting.Domain,
Search: req.DnsSetting.Search,
}
}

endpoint, err = endpoint.Create()
if err != nil {
return nil, errors.Wrap(err, "failed to create HNS endpoint")
Expand Down Expand Up @@ -456,6 +465,11 @@ func (s *grpcService) GetEndpoint(ctx context.Context, req *ncproxygrpc.GetEndpo
Name: ep.Name,
Network: ep.HostComputeNetwork,
Namespace: ep.HostComputeNamespace,
DnsSetting: &ncproxygrpc.DnsSetting{
ServerIpAddrs: ep.Dns.ServerList,
Domain: ep.Dns.Domain,
Search: ep.Dns.Search,
},
}, nil
}

Expand Down Expand Up @@ -595,6 +609,8 @@ func (s *ttrpcService) ConfigureNetworking(ctx context.Context, req *ncproxyttrp
RequestType: nodenetsvc.RequestType(req.RequestType),
}

ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)
defer cancel()
if _, err := nodeNetSvcClient.client.ConfigureNetworking(ctx, netsvcReq); err != nil {
return nil, err
}
Expand Down

0 comments on commit 7e13d2c

Please sign in to comment.