Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/operator/targetconfigcontroller: wait for kcm-o to generate certs…
… before rollout Signed-off-by: Sam Batschelet <sbatsche@redhat.com>
- Loading branch information
Showing
5 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
pkg/operator/targetconfigcontroller/targetconfigcontroller_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package targetconfigcontroller | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/openshift/library-go/pkg/operator/resource/resourceread" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
testBootstrapGeneratedCAPath = "testdata/bootstrap-configmap-csr-controller-ca.yaml" | ||
testKCMGeneratedCAPath = "testdata/configmap-csr-controller-ca.yaml" | ||
testNoDataCAPath = "testdata/nodata-configmap-csr-controller-ca.yaml" | ||
) | ||
|
||
func Test_ensureCSRControllerCAConfigMap(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
configMapPath string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "test CA materials generated by installer kubelet-client-ca-bundle.crt", | ||
configMapPath: testBootstrapGeneratedCAPath, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "test CA materials generated by kube-controller-manager-operator", | ||
configMapPath: testKCMGeneratedCAPath, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "test missing CA materials", | ||
configMapPath: testNoDataCAPath, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
cmBytes, err := ioutil.ReadFile(test.configMapPath) | ||
require.NoError(t, err) | ||
caConfigMap := resourceread.ReadConfigMapV1OrDie(cmBytes) | ||
gotErr := ensureCSRControllerCAConfigMap(caConfigMap) | ||
if gotErr != nil && !test.wantErr { | ||
t.Errorf("unexpected expected error %v", gotErr) | ||
} | ||
if gotErr == nil && test.wantErr { | ||
t.Errorf("expected error got nil") | ||
} | ||
}) | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
pkg/operator/targetconfigcontroller/testdata/bootstrap-configmap-csr-controller-ca.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# this is written by the kcm-o, but we initialize here to cleanly handle the adoption case | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: csr-controller-ca | ||
namespace: openshift-config-managed | ||
data: | ||
ca-bundle.crt: | | ||
-----BEGIN CERTIFICATE----- | ||
MIIDHjCCAgagAwIBAgIIPFoVWHbgcKQwDQYJKoZIhvcNAQELBQAwLTESMBAGA1UE | ||
CxMJb3BlbnNoaWZ0MRcwFQYDVQQDEw5rdWJlbGV0LXNpZ25lcjAeFw0yMTA2MzAw | ||
MjAxMzdaFw0yMTA3MDEwMjAxMzdaMC0xEjAQBgNVBAsTCW9wZW5zaGlmdDEXMBUG | ||
A1UEAxMOa3ViZWxldC1zaWduZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK | ||
AoIBAQDNneh+K8k75eaV1AlGSKVSsMJk8bwSijxmK10cpwnXkYejSvTD8IHnYHie | ||
Lx45/OCelg71D+bZJIATbPFT5UcUXymtlzXl8miFNF6VGGeycwsa+rmGiNCn7b/O | ||
QL9pOUtMi+7GVod7E8jdmQnnYaFQwXDVrA0pbz6U8fqVqBNqgxXNkySCJD0q/LMR | ||
m1utoceZ1GFIagz9Rq6X3ysI2NPprsMslLJvHHuu67KA4+jY9tUgWqzZApIiWo1J | ||
zsh/KJryD0yB4Zxmp9gxwZMbgkifguc1EPARiF44ASlSdrkLZiMzj6Rn9D0T7j1o | ||
Xk2lAQsk7oA6JzNs4L4iJT6b6iCzAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwICpDAP | ||
BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSuj6vBj5M6MgzZM3IxI4mTsIHA4TAN | ||
BgkqhkiG9w0BAQsFAAOCAQEAkQPmoUn2fTnv6EwoL61ynfKaK2wieQnPH+Kbrrrr | ||
ypceZJzEzwOToi5D1kM/P59DXMMqizyEjG4uRMSR1oSsX7qbgh5ZmIo0Z0m8uAai | ||
PKGtOfup3rK/5DzxiTqO9onq5Ri2P5OlzCYj7tRO4HIVRZgnbkfhn/Abtx+tA69r | ||
BUP87uqOIWwSVLaWv4kWHDyg6tDmL4zb2rNLwyHYp6Ox5VUPJPZmZHRe8SNPR3bO | ||
T5XAEjPryZ53W4O12h2nCxu++4WIZwUcIkMY1EK0psw9bjEGIXY3z8OdAfcKuNNn | ||
UNQlm7klBGHxxdTXaj1w2l7n/4QJkmlx8WQlIJx77yMPpg== | ||
-----END CERTIFICATE----- |
55 changes: 55 additions & 0 deletions
55
pkg/operator/targetconfigcontroller/testdata/configmap-csr-controller-ca.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
apiVersion: v1 | ||
data: | ||
ca-bundle.crt: | | ||
-----BEGIN CERTIFICATE----- | ||
MIIDODCCAiCgAwIBAgIISVOVGr6vvpgwDQYJKoZIhvcNAQELBQAwLTESMBAGA1UE | ||
CxMJb3BlbnNoaWZ0MRcwFQYDVQQDEw5rdWJlbGV0LXNpZ25lcjAeFw0yMTA2MzAw | ||
MjEyMDNaFw0yMTA3MDEwMjAxMzdaMCYxJDAiBgNVBAMMG2t1YmUtY3NyLX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Xaj1w2l7n/4QJkmlx8WQlIJx77yMPpg== | ||
-----END CERTIFICATE----- | ||
kind: ConfigMap | ||
metadata: | ||
managedFields: | ||
- apiVersion: v1 | ||
fieldsType: FieldsV1 | ||
fieldsV1: | ||
f:data: | ||
.: {} | ||
f:ca-bundle.crt: {} | ||
manager: cluster-kube-controller-manager-operator | ||
operation: Update | ||
name: csr-controller-ca | ||
namespace: openshift-config-managed |
7 changes: 7 additions & 0 deletions
7
pkg/operator/targetconfigcontroller/testdata/nodata-configmap-csr-controller-ca.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: csr-controller-ca | ||
namespace: openshift-config-managed | ||
data: | ||
ca-bundle.crt: |