Skip to content

Commit

Permalink
openstack: Stop passing cluster tags
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman committed Dec 22, 2022
1 parent d9d78df commit 0c88d88
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 25 deletions.
4 changes: 1 addition & 3 deletions pkg/model/openstackmodel/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ type OpenstackModelContext struct {

func (c *OpenstackModelContext) createCloud() (openstack.OpenstackCloud, error) {
if c.cloud == nil {
tags := make(map[string]string)
tags[openstack.TagClusterName] = c.ClusterName()
osCloud, err := openstack.NewOpenstackCloud(tags, c.Cluster, "openstackmodel")
osCloud, err := openstack.NewOpenstackCloud(c.Cluster, "openstackmodel")
if err != nil {
return nil, err
}
Expand Down
6 changes: 1 addition & 5 deletions protokube/pkg/protokube/openstack_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,7 @@ func NewOpenStackCloudProvider() (*OpenStackCloudProvider, error) {
return nil, fmt.Errorf("Failed to get server metadata: %v", err)
}

tags := make(map[string]string)
// Cluster name needed to bypass missing designate options
tags[openstack.TagClusterName] = metadata.UserMeta.ClusterName

oscloud, err := openstack.NewOpenstackCloud(tags, nil, "protokube")
oscloud, err := openstack.NewOpenstackCloud(nil, "protokube")
if err != nil {
return nil, fmt.Errorf("Failed to initialize OpenStackCloudProvider: %v", err)
}
Expand Down
20 changes: 6 additions & 14 deletions upup/pkg/fi/cloudup/new_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,7 @@ func NewCluster(opt *NewClusterOptions, clientset simple.Clientset) (*NewCluster
MaxRetries: fi.PtrTo(3),
},
}
tags := make(map[string]string)
tags[openstack.TagClusterName] = cluster.GetName()
osCloud, err := openstack.NewOpenstackCloud(tags, cluster, "openstackmodel")
osCloud, err := openstack.NewOpenstackCloud(cluster, "openstackmodel")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -572,9 +570,7 @@ func setupVPC(opt *NewClusterOptions, cluster *api.Cluster, cloud fi.Cloud) erro
}

if cluster.Spec.Networking.NetworkID == "" && len(opt.SubnetIDs) > 0 {
tags := make(map[string]string)
tags[openstack.TagClusterName] = cluster.Name
osCloud, err := openstack.NewOpenstackCloud(tags, cluster, "new-cluster-setupvpc")
osCloud, err := openstack.NewOpenstackCloud(cluster, "new-cluster-setupvpc")
if err != nil {
return fmt.Errorf("error loading cloud: %v", err)
}
Expand Down Expand Up @@ -716,9 +712,7 @@ func setupZones(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.Stri

case api.CloudProviderOpenstack:
if len(opt.Zones) > 0 && len(opt.SubnetIDs) > 0 {
tags := make(map[string]string)
tags[openstack.TagClusterName] = cluster.Name
zoneToSubnetProviderID, err = getOpenstackZoneToSubnetProviderID(cluster, allZones.List(), opt.SubnetIDs, tags)
zoneToSubnetProviderID, err = getOpenstackZoneToSubnetProviderID(cluster, allZones.List(), opt.SubnetIDs)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -783,9 +777,9 @@ func getAWSZoneToSubnetProviderID(VPCID string, region string, subnetIDs []strin
return res, nil
}

func getOpenstackZoneToSubnetProviderID(cluster *api.Cluster, zones []string, subnetIDs []string, tags map[string]string) (map[string]string, error) {
func getOpenstackZoneToSubnetProviderID(cluster *api.Cluster, zones []string, subnetIDs []string) (map[string]string, error) {
res := make(map[string]string)
osCloud, err := openstack.NewOpenstackCloud(tags, cluster, "new-cluster-zone-to-subnet")
osCloud, err := openstack.NewOpenstackCloud(cluster, "new-cluster-zone-to-subnet")
if err != nil {
return res, fmt.Errorf("error loading cloud: %v", err)
}
Expand Down Expand Up @@ -1210,9 +1204,7 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S
return nil, err
}
case api.CloudProviderOpenstack:
tags := make(map[string]string)
tags[openstack.TagClusterName] = cluster.Name
zoneToSubnetProviderID, err = getOpenstackZoneToSubnetProviderID(cluster, allZones.List(), opt.UtilitySubnetIDs, tags)
zoneToSubnetProviderID, err = getOpenstackZoneToSubnetProviderID(cluster, allZones.List(), opt.UtilitySubnetIDs)
if err != nil {
return nil, err
}
Expand Down
6 changes: 5 additions & 1 deletion upup/pkg/fi/cloudup/openstack/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ var _ fi.Cloud = &openstackCloud{}

var openstackCloudInstances = make(map[string]OpenstackCloud)

func NewOpenstackCloud(tags map[string]string, cluster *kops.Cluster, uagent string) (OpenstackCloud, error) {
func NewOpenstackCloud(cluster *kops.Cluster, uagent string) (OpenstackCloud, error) {
config := vfs.OpenstackConfig{}

region, err := config.GetRegion()
Expand Down Expand Up @@ -363,6 +363,10 @@ func NewOpenstackCloud(tags map[string]string, cluster *kops.Cluster, uagent str
return nil, fmt.Errorf("error building openstack authenticated client: %v", err)
}

tags := map[string]string{
TagClusterName: cluster.Name,
}

hasDNS := !cluster.IsGossip() && !cluster.UsesNoneDNS()
return buildClients(provider, tags, cluster.Spec.CloudProvider.Openstack, config, region, hasDNS)
}
Expand Down
3 changes: 1 addition & 2 deletions upup/pkg/fi/cloudup/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ func BuildCloud(cluster *kops.Cluster) (fi.Cloud, error) {

case kops.CloudProviderOpenstack:
{
cloudTags := map[string]string{openstack.TagClusterName: cluster.ObjectMeta.Name}
osc, err := openstack.NewOpenstackCloud(cloudTags, cluster, "build-cloud")
osc, err := openstack.NewOpenstackCloud(cluster, "build-cloud")
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 0c88d88

Please sign in to comment.