Skip to content

Commit 58a5a19

Browse files
Merge pull request #726 from deads2k/apply-12-test-data
API-1835: first integration-tests
2 parents ddb8960 + 8fda981 commit 58a5a19

File tree

81 files changed

+1511
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1511
-106
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ tags
1919
.envrc
2020
authentication-operator
2121
telepresence.log
22+
/test-output/

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ require (
99
github.com/openshift/api v0.0.0-20241001152557-e415140e5d5f
1010
github.com/openshift/build-machinery-go v0.0.0-20241025131534-5f3bc3c56265
1111
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f
12-
github.com/openshift/library-go v0.0.0-20241025192116-97dc382cad13
13-
github.com/openshift/multi-operator-manager v0.0.0-20241028172628-4e6de0af517a
12+
github.com/openshift/library-go v0.0.0-20241028193827-a808e2fb8060
13+
github.com/openshift/multi-operator-manager v0.0.0-20241029144625-19a490bc33c3
1414
github.com/spf13/cobra v1.8.1
1515
github.com/stretchr/testify v1.9.0
1616
go.etcd.io/etcd/client/v3 v3.5.14

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ github.com/openshift/build-machinery-go v0.0.0-20241025131534-5f3bc3c56265 h1:FT
148148
github.com/openshift/build-machinery-go v0.0.0-20241025131534-5f3bc3c56265/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
149149
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f h1:FRc0bVNWprihWS0GqQWzb3dY4dkCwpOP3mDw5NwSoR4=
150150
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f/go.mod h1:KiZi2mJRH1TOJ3FtBDYS6YvUL30s/iIXaGSUrSa36mo=
151-
github.com/openshift/library-go v0.0.0-20241025192116-97dc382cad13 h1:59NslqHDdxffgFww2qnzc6HZ1OHvfVzkUpEICiZAvok=
152-
github.com/openshift/library-go v0.0.0-20241025192116-97dc382cad13/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0=
153-
github.com/openshift/multi-operator-manager v0.0.0-20241028172628-4e6de0af517a h1:ru37iQH7O+lqv4H8a2QTOYp+ZCajf6MS02a3HouEFrc=
154-
github.com/openshift/multi-operator-manager v0.0.0-20241028172628-4e6de0af517a/go.mod h1:/gSz0z+w5wjpnbsCvE/uo+Tu4xKG7iZKKWMh3skmfRw=
151+
github.com/openshift/library-go v0.0.0-20241028193827-a808e2fb8060 h1:Dvja54+vTv/ZZVoY/sCnh8bacSRdJPdkPeLuVOt8hmE=
152+
github.com/openshift/library-go v0.0.0-20241028193827-a808e2fb8060/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0=
153+
github.com/openshift/multi-operator-manager v0.0.0-20241029144625-19a490bc33c3 h1:GeSci9SzTgK47WEArLskz4GlL+VsxGFEnt6avuxw3GA=
154+
github.com/openshift/multi-operator-manager v0.0.0-20241029144625-19a490bc33c3/go.mod h1:/gSz0z+w5wjpnbsCvE/uo+Tu4xKG7iZKKWMh3skmfRw=
155155
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
156156
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
157157
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

pkg/cmd/mom/apply_configuration_command.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ func NewApplyConfigurationCommand(streams genericiooptions.IOStreams) *cobra.Com
1515
}
1616

