Skip to content

Commit 4b74292

Browse files
committed
openstack: Stop generating configuration for legacy cloud provider
The legacy cloud provider read its configuration from the 'cloud.conf' key of the 'kube-system / openstack-credentials' secret. The out-of-tree one uses 'cloud.conf' key of the 'openshift-cloud-controller-manager / cloud-conf' config map. We can therefore remove the former. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 995850b commit 4b74292

File tree

5 files changed

+0
-148
lines changed

5 files changed

+0
-148
lines changed

Diff for: data/data/manifests/openshift/cloud-creds-secret.yaml.template

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ data:
1717
ibmcloud_api_key: {{.CloudCreds.IBMCloud.Base64encodeAPIKey}}
1818
{{- else if .CloudCreds.OpenStack}}
1919
clouds.yaml: {{.CloudCreds.OpenStack.Base64encodeCloudsYAML}}
20-
clouds.conf: {{.CloudCreds.OpenStack.Base64encodeCloudsConf}}
2120
{{- if .CloudCreds.OpenStack.Base64encodeCACert}}
2221
cacert: {{.CloudCreds.OpenStack.Base64encodeCACert}}
2322
{{- end}}

Diff for: pkg/asset/manifests/openshift.go

-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/openshift/installer/pkg/asset/installconfig/ovirt"
2323
"github.com/openshift/installer/pkg/asset/machines"
2424
osmachine "github.com/openshift/installer/pkg/asset/machines/openstack"
25-
openstackmanifests "github.com/openshift/installer/pkg/asset/manifests/openstack"
2625
"github.com/openshift/installer/pkg/asset/openshiftinstall"
2726
"github.com/openshift/installer/pkg/asset/password"
2827
"github.com/openshift/installer/pkg/asset/rhcos"
@@ -189,18 +188,11 @@ func (o *Openshift) Generate(ctx context.Context, dependencies asset.Parents) er
189188
return err
190189
}
191190

192-
cloudProviderConf, err := openstackmanifests.CloudProviderConfigSecret(cloud)
193-
if err != nil {
194-
return err
195-
}
196-
197191
credsEncoded := base64.StdEncoding.EncodeToString(marshalled)
198-
cloudProviderConfEncoded := base64.StdEncoding.EncodeToString(cloudProviderConf)
199192
caCertEncoded := base64.StdEncoding.EncodeToString(caCert)
200193
cloudCreds = cloudCredsSecretData{
201194
OpenStack: &OpenStackCredsSecretData{
202195
Base64encodeCloudsYAML: credsEncoded,
203-
Base64encodeCloudsConf: cloudProviderConfEncoded,
204196
Base64encodeCACert: caCertEncoded,
205197
},
206198
}

Diff for: pkg/asset/manifests/openstack/cloudproviderconfig.go

