From 10cf53cc9c2f6c6c51125a484ed2ad480ed609d3 Mon Sep 17 00:00:00 2001 From: robbiezhang Date: Tue, 16 Oct 2018 20:31:39 +0000 Subject: [PATCH] Use a hash of the subnetID instead of virtual node name to avoid conflict --- providers/azure/aci.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/providers/azure/aci.go b/providers/azure/aci.go index e72a3c28c..37efc6154 100644 --- a/providers/azure/aci.go +++ b/providers/azure/aci.go @@ -368,7 +368,9 @@ func (p *ACIProvider) setupNetworkProfile(auth *client.Authentication) error { } } - profile, err := c.GetProfile(p.resourceGroup, p.nodeName) + networkProfileName := getNetworkProfileName(*subnet.ID) + + profile, err := c.GetProfile(p.resourceGroup, networkProfileName) if err != nil && !network.IsNotFound(err) { return fmt.Errorf("error while looking up network profile: %v", err) } @@ -384,7 +386,7 @@ func (p *ACIProvider) setupNetworkProfile(auth *client.Authentication) error { } // at this point, profile should be nil - profile = network.NewNetworkProfile(p.nodeName, p.region, *subnet.ID) + profile = network.NewNetworkProfile(networkProfileName, p.region, *subnet.ID) profile, err = c.CreateOrUpdateProfile(p.resourceGroup, profile) if err != nil { return err @@ -394,6 +396,13 @@ func (p *ACIProvider) setupNetworkProfile(auth *client.Authentication) error { return nil } +func getNetworkProfileName(subnetID string) string { + h := sha256.New() + h.Write([]byte(strings.ToUpper(subnetID))) + hashBytes := h.Sum(nil) + return fmt.Sprintf("vk-%s", hex.EncodeToString(hashBytes)) +} + func getKubeProxyExtension(secretPath, masterURI, clusterCIDR string) (*aci.Extension, error) { ca, err := ioutil.ReadFile(secretPath + "/ca.crt") if err != nil {