1717
func RunApplyConfiguration(ctx context.Context, input libraryapplyconfiguration.ApplyConfigurationInput) (libraryapplyconfiguration.AllDesiredMutationsGetter, error) {
18-
// TODO initialize dynamic clients, informers, operator clients, and kubeclients from the input to demonstrate.
19-
2018
authenticationOperatorInput, err := operator.CreateOperatorInputFromMOM(ctx, input)
2119
if err != nil {
2220
return nil, fmt.Errorf("unable to configure operator input: %w", err)

pkg/cmd/mom/output_resources_command.go

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,58 @@ func RunOutputResources(ctx context.Context) (*libraryoutputresources.OutputReso
1616
return &libraryoutputresources.OutputResources{
1717
ConfigurationResources: libraryoutputresources.ResourceList{
1818
ExactResources: []libraryoutputresources.ExactResourceID{
19-
exactResource("config.openshift.io", "ingresses", "", "cluster"),
19+
libraryoutputresources.ExactResource("config.openshift.io", "ingresses", "", "cluster"),
2020
},
2121
},
2222
ManagementResources: libraryoutputresources.ResourceList{
2323
ExactResources: []libraryoutputresources.ExactResourceID{
24-
exactResource("config.openshift.io", "clusteroperators", "", "authentication"),
25-
exactResource("openshift.openshift.io", "authentications", "", "cluster"),
24+
libraryoutputresources.ExactClusterOperator("authentication"),
25+
libraryoutputresources.ExactConfigMap("openshift-authentication", "audit"),
26+
libraryoutputresources.ExactConfigMap("openshift-authentication", "v4-0-config-system-trusted-ca-bundle"),
27+
libraryoutputresources.ExactDeployment("openshift-authentication", "oauth-openshift"),
28+
libraryoutputresources.ExactLowLevelOperator("authentications"),
29+
exactNamespace("openshift-authentication"),
30+
exactRole("openshift-config-managed", "system:openshift:oauth-servercert-trust"),
31+
exactRoleBinding("openshift-config-managed", "system:openshift:oauth-servercert-trust"),
32+
libraryoutputresources.ExactSecret("openshift-authentication", "v4-0-config-system-session"),
33+
libraryoutputresources.ExactSecret("openshift-authentication", "v4-0-config-system-ocp-branding-template"),
34+
exactService("openshift-authentication", "oauth-openshift"),
35+
libraryoutputresources.ExactServiceAccount("openshift-authentication", "oauth-openshift"),
36+
},
37+
EventingNamespaces: []string{
38+
"openshift-authentication-operator",
2639
},
2740
},
2841
UserWorkloadResources: libraryoutputresources.ResourceList{
2942
ExactResources: []libraryoutputresources.ExactResourceID{
30-
exactResource("", "secrets", "openshift-authentication", "v4-0-config-system-session"),
31-
exactResource("", "secrets", "openshift-authentication", "v4-0-config-system-ocp-branding-template"),
32-
exactResource("", "serviceaccounts", "openshift-authentication", "oauth-openshift"),
33-
exactResource("apps", "deployments", "openshift-authentication", "oauth-openshift"),
34-
exactResource("oauth.openshift.io", "oauthclients", "", "openshift-browser-client"),
35-
exactResource("oauth.openshift.io", "oauthclients", "", "openshift-challenging-client"),
36-
exactResource("oauth.openshift.io", "oauthclients", "", "openshift-cli-client"),
37-
exactResource("rbac.authorization.k8s.io", "clusterrolebindings", "", "system:openshift:openshift-authentication"),
38-
exactResource("rbac.authorization.k8s.io", "rolebindings", "openshift-config-managed", "system:openshift:oauth-servercert-trust"),
39-
exactResource("rbac.authorization.k8s.io", "roles", "openshift-config-managed", "system:openshift:oauth-servercert-trust"),
43+
libraryoutputresources.ExactClusterRoleBinding("system:openshift:openshift-authentication"),
44+
exactOAuthClient("openshift-browser-client"),
45+
exactOAuthClient("openshift-challenging-client"),
46+
exactOAuthClient("openshift-cli-client"),
4047
},
4148
GeneratedNameResources: []libraryoutputresources.GeneratedResourceID{
42-
generatedResource("certificates.k8s.io", "certificatesigningrequests", "", "system:openshift:openshift-authenticator-"),
49+
libraryoutputresources.GeneratedCSR("system:openshift:openshift-authenticator-"),
4350
},
4451
},
4552
}, nil
4653
}
4754

48-
func exactResource(group, resource, namespace, name string) libraryoutputresources.ExactResourceID {
49-
return libraryoutputresources.ExactResourceID{
50-
OutputResourceTypeIdentifier: libraryoutputresources.OutputResourceTypeIdentifier{
51-
Group: group,
52-
Resource: resource,
53-
},
54-
Namespace: namespace,
55-
Name: name,
56-
}
55+
func exactOAuthClient(name string) libraryoutputresources.ExactResourceID {
56+
return libraryoutputresources.ExactResource("oauth.openshift.io", "oauthclients", "", name)
5757
}
5858

59-
func generatedResource(group, resource, namespace, name string) libraryoutputresources.GeneratedResourceID {
60-
return libraryoutputresources.GeneratedResourceID{
61-
OutputResourceTypeIdentifier: libraryoutputresources.OutputResourceTypeIdentifier{
62-
Group: group,
63-
Resource: resource,
64-
},
65-
Namespace: namespace,
66-
GeneratedName: name,
67-
}
59+
func exactNamespace(name string) libraryoutputresources.ExactResourceID {
60+
return libraryoutputresources.ExactResource("", "namespaces", "", name)
61+
}
62+
63+
func exactService(namespace, name string) libraryoutputresources.ExactResourceID {
64+
return libraryoutputresources.ExactResource("", "services", namespace, name)
65+
}
66+
67+
func exactRole(namespace, name string) libraryoutputresources.ExactResourceID {
68+
return libraryoutputresources.ExactResource("rbac.authorization.k8s.io", "roles", namespace, name)
69+
}
70+
71+
func exactRoleBinding(namespace, name string) libraryoutputresources.ExactResourceID {
72+
return libraryoutputresources.ExactResource("rbac.authorization.k8s.io", "rolebindings", namespace, name)
6873
}

pkg/operator/replacement_starter.go

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,36 @@ type authenticationOperatorInput struct {
5959
const componentName = "cluster-authentication-operator"
6060

6161
func CreateOperatorInputFromMOM(ctx context.Context, momInput libraryapplyconfiguration.ApplyConfigurationInput) (*authenticationOperatorInput, error) {
62-
kubeClient, err := kubernetes.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
62+
// TODO replace with the library-go function in https://github.com/openshift/library-go/pull/1857 once it merges
63+
recommendedRESTConfig := &rest.Config{
64+
QPS: 1000,
65+
Burst: 10000,
66+
}
67+
kubeClient, err := kubernetes.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
6368
if err != nil {
6469
return nil, err
6570
}
66-
configClient, err := configclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
71+
configClient, err := configclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
6772
if err != nil {
6873
return nil, err
6974
}
70-
operatorClient, err := operatorclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
75+
operatorClient, err := operatorclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
7176
if err != nil {
7277
return nil, err
7378
}
74-
routeClient, err := routeclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
79+
routeClient, err := routeclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
7580
if err != nil {
7681
return nil, err
7782
}
78-
oauthClient, err := oauthclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
83+
oauthClient, err := oauthclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
7984
if err != nil {
8085
return nil, err
8186
}
82-
apiregistrationv1Client, err := apiregistrationclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
87+
apiregistrationv1Client, err := apiregistrationclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
8388
if err != nil {
8489
return nil, err
8590
}
86-
migrationClient, err := kubemigratorclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
91+
migrationClient, err := kubemigratorclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
8792
if err != nil {
8893
return nil, err
8994
}
@@ -100,16 +105,25 @@ func CreateOperatorInputFromMOM(ctx context.Context, momInput libraryapplyconfig
100105
return nil, err
101106
}
102107

103-
eventRecorder := events.NewKubeRecorderWithOptions(
104-
kubeClient.CoreV1().Events("openshift-authentication-operator"),
105-
events.RecommendedClusterSingletonCorrelatorOptions(),
108+
//eventRecorder := events.NewKubeRecorderWithOptions(
109+
// kubeClient.CoreV1().Events("openshift-authentication-operator"),
110+
// events.RecommendedClusterSingletonCorrelatorOptions(),
111+
// componentName,
112+
// &corev1.ObjectReference{
113+
// Kind: "Deployment",
114+
// Namespace: "openshift-authentication-operator",
115+
// Name: "authentication-operator",
116+
// },
117+
//)
118+
// TODO figure out if we're better off using the event correlator (possible) and making a flush of some kind or if live write are better
119+
// but for now don't lose it.
120+
eventRecorder := events.NewRecorder(kubeClient.CoreV1().Events("openshift-authentication-operator"),
106121
componentName,
107122
&corev1.ObjectReference{
108123
Kind: "Deployment",
109124
Namespace: "openshift-authentication-operator",
110125
Name: "authentication-operator",
111-
},
112-
)
126+
})
113127

114128
return &authenticationOperatorInput{
115129
kubeClient: kubeClient,
@@ -299,7 +313,7 @@ func CreateOperatorStarter(ctx context.Context, authOperatorInput *authenticatio
299313

300314
oauthAPIServerRunOnceFns, oauthAPIServerRunFns, err := prepareOauthAPIServerOperator(ctx, authOperatorInput, informerFactories, resourceSyncer, versionRecorder)
301315
if err != nil {
302-
return nil, fmt.Errorf("unable to prepare oauth server: %w", err)
316+
return nil, fmt.Errorf("unable to prepare oauth apiserver: %w", err)
303317
}
304318
ret.ControllerRunFns = append(ret.ControllerRunFns, oauthAPIServerRunFns...)
305319
ret.ControllerNamedRunOnceFns = append(ret.ControllerNamedRunOnceFns, oauthAPIServerRunOnceFns...)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: operator.openshift.io/v1
2+
kind: Authentication
3+
metadata:
4+
annotations:
5+
operator.openshift.io/controller-name: TODO-resourceSyncer
6+
name: cluster
7+
status:
8+
conditions:
9+
- lastTransitionTime: "2024-10-14T22:38:20Z"
10+
message: an error on the server ("request namespace \"openshift-oauth-apiserver\"
11+
does not equal body namespace \"\"") has prevented the request from succeeding
12+
(delete secrets etcd-client)
13+
reason: Error
14+
status: "True"
15+
type: ResourceSyncControllerDegraded
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fieldManager: oauth-server-ResourceSync
2+
force: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: operator.openshift.io/v1
2+
kind: Authentication
3+
metadata:
4+
annotations:
5+
operator.openshift.io/controller-name: TODO-configOverridesController
6+
name: cluster
7+
status:
8+
conditions:
9+
- lastTransitionTime: "2024-10-14T22:38:20Z"
10+
reason: NoUnsupportedConfigOverrides
11+
status: "True"
12+
type: UnsupportedConfigOverridesUpgradeable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fieldManager: openshift-authentication-UnsupportedConfigOverrides
2+
force: true

0 commit comments

Comments
 (0)