From 1f1e915703e9bb1d58022a3084844a7239128312 Mon Sep 17 00:00:00 2001 From: Sushant Sharma Date: Wed, 8 Aug 2018 16:08:39 -0700 Subject: [PATCH] Do not provision dns on the webapp interface, and instead return it in interface response --- cns/NetworkContainerContract.go | 8 +++++--- cns/networkcontainers/networkcontainers_windows.go | 12 ------------ cns/restserver/restserver.go | 13 ++++++++++--- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/cns/NetworkContainerContract.go b/cns/NetworkContainerContract.go index 117012b9e4..4bd6e9429d 100644 --- a/cns/NetworkContainerContract.go +++ b/cns/NetworkContainerContract.go @@ -133,9 +133,11 @@ type GetInterfaceForContainerRequest struct { // GetInterfaceForContainerResponse specifies the interface for a given container ID. type GetInterfaceForContainerResponse struct { - NetworkInterface NetworkInterface - CnetAddressSpace []IPSubnet - Response Response + NetworkContainerVersion string + NetworkInterface NetworkInterface + CnetAddressSpace []IPSubnet + DNSServers []string + Response Response } // NetworkInterface specifies the information that can be used to unquely identify an interface. diff --git a/cns/networkcontainers/networkcontainers_windows.go b/cns/networkcontainers/networkcontainers_windows.go index 3ae72f9d8f..986444c6c2 100644 --- a/cns/networkcontainers/networkcontainers_windows.go +++ b/cns/networkcontainers/networkcontainers_windows.go @@ -99,16 +99,6 @@ func createOrUpdateWithOperation(createNetworkContainerRequest cns.CreateNetwork return errors.New("[Azure CNS] IPAddress in IPConfiguration of createNetworkContainerRequest is nil") } - var dnsServers string - - for _, element := range createNetworkContainerRequest.IPConfiguration.DNSServers { - dnsServers += element + "," - } - - if dnsServers != "" && dnsServers[len(dnsServers)-1] == ',' { - dnsServers = dnsServers[:len(dnsServers)-1] - } - ipv4AddrCidr := fmt.Sprintf("%v/%d", createNetworkContainerRequest.IPConfiguration.IPSubnet.IPAddress, createNetworkContainerRequest.IPConfiguration.IPSubnet.PrefixLength) log.Printf("[Azure CNS] Created ipv4Cidr as %v", ipv4AddrCidr) ipv4Addr, _, err := net.ParseCIDR(ipv4AddrCidr) @@ -128,8 +118,6 @@ func createOrUpdateWithOperation(createNetworkContainerRequest cns.CreateNetwork ipv4NetStr, "/gateway", createNetworkContainerRequest.IPConfiguration.GatewayIPAddress, - "/dns", - dnsServers, "/weakhostsend", "true", "/weakhostreceive", diff --git a/cns/restserver/restserver.go b/cns/restserver/restserver.go index d52ecb8421..2a743d5aa6 100644 --- a/cns/restserver/restserver.go +++ b/cns/restserver/restserver.go @@ -1194,17 +1194,22 @@ func (service *httpRestService) getInterfaceForContainer(w http.ResponseWriter, var interfaceName string var ipaddress string var cnetSpace []cns.IPSubnet + var dnsServers []string + var version string if ok { savedReq := containerDetails.CreateNetworkContainerRequest interfaceName = savedReq.NetworkContainerid cnetSpace = savedReq.CnetAddressSpace ipaddress = savedReq.IPConfiguration.IPSubnet.IPAddress // it has to exist + dnsServers = savedReq.IPConfiguration.DNSServers + version = savedReq.Version } else { returnMessage = "[Azure CNS] Never received call to create this container." returnCode = UnknownContainerID interfaceName = "" ipaddress = "" + version = "" } resp := cns.Response{ @@ -1213,9 +1218,11 @@ func (service *httpRestService) getInterfaceForContainer(w http.ResponseWriter, } getInterfaceForContainerResponse := cns.GetInterfaceForContainerResponse{ - Response: resp, - NetworkInterface: cns.NetworkInterface{Name: interfaceName, IPAddress: ipaddress}, - CnetAddressSpace: cnetSpace, + Response: resp, + NetworkInterface: cns.NetworkInterface{Name: interfaceName, IPAddress: ipaddress}, + CnetAddressSpace: cnetSpace, + DNSServers: dnsServers, + NetworkContainerVersion: version, } err = service.Listener.Encode(w, &getInterfaceForContainerResponse)