Skip to content

Commit

Permalink
Update MaxNameLength and use GenerateTruncName to build subnet name
Browse files Browse the repository at this point in the history
nsx-t limits the name to 80-byte.
  • Loading branch information
zhengxiexie committed Sep 5, 2023
1 parent 39a88d6 commit b5ac38e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/nsx/services/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
HashLength int = 8
MaxTagLength int = 256
MaxIdLength int = 255
MaxNameLength int = 255
MaxNameLength int = 80
TagScopeNCPCluster string = "ncp/cluster"
TagScopeNCPProjectUID string = "ncp/project_uid"
TagScopeNCPVIFProjectUID string = "ncp/vif_project_uid"
Expand Down
4 changes: 2 additions & 2 deletions pkg/nsx/services/subnet/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func (service *SubnetService) buildSubnetSetID(subnetset *v1alpha1.SubnetSet, in
}

func (service *SubnetService) buildSubnetName(subnet *v1alpha1.Subnet) string {
return util.GenerateDisplayName(subnet.ObjectMeta.Name, SUBNETPREFIX, "", "", getCluster(service))
return util.GenerateTruncName(common.MaxNameLength, subnet.ObjectMeta.Name, SUBNETPREFIX, "", "", getCluster(service))
}

func (service *SubnetService) buildSubnetSetName(subnetset *v1alpha1.SubnetSet, index string) string {
return util.GenerateDisplayName(subnetset.ObjectMeta.Name, SUBNETPREFIX, index, "", getCluster(service))
return util.GenerateTruncName(common.MaxNameLength, subnetset.ObjectMeta.Name, SUBNETPREFIX, index, "", getCluster(service))
}

func (service *SubnetService) buildSubnet(obj client.Object, tags []model.Tag) (*model.VpcSubnet, error) {
Expand Down

0 comments on commit b5ac38e

Please sign in to comment.