-
Notifications
You must be signed in to change notification settings - Fork 253
store cluster version into clusterdeployment status #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
joelddiaz:clusterversionstatus
Dec 11, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ import ( | |
| "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
| "sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
|
|
||
| openshiftapiv1 "github.com/openshift/api/config/v1" | ||
| "github.com/openshift/hive/pkg/apis" | ||
| hivev1 "github.com/openshift/hive/pkg/apis/hive/v1alpha1" | ||
| "github.com/openshift/hive/pkg/install" | ||
|
|
@@ -61,6 +62,8 @@ const ( | |
| server: https://bar-api.clusters.example.com:6443 | ||
| name: bar | ||
| ` | ||
| testRemoteClusterCurrentVersion = "4.0.0" | ||
| remoteClusterVersionObjectName = "version" | ||
| ) | ||
|
|
||
| func init() { | ||
|
|
@@ -69,6 +72,7 @@ func init() { | |
|
|
||
| func TestClusterDeploymentReconcile(t *testing.T) { | ||
| apis.AddToScheme(scheme.Scheme) | ||
| openshiftapiv1.Install(scheme.Scheme) | ||
|
|
||
| // Utility function to get the test CD from the fake client | ||
| getCD := func(c client.Client) *hivev1.ClusterDeployment { | ||
|
|
@@ -79,6 +83,7 @@ func TestClusterDeploymentReconcile(t *testing.T) { | |
| } | ||
| return nil | ||
| } | ||
|
|
||
| getJob := func(c client.Client, name string) *batchv1.Job { | ||
| job := &batchv1.Job{} | ||
| err := c.Get(context.TODO(), client.ObjectKey{Name: name, Namespace: testNamespace}, job) | ||
|
|
@@ -182,8 +187,27 @@ func TestClusterDeploymentReconcile(t *testing.T) { | |
| }, | ||
| validate: func(c client.Client, t *testing.T) { | ||
| cd := getCD(c) | ||
| assert.Equal(t, cd.Status.APIURL, "https://bar-api.clusters.example.com:6443") | ||
| assert.Equal(t, cd.Status.WebConsoleURL, "https://bar-api.clusters.example.com:6443/console") | ||
| assert.Equal(t, "https://bar-api.clusters.example.com:6443", cd.Status.APIURL) | ||
| assert.Equal(t, "https://bar-api.clusters.example.com:6443/console", cd.Status.WebConsoleURL) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. |
||
| }, | ||
| }, | ||
| { | ||
| name: "Fetch remote cluster version status into clusterdeployment status", | ||
| existing: []runtime.Object{ | ||
| func() *hivev1.ClusterDeployment { | ||
| cd := testClusterDeployment() | ||
| cd.Status.AdminKubeconfigSecret = corev1.LocalObjectReference{Name: adminKubeconfigSecret} | ||
| return cd | ||
| }(), | ||
| testInstallJob(), | ||
| testSecret(adminKubeconfigSecret, "kubeconfig", adminKubeconfig), | ||
| testSecret(adminPasswordSecret, adminCredsSecretPasswordKey, "password"), | ||
| testSecret(pullSecretSecret, pullSecretKey, "{}"), | ||
| testSecret(sshKeySecret, adminSSHKeySecretKey, "fakesshkey"), | ||
| }, | ||
| validate: func(c client.Client, t *testing.T) { | ||
| cd := getCD(c) | ||
| assert.Equal(t, "4.0.0", cd.Status.ClusterVersionStatus.Current.Version) | ||
| }, | ||
| }, | ||
| { | ||
|
|
@@ -296,6 +320,7 @@ func TestClusterDeploymentReconcile(t *testing.T) { | |
| amiLookupFunc: func(cd *hivev1.ClusterDeployment) (string, error) { | ||
| return testAMI, nil | ||
| }, | ||
| remoteClusterAPIClientBuilder: testRemoteClusterAPIClientBuilder, | ||
| } | ||
|
|
||
| _, err := rcd.Reconcile(reconcile.Request{ | ||
|
|
@@ -446,3 +471,28 @@ func testSecret(name, key, value string) *corev1.Secret { | |
| } | ||
| return s | ||
| } | ||
|
|
||
| func testRemoteClusterAPIClientBuilder(secretData string) (client.Client, error) { | ||
| remoteClusterVersion := &openshiftapiv1.ClusterVersion{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: remoteClusterVersionObjectName, | ||
| }, | ||
| } | ||
| remoteClusterVersion.Status = testRemoteClusterVersionStatus() | ||
|
|
||
| remoteClient := fake.NewFakeClient(remoteClusterVersion) | ||
|
|
||
| return remoteClient, nil | ||
| } | ||
|
|
||
| func testRemoteClusterVersionStatus() openshiftapiv1.ClusterVersionStatus { | ||
| status := openshiftapiv1.ClusterVersionStatus{ | ||
| Current: openshiftapiv1.Update{ | ||
| Version: testRemoteClusterCurrentVersion, | ||
| Payload: "TESTPAYLOAD", | ||
| }, | ||
| Generation: 123456789, | ||
| VersionHash: "TESTVERSIONHASH", | ||
| } | ||
| return status | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realistically I think treating this as just a string will probably get us into a spot where we need to break API compatibility in the near future. We should make this a struct, the Update struct also has a Payload which looks really interesting for our purposes as well and we should.
Should we pull the FULL ClusterVersionStatus? Or just make our own and copy over parts of it? Looking through https://github.com/openshift/api/blob/master/config/v1/types_cluster_version.go#L75 we're not really interested in the Generation or VersionHash but the Conditions and the AvailableUpdates could be extremely useful. I'd be tempted to re-use their type and copy the whole thing.
Thoughts?
CC @csrwng in case he has ideas as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I think there's usefulness in embedding the entire status struct