Skip to content

Commit a39082b

Browse files
Merge pull request openshift#8757 from shiftstack/OCPBUGS-36913
OCPBUGS-36913: openstack: Fix security group tagging
2 parents b56d954 + 99b2307 commit a39082b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/infrastructure/openstack/preprovision/securitygroups.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@ func SecurityGroups(ctx context.Context, installConfig *installconfig.InstallCon
6464
return fmt.Errorf("failed to create the Control plane security group: %w", err)
6565
}
6666

67-
if err := attributestags.Add(ctx, networkClient, "security-groups", masterGroup.ID, "openshiftClusterID="+infraID).ExtractErr(); err != nil {
67+
// The Neutron call to add a tag
68+
// (https://docs.openstack.org/api-ref/network/v2/#add-a-tag)
69+
// doesn't accept all special characters. Here we use the
70+
// "replace-all-tags" call instead, because it accepts a more
71+
// robust JSON body.
72+
//
73+
// see: https://bugzilla.redhat.com/show_bug.cgi?id=2299208
74+
if _, err := attributestags.ReplaceAll(ctx, networkClient, "security-groups", masterGroup.ID, attributestags.ReplaceAllOpts{
75+
Tags: []string{"openshiftClusterID=" + infraID},
76+
}).Extract(); err != nil {
6877
return fmt.Errorf("failed to tag the Control plane security group: %w", err)
6978
}
7079

@@ -76,7 +85,10 @@ func SecurityGroups(ctx context.Context, installConfig *installconfig.InstallCon
7685
return fmt.Errorf("failed to create the Compute security group: %w", err)
7786
}
7887

79-
if err := attributestags.Add(ctx, networkClient, "security-groups", workerGroup.ID, "openshiftClusterID="+infraID).ExtractErr(); err != nil {
88+
// See comment above
89+
if _, err := attributestags.ReplaceAll(ctx, networkClient, "security-groups", workerGroup.ID, attributestags.ReplaceAllOpts{
90+
Tags: []string{"openshiftClusterID=" + infraID},
91+
}).Extract(); err != nil {
8092
return fmt.Errorf("failed to tag the Compute security group: %w", err)
8193
}
8294
}

0 commit comments

Comments
 (0)