Skip to content

Commit

Permalink
Merge pull request #5262 from shiftstack/OSASINFRA-3685
Browse files Browse the repository at this point in the history
OSASINFRA-3685: openstack: tag CAPI resources with InfraID
  • Loading branch information
openshift-merge-bot[bot] authored Dec 15, 2024
2 parents d0e7d7c + bba8234 commit ba6cf38
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/content/how-to/openstack/create-openstack-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ example example 5 5 False
example-extra-az example 2 2 False False 4.17.0
```

## OpenStack resources tagging

The OpenStack resources created by the CAPI provider are tagged with `openshiftClusterID=<infraID>` but additional tags can be added to the resources
via the `HostedCluster.Spec.Platform.OpenStack.Tags` field when creating the HostedCluster with a given YAML file.

## Delete a HostedCluster

To delete a HostedCluster:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ func reconcileOpenStackClusterSpec(hcluster *hyperv1.HostedCluster, openStackClu
openStackClusterSpec.ManagedSecurityGroups = &capo.ManagedSecurityGroups{
AllNodesSecurityGroupRules: defaultWorkerSecurityGroupRules(machineNetworksToStrings(machineNetworks)),
}
openStackClusterSpec.Tags = openStackPlatform.Tags

// Users are permitted to specify additional tags to be applied to the OpenStack resources
// but the default tag will be compliant with the OpenShift Cluster ID.
openStackClusterSpec.Tags = []string{"openshiftClusterID=" + hcluster.Spec.InfraID}
openStackClusterSpec.Tags = append(openStackClusterSpec.Tags, openStackPlatform.Tags...)

return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestReconcileOpenStackCluster(t *testing.T) {
name: "CAPO provisioned network and subnet",
hostedCluster: &hyperv1.HostedCluster{
Spec: hyperv1.HostedClusterSpec{
InfraID: "cluster-123",
Networking: hyperv1.ClusterNetworking{
MachineNetwork: []hyperv1.MachineNetworkEntry{{CIDR: *ipnet.MustParseCIDR("10.0.0.0/24")}},
},
Expand Down Expand Up @@ -71,13 +72,15 @@ func TestReconcileOpenStackCluster(t *testing.T) {
ManagedSecurityGroups: &capo.ManagedSecurityGroups{
AllNodesSecurityGroupRules: defaultWorkerSecurityGroupRules([]string{"10.0.0.0/24"}),
},
Tags: []string{"openshiftClusterID=cluster-123"},
},
wantErr: false,
},
{
name: "User provided network and subnet by ID on hosted cluster",
hostedCluster: &hyperv1.HostedCluster{
Spec: hyperv1.HostedClusterSpec{
InfraID: "cluster-123",
Networking: hyperv1.ClusterNetworking{
MachineNetwork: []hyperv1.MachineNetworkEntry{{CIDR: *ipnet.MustParseCIDR("192.168.1.0/24")}},
},
Expand Down Expand Up @@ -115,13 +118,15 @@ func TestReconcileOpenStackCluster(t *testing.T) {
ManagedSecurityGroups: &capo.ManagedSecurityGroups{
AllNodesSecurityGroupRules: defaultWorkerSecurityGroupRules([]string{"192.168.1.0/24"}),
},
Tags: []string{"openshiftClusterID=cluster-123"},
},
wantErr: false,
},
{
name: "User provided network and subnet by tag on hosted cluster",
hostedCluster: &hyperv1.HostedCluster{
Spec: hyperv1.HostedClusterSpec{
InfraID: "cluster-123",
Networking: hyperv1.ClusterNetworking{
MachineNetwork: []hyperv1.MachineNetworkEntry{{CIDR: *ipnet.MustParseCIDR("192.168.1.0/24")}},
},
Expand All @@ -144,6 +149,7 @@ func TestReconcileOpenStackCluster(t *testing.T) {
},
}},
},
Tags: []string{"hcp-id=123"},
}}}},
expectedOpenStackClusterSpec: capo.OpenStackClusterSpec{
IdentityRef: capo.OpenStackIdentityReference{
Expand Down Expand Up @@ -171,6 +177,7 @@ func TestReconcileOpenStackCluster(t *testing.T) {
ManagedSecurityGroups: &capo.ManagedSecurityGroups{
AllNodesSecurityGroupRules: defaultWorkerSecurityGroupRules([]string{"192.168.1.0/24"}),
},
Tags: []string{"openshiftClusterID=cluster-123", "hcp-id=123"},
},
wantErr: false,
},
Expand Down

0 comments on commit ba6cf38

Please sign in to comment.