Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
fixing vmPrefix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqibrahim committed Sep 24, 2018
1 parent eb67cfc commit 83ce0a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 7 additions & 5 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type ClusterMetadata struct {
RouteTableName string `json:"routeTableName,omitempty"`
PrimaryAvailabilitySetName string `json:"primaryAvailabilitySetName,omitempty"`
PrimaryScaleSetName string `json:"primaryScaleSetName,omitempty"`
VMPrefix string `json:"vmPrefix,omitempty"`
}

// AddonProfile represents an addon for managed cluster
Expand Down Expand Up @@ -748,14 +749,14 @@ func (p *Properties) K8sOrchestratorName() string {
}

func (p *Properties) getAgentVMPrefix() string {
return p.K8sOrchestratorName() + "-agentpool-"
return p.K8sOrchestratorName() + "-agentpool-" + p.GenerateClusterID() + "-"
}

func (p *Properties) getMasterVMPrefix() string {
return p.K8sOrchestratorName() + "-master-"
return p.K8sOrchestratorName() + "-master-" + p.GenerateClusterID() + "-"
}

func (p *Properties) getVMPrefix() string {
func (p *Properties) GetVMPrefix() string {
if p.IsHostedMasterProfile() {
return p.getAgentVMPrefix()
}
Expand All @@ -764,12 +765,12 @@ func (p *Properties) getVMPrefix() string {

// GetRouteTableName returns the route table name of the cluster.
func (p *Properties) GetRouteTableName() string {
return p.getVMPrefix() + "routetable"
return p.GetVMPrefix() + "routetable"
}

// GetNSGName returns the name of the network security group of the cluster.
func (p *Properties) GetNSGName() string {
return p.getVMPrefix() + "nsg"
return p.GetVMPrefix() + "nsg"
}

// GetPrimaryAvailabilitySetName returns the name of the primary availability set of the cluster
Expand Down Expand Up @@ -873,6 +874,7 @@ func (p *Properties) GetClusterMetadata() *ClusterMetadata {
RouteTableName: p.GetRouteTableName(),
PrimaryAvailabilitySetName: p.GetPrimaryAvailabilitySetName(),
PrimaryScaleSetName: p.GetPrimaryScaleSetName(),
VMPrefix: p.GetVMPrefix(),
}
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/api/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1539,10 +1539,10 @@ func TestGetRouteTableName(t *testing.T) {
}

actualRTName := p.GetRouteTableName()
expectedRTName := "aks-agentpool-routetable"
expectedRTName := "aks-agentpool-28513887-routetable"

actualNSGName := p.GetNSGName()
expectedNSGName := "aks-agentpool-nsg"
expectedNSGName := "aks-agentpool-28513887-nsg"

if actualRTName != expectedRTName {
t.Errorf("expected route table name %s, but got %s", expectedRTName, actualRTName)
Expand Down Expand Up @@ -1572,10 +1572,10 @@ func TestGetRouteTableName(t *testing.T) {
}

actualRTName = p.GetRouteTableName()
expectedRTName = "k8s-master-routetable"
expectedRTName = "k8s-master-28513887-routetable"

actualNSGName = p.GetNSGName()
expectedNSGName = "k8s-master-nsg"
expectedNSGName = "k8s-master-28513887-nsg"

if actualRTName != expectedRTName {
t.Errorf("expected route table name %s, but got %s", actualRTName, expectedRTName)
Expand Down Expand Up @@ -1828,12 +1828,12 @@ func TestProperties_GetClusterMetadata(t *testing.T) {
t.Errorf("expected VirtualNetworkName name %s, but got %s", expectedVirtualNetworkName, metadata.VirtualNetworkName)
}

expectedRouteTableName := "k8s-master-routetable"
expectedRouteTableName := "k8s-master-28513887-routetable"
if metadata.RouteTableName != expectedRouteTableName {
t.Errorf("expected RouteTableName name %s, but got %s", expectedVirtualNetworkName, metadata.RouteTableName)
}

expectedSecurityGroupName := "k8s-master-nsg"
expectedSecurityGroupName := "k8s-master-28513887-nsg"
if metadata.SecurityGroupName != expectedSecurityGroupName {
t.Errorf("expected SecurityGroupName name %s, but got %s", expectedSecurityGroupName, metadata.SecurityGroupName)
}
Expand Down

0 comments on commit 83ce0a0

Please sign in to comment.