-55
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package openstack
33
import (
44
"context"
55
"os"
6-
"strconv"
7-
"strings"
86

97
"github.com/gophercloud/gophercloud/v2"
108
"github.com/gophercloud/utils/v2/openstack/clientconfig"
@@ -25,59 +23,6 @@ type Error struct {
2523
func (e Error) Error() string { return e.msg + ": " + e.err.Error() }
2624
func (e Error) Unwrap() error { return e.err }
2725

28-
// CloudProviderConfigSecret generates the cloud provider config for the OpenStack
29-
// platform, that will be stored in the system secret.
30-
// TODO: I think this is crud for the legacy cloud-provider and is no longer needed. Burn it with fire?
31-
func CloudProviderConfigSecret(cloud *clientconfig.Cloud) ([]byte, error) {
32-
domainID := cloud.AuthInfo.DomainID
33-
if domainID == "" {
34-
domainID = cloud.AuthInfo.UserDomainID
35-
}
36-
37-
domainName := cloud.AuthInfo.DomainName
38-
if domainName == "" {
39-
domainName = cloud.AuthInfo.UserDomainName
40-
}
41-
42-
// We have to generate this config manually without "go-ini" library, because its
43-
// output data is incompatible with "gcfg".
44-
// For instance, if there is a string with a # character, then "go-ini" wraps it in bacticks,
45-
// like `aaa#bbb`, but gcfg doesn't recognize it and parses the data as `aaa, skipping
46-
// everything after the #.
47-
// For more information: https://bugzilla.redhat.com/show_bug.cgi?id=1771358
48-
var res strings.Builder
49-
res.WriteString("[Global]\n")
50-
if cloud.AuthInfo.AuthURL != "" {
51-
res.WriteString("auth-url = " + strconv.Quote(cloud.AuthInfo.AuthURL) + "\n")
52-
}
53-
if cloud.AuthInfo.Username != "" {
54-
res.WriteString("username = " + strconv.Quote(cloud.AuthInfo.Username) + "\n")
55-
}
56-
if cloud.AuthInfo.Password != "" {
57-
res.WriteString("password = " + strconv.Quote(cloud.AuthInfo.Password) + "\n")
58-
}
59-
if cloud.AuthInfo.ProjectID != "" {
60-
res.WriteString("tenant-id = " + strconv.Quote(cloud.AuthInfo.ProjectID) + "\n")
61-
}
62-
if cloud.AuthInfo.ProjectName != "" {
63-
res.WriteString("tenant-name = " + strconv.Quote(cloud.AuthInfo.ProjectName) + "\n")
64-
}
65-
if domainID != "" {
66-
res.WriteString("domain-id = " + strconv.Quote(domainID) + "\n")
67-
}
68-
if domainName != "" {
69-
res.WriteString("domain-name = " + strconv.Quote(domainName) + "\n")
70-
}
71-
if cloud.RegionName != "" {
72-
res.WriteString("region = " + strconv.Quote(cloud.RegionName) + "\n")
73-
}
74-
if cloud.CACertFile != "" {
75-
res.WriteString("ca-file = /etc/kubernetes/static-pod-resources/configmaps/cloud-config/ca-bundle.pem\n")
76-
}
77-
78-
return []byte(res.String()), nil
79-
}
80-
8126
func generateCloudProviderConfig(ctx context.Context, networkClient *gophercloud.ServiceClient, cloudConfig *clientconfig.Cloud, installConfig types.InstallConfig) (cloudProviderConfigData, cloudProviderConfigCABundleData string, err error) {
8227
cloudProviderConfigData = `[Global]
8328
secret-name = openstack-credentials

Diff for: pkg/asset/manifests/openstack/cloudproviderconfig_test.go

-83
Original file line numberDiff line numberDiff line change
@@ -11,89 +11,6 @@ import (
1111
"github.com/openshift/installer/pkg/types/openstack"
1212
)
1313

14-
func TestCloudProviderConfigSecret(t *testing.T) {
15-
cloud := clientconfig.Cloud{
16-
AuthInfo: &clientconfig.AuthInfo{
17-
Username: "my_user",
18-
Password: "my_secret_password",
19-
AuthURL: "https://my_auth_url.com/v3/",
20-
ProjectID: "f12f928576ae4d21bdb984da5dd1d3bf",
21-
DomainID: "default",
22-
DomainName: "Default",
23-
},
24-
RegionName: "my_region",
25-
}
26-
27-
expectedConfig := `[Global]
28-
auth-url = "https://my_auth_url.com/v3/"
29-
username = "my_user"
30-
password = "my_secret_password"
31-
tenant-id = "f12f928576ae4d21bdb984da5dd1d3bf"
32-
domain-id = "default"
33-
domain-name = "Default"
34-
region = "my_region"
35-
`
36-
actualConfig, err := CloudProviderConfigSecret(&cloud)
37-
assert.NoError(t, err, "failed to create cloud provider config")
38-
assert.Equal(t, expectedConfig, string(actualConfig), "unexpected cloud provider config")
39-
}
40-
41-
func TestCloudProviderConfigSecretUserDomain(t *testing.T) {
42-
cloud := clientconfig.Cloud{
43-
AuthInfo: &clientconfig.AuthInfo{
44-
Username: "my_user",
45-
Password: "my_secret_password",
46-
AuthURL: "https://my_auth_url.com/v3/",
47-
ProjectID: "f12f928576ae4d21bdb984da5dd1d3bf",
48-
UserDomainID: "default",
49-
UserDomainName: "Default",
50-
},
51-
RegionName: "my_region",
52-
}
53-
54-
expectedConfig := `[Global]
55-
auth-url = "https://my_auth_url.com/v3/"
56-
username = "my_user"
57-
password = "my_secret_password"
58-
tenant-id = "f12f928576ae4d21bdb984da5dd1d3bf"
59-
domain-id = "default"
60-
domain-name = "Default"
61-
region = "my_region"
62-
`
63-
actualConfig, err := CloudProviderConfigSecret(&cloud)
64-
assert.NoError(t, err, "failed to create cloud provider config")
65-
assert.Equal(t, expectedConfig, string(actualConfig), "unexpected cloud provider config")
66-
}
67-
68-
func TestCloudProviderConfigSecretQuoting(t *testing.T) {
69-
passwords := map[string]string{
70-
"regular": "regular",
71-
"with\\n": "with\\\\n",
72-
"with#": "with#",
73-
"with$": "with$",
74-
"with;": "with;",
75-
"with \n \" \\ ": "with \\n \\\" \\\\ ",
76-
"with!": "with!",
77-
"with?": "with?",
78-
"with`": "with`",
79-
}
80-
81-
for k, v := range passwords {
82-
cloud := clientconfig.Cloud{
83-
AuthInfo: &clientconfig.AuthInfo{
84-
Password: k,
85-
},
86-
}
87-
88-
expectedConfig := `[Global]
89-
password = "` + v + `"
90-
`
91-
actualConfig, err := CloudProviderConfigSecret(&cloud)
92-
assert.NoError(t, err, "failed to create cloud provider config")
93-
assert.Equal(t, expectedConfig, string(actualConfig), "unexpected cloud provider config")
94-
}
95-
}
96-
9714
func TestCloudProviderConfig(t *testing.T) {
9815
cases := []struct {
9916
name string

Diff for: pkg/asset/manifests/template.go

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type IBMCloudCredsSecretData struct {
3535
// OpenStackCredsSecretData holds encoded credentials and is used to generate cloud-creds secret
3636
type OpenStackCredsSecretData struct {
3737
Base64encodeCloudsYAML string
38-
Base64encodeCloudsConf string
3938
Base64encodeCACert string
4039
}
4140

0 commit comments

Comments
 (0)