From 0db13aadf7da355c1ec6cb9b85bd88b92ee0a773 Mon Sep 17 00:00:00 2001 From: cadenmarchese Date: Fri, 10 May 2024 09:33:19 -0400 Subject: [PATCH 1/7] add field and type, make client, converters --- .sha256sum | 2 +- pkg/api/admin/openshiftcluster.go | 4 ++ pkg/api/openshiftcluster.go | 4 ++ pkg/api/v20240812preview/openshiftcluster.go | 4 ++ .../openshiftcluster_convert.go | 12 ++++ .../redhatopenshift/models.go | 1 + pkg/cluster/arooperator.go | 4 ++ pkg/cluster/install.go | 1 + pkg/operator/deploy/deploy.go | 33 +++++++++ pkg/operator/deploy/deploy_test.go | 70 +++++++++++++++++++ pkg/util/mocks/operator/deploy/deploy.go | 14 ++++ .../v2024_08_12_preview/models/_models.py | 8 +++ .../v2024_08_12_preview/models/_models_py3.py | 9 +++ .../2024-08-12-preview/redhatopenshift.json | 7 ++ 14 files changed, 172 insertions(+), 1 deletion(-) diff --git a/.sha256sum b/.sha256sum index 8fae07dc734..4f9a06e1463 100644 --- a/.sha256sum +++ b/.sha256sum @@ -6,4 +6,4 @@ b1f1de0fe40d05de90742b17928968923b936adc294000f58974f50a297581dd swagger/redhat c023515341196746454c0ae7af077d40d3ec13f6b88b33cb558f0a7ab17a5a24 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2023-07-01-preview/redhatopenshift.json 440748951dd1c3b34b5ccbdcb7cd966e3b89490887a1f1d64429561fad789515 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-09-04/redhatopenshift.json 74a46fdde6ceb0121fe1515c7e11e902dd921b54cffe693307fb02b3dc88f26e swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-11-22/redhatopenshift.json -a27184734436629e24b344c3b5c015437f144e18e7eddce7e252a1ed4cda7bca swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json +76e20d8da5c40013e0b5133bb454ba48a86aab9ad9563f53c8d32b7526bebc19 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json diff --git a/pkg/api/admin/openshiftcluster.go b/pkg/api/admin/openshiftcluster.go index d1bab4bb6ea..de790d76968 100644 --- a/pkg/api/admin/openshiftcluster.go +++ b/pkg/api/admin/openshiftcluster.go @@ -418,9 +418,13 @@ type IngressProfile struct { // PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters. type PlatformWorkloadIdentityProfile struct { + UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty"` PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"` } +// UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to +type UpgradeableTo string + // PlatformWorkloadIdentity stores information representing a single workload identity. type PlatformWorkloadIdentity struct { OperatorName string `json:"operatorName,omitempty"` diff --git a/pkg/api/openshiftcluster.go b/pkg/api/openshiftcluster.go index 0826520d0bb..f4efa59c51f 100644 --- a/pkg/api/openshiftcluster.go +++ b/pkg/api/openshiftcluster.go @@ -773,9 +773,13 @@ type HiveProfile struct { type PlatformWorkloadIdentityProfile struct { MissingFields + UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty"` PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"` } +// UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to +type UpgradeableTo string + // PlatformWorkloadIdentity stores information representing a single workload identity. type PlatformWorkloadIdentity struct { MissingFields diff --git a/pkg/api/v20240812preview/openshiftcluster.go b/pkg/api/v20240812preview/openshiftcluster.go index 09a5a632dbf..474b15f9d1c 100644 --- a/pkg/api/v20240812preview/openshiftcluster.go +++ b/pkg/api/v20240812preview/openshiftcluster.go @@ -290,9 +290,13 @@ type IngressProfile struct { // PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters. type PlatformWorkloadIdentityProfile struct { + UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty"` PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"` } +// UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to +type UpgradeableTo string + // PlatformWorkloadIdentity stores information representing a single workload identity. type PlatformWorkloadIdentity struct { OperatorName string `json:"operatorName,omitempty"` diff --git a/pkg/api/v20240812preview/openshiftcluster_convert.go b/pkg/api/v20240812preview/openshiftcluster_convert.go index ad51f440659..078d0ad7fde 100644 --- a/pkg/api/v20240812preview/openshiftcluster_convert.go +++ b/pkg/api/v20240812preview/openshiftcluster_convert.go @@ -141,6 +141,12 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac if oc.Properties.PlatformWorkloadIdentityProfile != nil && oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities != nil { out.Properties.PlatformWorkloadIdentityProfile = &PlatformWorkloadIdentityProfile{} + + if oc.Properties.PlatformWorkloadIdentityProfile.UpgradeableTo != nil { + temp := UpgradeableTo(*oc.Properties.PlatformWorkloadIdentityProfile.UpgradeableTo) + out.Properties.PlatformWorkloadIdentityProfile.UpgradeableTo = &temp + } + out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities = make([]PlatformWorkloadIdentity, len(oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities)) for i := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities { @@ -225,6 +231,12 @@ func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShif } if oc.Properties.PlatformWorkloadIdentityProfile != nil && oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities != nil { out.Properties.PlatformWorkloadIdentityProfile = &api.PlatformWorkloadIdentityProfile{} + + if oc.Properties.PlatformWorkloadIdentityProfile.UpgradeableTo != nil { + temp := api.UpgradeableTo(*oc.Properties.PlatformWorkloadIdentityProfile.UpgradeableTo) + out.Properties.PlatformWorkloadIdentityProfile.UpgradeableTo = &temp + } + out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities = make([]api.PlatformWorkloadIdentity, len(oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities)) for i := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities { diff --git a/pkg/client/services/redhatopenshift/mgmt/2024-08-12-preview/redhatopenshift/models.go b/pkg/client/services/redhatopenshift/mgmt/2024-08-12-preview/redhatopenshift/models.go index e438d5fc15b..2535b27f728 100644 --- a/pkg/client/services/redhatopenshift/mgmt/2024-08-12-preview/redhatopenshift/models.go +++ b/pkg/client/services/redhatopenshift/mgmt/2024-08-12-preview/redhatopenshift/models.go @@ -1525,6 +1525,7 @@ func (pwi PlatformWorkloadIdentity) MarshalJSON() ([]byte, error) { // PlatformWorkloadIdentityProfile platformWorkloadIdentityProfile encapsulates all information that is // specific to workload identity clusters. type PlatformWorkloadIdentityProfile struct { + UpgradeableTo *string `json:"upgradeableTo,omitempty"` PlatformWorkloadIdentities *[]PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"` } diff --git a/pkg/cluster/arooperator.go b/pkg/cluster/arooperator.go index 7afbb5b3c9d..db672124c11 100644 --- a/pkg/cluster/arooperator.go +++ b/pkg/cluster/arooperator.go @@ -65,6 +65,10 @@ func (m *manager) ensureCredentialsRequest(ctx context.Context) error { return m.aroOperatorDeployer.CreateOrUpdateCredentialsRequest(ctx) } +func (m *manager) ensureUpgradeAnnotations(ctx context.Context) error { + return m.aroOperatorDeployer.EnsureUpgradeAnnotations(ctx) +} + func (m *manager) renewMDSDCertificate(ctx context.Context) error { return m.aroOperatorDeployer.RenewMDSDCertificate(ctx) } diff --git a/pkg/cluster/install.go b/pkg/cluster/install.go index 5e14d57ef16..ea177fe7262 100644 --- a/pkg/cluster/install.go +++ b/pkg/cluster/install.go @@ -213,6 +213,7 @@ func (m *manager) Update(ctx context.Context) error { steps.Action(m.updateAROSecret), steps.Action(m.restartAROOperatorMaster), // depends on m.updateOpenShiftSecret; the point of restarting is to pick up any changes made to the secret steps.Condition(m.aroDeploymentReady, 5*time.Minute, true), + steps.Action(m.ensureUpgradeAnnotations), steps.Action(m.reconcileLoadBalancerProfile), } diff --git a/pkg/operator/deploy/deploy.go b/pkg/operator/deploy/deploy.go index ab18e2505a4..4cb41f37b5d 100644 --- a/pkg/operator/deploy/deploy.go +++ b/pkg/operator/deploy/deploy.go @@ -14,6 +14,7 @@ import ( "time" "github.com/hashicorp/go-multierror" + operatorclient "github.com/openshift/client-go/operator/clientset/versioned" "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" extensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -56,6 +57,7 @@ type Operator interface { Restart(context.Context, []string) error IsRunningDesiredVersion(context.Context) (bool, error) RenewMDSDCertificate(context.Context) error + EnsureUpgradeAnnotations(context.Context) error } type operator struct { @@ -67,6 +69,7 @@ type operator struct { client client.Client extensionscli extensionsclient.Interface kubernetescli kubernetes.Interface + operatorcli operatorclient.Interface dh dynamichelper.Interface } @@ -432,6 +435,36 @@ func (o *operator) RenewMDSDCertificate(ctx context.Context) error { return nil } +func (o *operator) EnsureUpgradeAnnotations(ctx context.Context) error { + if o.oc.Properties.PlatformWorkloadIdentityProfile == nil { + return nil + } + + if o.oc.Properties.ServicePrincipalProfile != nil { + return nil + } + + upgradeableTo := string(*o.oc.Properties.PlatformWorkloadIdentityProfile.UpgradeableTo) + + cloudcredentialobject, err := o.operatorcli.OperatorV1().CloudCredentials().List(ctx, metav1.ListOptions{}) + if err != nil { + return err + } + + for _, v := range cloudcredentialobject.Items { + v.Annotations = map[string]string{ + "cloudcredential.openshift.io/upgradeable-to": upgradeableTo, + } + + _, err = o.operatorcli.OperatorV1().CloudCredentials().Update(ctx, &v, metav1.UpdateOptions{}) + if err != nil { + return err + } + } + + return nil +} + func (o *operator) IsReady(ctx context.Context) (bool, error) { ok, err := ready.CheckDeploymentIsReady(ctx, o.kubernetescli.AppsV1().Deployments(pkgoperator.Namespace), "aro-operator-master")() o.log.Infof("deployment %q ok status is: %v, err is: %v", "aro-operator-master", ok, err) diff --git a/pkg/operator/deploy/deploy_test.go b/pkg/operator/deploy/deploy_test.go index 6002e65dd7d..ec2dccee397 100644 --- a/pkg/operator/deploy/deploy_test.go +++ b/pkg/operator/deploy/deploy_test.go @@ -10,6 +10,7 @@ import ( "github.com/golang/mock/gomock" configv1 "github.com/openshift/api/config/v1" + operatorv1 "github.com/openshift/api/operator/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -461,3 +462,72 @@ func TestCheckPodImageVersion(t *testing.T) { }) } } + +func TestEnsureUpgradeAnnotations(t *testing.T) { + //UpgradeableTo1 := api.UpgradeableTo("4.14.59") + + for _, tt := range []struct { + name string + cluster api.OpenShiftCluster + annotation map[string]string + wantAnnotation map[string]string + wantErr string + }{ + { + name: "nil PlatformWorkloadIdentityProfile, no version persisted in cluster document", + }, + { + name: "non-nil ServicePrincipalProfile, no version persisted in cluster document", + cluster: api.OpenShiftCluster{ + Properties: api.OpenShiftClusterProperties{ + ServicePrincipalProfile: &api.ServicePrincipalProfile{ + ClientID: "", + ClientSecret: "", + }, + PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{}, + }, + }, + }, + // { + // name: "no version persisted in cluster document, persist it", + // cluster: api.OpenShiftCluster{ + // Properties: api.OpenShiftClusterProperties{ + // PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{ + // UpgradeableTo: &UpgradeableTo1, + // }, + // }, + // }, + // annotation: nil, + // wantAnnotation: map[string]string{ + // "cloudcredential.openshift.io/upgradeable-to": "4.14.59", + // }, + // }, + } { + t.Run(tt.name, func(t *testing.T) { + ctx := context.Background() + controller := gomock.NewController(t) + defer controller.Finish() + + env := mock_env.NewMockInterface(controller) + oc := &tt.cluster + + cloudcredentialobject := &operatorv1.CloudCredential{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: tt.annotation, + }, + } + + o := operator{ + oc: oc, + env: env, + client: ctrlfake.NewClientBuilder().WithObjects(cloudcredentialobject).Build(), + } + + err := o.EnsureUpgradeAnnotations(ctx) + utilerror.AssertErrorMessage(t, err, tt.wantErr) + if !reflect.DeepEqual(tt.annotation, tt.wantAnnotation) { + t.Errorf("actual annotation: %v, wanted %v", tt.annotation, tt.wantAnnotation) + } + }) + } +} diff --git a/pkg/util/mocks/operator/deploy/deploy.go b/pkg/util/mocks/operator/deploy/deploy.go index 99ad4f2243b..f3536da8087 100644 --- a/pkg/util/mocks/operator/deploy/deploy.go +++ b/pkg/util/mocks/operator/deploy/deploy.go @@ -62,6 +62,20 @@ func (mr *MockOperatorMockRecorder) CreateOrUpdateCredentialsRequest(arg0 interf return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdateCredentialsRequest", reflect.TypeOf((*MockOperator)(nil).CreateOrUpdateCredentialsRequest), arg0) } +// EnsureUpgradeAnnotations mocks base method. +func (m *MockOperator) EnsureUpgradeAnnotations(arg0 context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EnsureUpgradeAnnotations", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// EnsureUpgradeAnnotations indicates an expected call of EnsureUpgradeAnnotations. +func (mr *MockOperatorMockRecorder) EnsureUpgradeAnnotations(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsureUpgradeAnnotations", reflect.TypeOf((*MockOperator)(nil).EnsureUpgradeAnnotations), arg0) +} + // IsReady mocks base method. func (m *MockOperator) IsReady(arg0 context.Context) (bool, error) { m.ctrl.T.Helper() diff --git a/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models.py b/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models.py index 3e77e23023c..3d6c4bfa60f 100644 --- a/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models.py +++ b/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models.py @@ -1303,12 +1303,16 @@ def __init__( class PlatformWorkloadIdentityProfile(msrest.serialization.Model): """PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters. + :ivar upgradeable_to: UpgradeableTo stores a single OpenShift version a workload idetntiy + cluster can be upgraded to. + :vartype upgradeable_to: str :ivar platform_workload_identities: :vartype platform_workload_identities: list[~azure.mgmt.redhatopenshift.v2024_08_12_preview.models.PlatformWorkloadIdentity] """ _attribute_map = { + 'upgradeable_to': {'key': 'upgradeableTo', 'type': 'str'}, 'platform_workload_identities': {'key': 'platformWorkloadIdentities', 'type': '[PlatformWorkloadIdentity]'}, } @@ -1317,11 +1321,15 @@ def __init__( **kwargs ): """ + :keyword upgradeable_to: UpgradeableTo stores a single OpenShift version a workload idetntiy + cluster can be upgraded to. + :paramtype upgradeable_to: str :keyword platform_workload_identities: :paramtype platform_workload_identities: list[~azure.mgmt.redhatopenshift.v2024_08_12_preview.models.PlatformWorkloadIdentity] """ super(PlatformWorkloadIdentityProfile, self).__init__(**kwargs) + self.upgradeable_to = kwargs.get('upgradeable_to', None) self.platform_workload_identities = kwargs.get('platform_workload_identities', None) diff --git a/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models_py3.py b/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models_py3.py index 9828713ff69..e38a84f2987 100644 --- a/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models_py3.py +++ b/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models_py3.py @@ -1412,27 +1412,36 @@ def __init__( class PlatformWorkloadIdentityProfile(msrest.serialization.Model): """PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters. + :ivar upgradeable_to: UpgradeableTo stores a single OpenShift version a workload idetntiy + cluster can be upgraded to. + :vartype upgradeable_to: str :ivar platform_workload_identities: :vartype platform_workload_identities: list[~azure.mgmt.redhatopenshift.v2024_08_12_preview.models.PlatformWorkloadIdentity] """ _attribute_map = { + 'upgradeable_to': {'key': 'upgradeableTo', 'type': 'str'}, 'platform_workload_identities': {'key': 'platformWorkloadIdentities', 'type': '[PlatformWorkloadIdentity]'}, } def __init__( self, *, + upgradeable_to: Optional[str] = None, platform_workload_identities: Optional[List["PlatformWorkloadIdentity"]] = None, **kwargs ): """ + :keyword upgradeable_to: UpgradeableTo stores a single OpenShift version a workload idetntiy + cluster can be upgraded to. + :paramtype upgradeable_to: str :keyword platform_workload_identities: :paramtype platform_workload_identities: list[~azure.mgmt.redhatopenshift.v2024_08_12_preview.models.PlatformWorkloadIdentity] """ super(PlatformWorkloadIdentityProfile, self).__init__(**kwargs) + self.upgradeable_to = upgradeable_to self.platform_workload_identities = platform_workload_identities diff --git a/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json index c65beac000c..482fba9cc5a 100644 --- a/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json +++ b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json @@ -2349,6 +2349,9 @@ "description": "PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters.", "type": "object", "properties": { + "upgradeableTo": { + "$ref": "#/definitions/UpgradeableTo" + }, "platformWorkloadIdentities": { "type": "array", "items": { @@ -2603,6 +2606,10 @@ "type": "string" } }, + "UpgradeableTo": { + "description": "UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to", + "type": "string" + }, "UserAssignedIdentities": { "description": "UserAssignedIdentities stores a mapping from resource IDs of managed identities to their client/principal IDs.", "type": "object", From 34f593b0f0d1e808ac4771cfb057e466a6e7eb80 Mon Sep 17 00:00:00 2001 From: kimorris27 Date: Wed, 15 May 2024 15:44:13 -0500 Subject: [PATCH 2/7] Two fixes: - Initialize the operatorcli in both the real code and the unit tests - Compare the actual annotations on the CloudCredentials to the wantAnnotations --- pkg/cluster/install.go | 2 +- pkg/operator/deploy/deploy.go | 3 +- pkg/operator/deploy/deploy_test.go | 45 +++++++++++++++++------------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/pkg/cluster/install.go b/pkg/cluster/install.go index ea177fe7262..6ddcbfb7190 100644 --- a/pkg/cluster/install.go +++ b/pkg/cluster/install.go @@ -525,7 +525,7 @@ func (m *manager) initializeKubernetesClients(ctx context.Context) error { // initializeKubernetesClients initializes clients which are used // once the cluster is up later on in the install process. func (m *manager) initializeOperatorDeployer(ctx context.Context) (err error) { - m.aroOperatorDeployer, err = deploy.New(m.log, m.env, m.doc.OpenShiftCluster, m.arocli, m.client, m.extensionscli, m.kubernetescli) + m.aroOperatorDeployer, err = deploy.New(m.log, m.env, m.doc.OpenShiftCluster, m.arocli, m.client, m.extensionscli, m.kubernetescli, m.operatorcli) return } diff --git a/pkg/operator/deploy/deploy.go b/pkg/operator/deploy/deploy.go index 4cb41f37b5d..21f63ea8ea9 100644 --- a/pkg/operator/deploy/deploy.go +++ b/pkg/operator/deploy/deploy.go @@ -73,7 +73,7 @@ type operator struct { dh dynamichelper.Interface } -func New(log *logrus.Entry, env env.Interface, oc *api.OpenShiftCluster, arocli aroclient.Interface, client client.Client, extensionscli extensionsclient.Interface, kubernetescli kubernetes.Interface) (Operator, error) { +func New(log *logrus.Entry, env env.Interface, oc *api.OpenShiftCluster, arocli aroclient.Interface, client client.Client, extensionscli extensionsclient.Interface, kubernetescli kubernetes.Interface, operatorcli operatorclient.Interface) (Operator, error) { restConfig, err := restconfig.RestConfig(env, oc) if err != nil { return nil, err @@ -92,6 +92,7 @@ func New(log *logrus.Entry, env env.Interface, oc *api.OpenShiftCluster, arocli client: client, extensionscli: extensionscli, kubernetescli: kubernetescli, + operatorcli: operatorcli, dh: dh, }, nil } diff --git a/pkg/operator/deploy/deploy_test.go b/pkg/operator/deploy/deploy_test.go index ec2dccee397..cb557af8597 100644 --- a/pkg/operator/deploy/deploy_test.go +++ b/pkg/operator/deploy/deploy_test.go @@ -11,6 +11,7 @@ import ( "github.com/golang/mock/gomock" configv1 "github.com/openshift/api/config/v1" operatorv1 "github.com/openshift/api/operator/v1" + fakeoperatorclient "github.com/openshift/client-go/operator/clientset/versioned/fake" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -464,7 +465,7 @@ func TestCheckPodImageVersion(t *testing.T) { } func TestEnsureUpgradeAnnotations(t *testing.T) { - //UpgradeableTo1 := api.UpgradeableTo("4.14.59") + UpgradeableTo1 := api.UpgradeableTo("4.14.59") for _, tt := range []struct { name string @@ -488,20 +489,20 @@ func TestEnsureUpgradeAnnotations(t *testing.T) { }, }, }, - // { - // name: "no version persisted in cluster document, persist it", - // cluster: api.OpenShiftCluster{ - // Properties: api.OpenShiftClusterProperties{ - // PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{ - // UpgradeableTo: &UpgradeableTo1, - // }, - // }, - // }, - // annotation: nil, - // wantAnnotation: map[string]string{ - // "cloudcredential.openshift.io/upgradeable-to": "4.14.59", - // }, - // }, + { + name: "no version persisted in cluster document, persist it", + cluster: api.OpenShiftCluster{ + Properties: api.OpenShiftClusterProperties{ + PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{ + UpgradeableTo: &UpgradeableTo1, + }, + }, + }, + annotation: nil, + wantAnnotation: map[string]string{ + "cloudcredential.openshift.io/upgradeable-to": "4.14.59", + }, + }, } { t.Run(tt.name, func(t *testing.T) { ctx := context.Background() @@ -518,15 +519,19 @@ func TestEnsureUpgradeAnnotations(t *testing.T) { } o := operator{ - oc: oc, - env: env, - client: ctrlfake.NewClientBuilder().WithObjects(cloudcredentialobject).Build(), + oc: oc, + env: env, + operatorcli: fakeoperatorclient.NewSimpleClientset(cloudcredentialobject), } err := o.EnsureUpgradeAnnotations(ctx) utilerror.AssertErrorMessage(t, err, tt.wantErr) - if !reflect.DeepEqual(tt.annotation, tt.wantAnnotation) { - t.Errorf("actual annotation: %v, wanted %v", tt.annotation, tt.wantAnnotation) + result, _ := o.operatorcli.OperatorV1().CloudCredentials().List(ctx, metav1.ListOptions{}) + for _, v := range result.Items { + actualAnnotations := v.ObjectMeta.Annotations + if !reflect.DeepEqual(actualAnnotations, tt.wantAnnotation) { + t.Errorf("actual annotation: %v, wanted %v", tt.annotation, tt.wantAnnotation) + } } }) } From fcca98c07596aa75500199d8ceeddaa57d8d238d Mon Sep 17 00:00:00 2001 From: cadenmarchese Date: Mon, 20 May 2024 08:54:23 -0400 Subject: [PATCH 3/7] unit test, static validation allow existing cc annotations, more test cases --- .../openshiftcluster_validatestatic.go | 9 ++ .../openshiftcluster_validatestatic_test.go | 24 ++++++ pkg/operator/deploy/deploy.go | 26 +++--- pkg/operator/deploy/deploy_test.go | 86 ++++++++++++++----- 4 files changed, 111 insertions(+), 34 deletions(-) diff --git a/pkg/api/v20240812preview/openshiftcluster_validatestatic.go b/pkg/api/v20240812preview/openshiftcluster_validatestatic.go index c027b1cd709..7de4109b0e7 100644 --- a/pkg/api/v20240812preview/openshiftcluster_validatestatic.go +++ b/pkg/api/v20240812preview/openshiftcluster_validatestatic.go @@ -8,6 +8,7 @@ import ( "net" "net/http" "net/url" + "regexp" "strings" azcorearm "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" @@ -442,6 +443,14 @@ func (sv openShiftClusterStaticValidator) validatePlatformWorkloadIdentityProfil return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, fmt.Sprintf("%s.PlatformWorkloadIdentities[%d].resourceID", path, n), "Resource must be a user assigned identity.") } } + + if pwip.UpgradeableTo != nil { + matches, err := regexp.MatchString(`^4\.[0-9]{2}\.`, string(*pwip.UpgradeableTo)) + if !matches || err != nil { + return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, fmt.Sprintf("%s.UpgradeableTo[%v]", path, *pwip.UpgradeableTo), "UpgradeableTo must be a valid OpenShift version.") + } + } + return nil } diff --git a/pkg/api/v20240812preview/openshiftcluster_validatestatic_test.go b/pkg/api/v20240812preview/openshiftcluster_validatestatic_test.go index 97e0b802fb5..3688e8e1f12 100644 --- a/pkg/api/v20240812preview/openshiftcluster_validatestatic_test.go +++ b/pkg/api/v20240812preview/openshiftcluster_validatestatic_test.go @@ -1163,6 +1163,9 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) { } func TestOpenShiftClusterStaticValidatePlatformWorkloadIdentityProfile(t *testing.T) { + validUpgradeableToValue := UpgradeableTo("4.14.29") + invalidUpgradeableToValue := UpgradeableTo("16.107.90") + createTests := []*validateTest{ { name: "valid empty workloadIdentityProfile", @@ -1323,6 +1326,27 @@ func TestOpenShiftClusterStaticValidatePlatformWorkloadIdentityProfile(t *testin }, wantErr: "400: InvalidParameter: properties.servicePrincipalProfile: Must provide either an identity or service principal credentials.", }, + { + name: "valid UpgradeableTo value", + modify: func(oc *OpenShiftCluster) { + oc.Identity = &Identity{} + oc.Properties.ServicePrincipalProfile = nil + oc.Properties.PlatformWorkloadIdentityProfile = &PlatformWorkloadIdentityProfile{ + UpgradeableTo: &validUpgradeableToValue, + } + }, + }, + { + name: "invalid UpgradeableTo value", + modify: func(oc *OpenShiftCluster) { + oc.Identity = &Identity{} + oc.Properties.ServicePrincipalProfile = nil + oc.Properties.PlatformWorkloadIdentityProfile = &PlatformWorkloadIdentityProfile{ + UpgradeableTo: &invalidUpgradeableToValue, + } + }, + wantErr: `400: InvalidParameter: properties.platformWorkloadIdentityProfile.UpgradeableTo[16.107.90]: UpgradeableTo must be a valid OpenShift version.`, + }, } runTests(t, testModeCreate, createTests) diff --git a/pkg/operator/deploy/deploy.go b/pkg/operator/deploy/deploy.go index 21f63ea8ea9..a143efa39bb 100644 --- a/pkg/operator/deploy/deploy.go +++ b/pkg/operator/deploy/deploy.go @@ -437,30 +437,28 @@ func (o *operator) RenewMDSDCertificate(ctx context.Context) error { } func (o *operator) EnsureUpgradeAnnotations(ctx context.Context) error { - if o.oc.Properties.PlatformWorkloadIdentityProfile == nil { - return nil - } - - if o.oc.Properties.ServicePrincipalProfile != nil { + if o.oc.Properties.PlatformWorkloadIdentityProfile == nil || + o.oc.Properties.ServicePrincipalProfile != nil { return nil } upgradeableTo := string(*o.oc.Properties.PlatformWorkloadIdentityProfile.UpgradeableTo) + upgradeableAnnotation := "cloudcredential.openshift.io/upgradeable-to" - cloudcredentialobject, err := o.operatorcli.OperatorV1().CloudCredentials().List(ctx, metav1.ListOptions{}) + cloudcredentialobject, err := o.operatorcli.OperatorV1().CloudCredentials().Get(ctx, "cluster", metav1.GetOptions{}) if err != nil { return err } - for _, v := range cloudcredentialobject.Items { - v.Annotations = map[string]string{ - "cloudcredential.openshift.io/upgradeable-to": upgradeableTo, - } + if cloudcredentialobject.Annotations == nil { + cloudcredentialobject.Annotations = map[string]string{} + } - _, err = o.operatorcli.OperatorV1().CloudCredentials().Update(ctx, &v, metav1.UpdateOptions{}) - if err != nil { - return err - } + cloudcredentialobject.Annotations[upgradeableAnnotation] = upgradeableTo + + _, err = o.operatorcli.OperatorV1().CloudCredentials().Update(ctx, cloudcredentialobject, metav1.UpdateOptions{}) + if err != nil { + return err } return nil diff --git a/pkg/operator/deploy/deploy_test.go b/pkg/operator/deploy/deploy_test.go index cb557af8597..f2db22c0e4f 100644 --- a/pkg/operator/deploy/deploy_test.go +++ b/pkg/operator/deploy/deploy_test.go @@ -11,7 +11,7 @@ import ( "github.com/golang/mock/gomock" configv1 "github.com/openshift/api/config/v1" operatorv1 "github.com/openshift/api/operator/v1" - fakeoperatorclient "github.com/openshift/client-go/operator/clientset/versioned/fake" + operatorfake "github.com/openshift/client-go/operator/clientset/versioned/fake" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -468,34 +468,31 @@ func TestEnsureUpgradeAnnotations(t *testing.T) { UpgradeableTo1 := api.UpgradeableTo("4.14.59") for _, tt := range []struct { - name string - cluster api.OpenShiftCluster - annotation map[string]string - wantAnnotation map[string]string - wantErr string + name string + cluster api.OpenShiftClusterProperties + annotation map[string]string + wantAnnotation map[string]string + wantErr string + cloudCredentialsName string }{ { name: "nil PlatformWorkloadIdentityProfile, no version persisted in cluster document", }, { name: "non-nil ServicePrincipalProfile, no version persisted in cluster document", - cluster: api.OpenShiftCluster{ - Properties: api.OpenShiftClusterProperties{ - ServicePrincipalProfile: &api.ServicePrincipalProfile{ - ClientID: "", - ClientSecret: "", - }, - PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{}, + cluster: api.OpenShiftClusterProperties{ + ServicePrincipalProfile: &api.ServicePrincipalProfile{ + ClientID: "", + ClientSecret: "", }, + PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{}, }, }, { name: "no version persisted in cluster document, persist it", - cluster: api.OpenShiftCluster{ - Properties: api.OpenShiftClusterProperties{ - PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{ - UpgradeableTo: &UpgradeableTo1, - }, + cluster: api.OpenShiftClusterProperties{ + PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{ + UpgradeableTo: &UpgradeableTo1, }, }, annotation: nil, @@ -503,6 +500,47 @@ func TestEnsureUpgradeAnnotations(t *testing.T) { "cloudcredential.openshift.io/upgradeable-to": "4.14.59", }, }, + { + name: "cloud credential 'cluster' doesn't exist", + cluster: api.OpenShiftClusterProperties{ + PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{ + UpgradeableTo: &UpgradeableTo1, + }, + }, + cloudCredentialsName: "oh_no", + annotation: nil, + wantAnnotation: nil, + wantErr: `cloudcredentials.operator.openshift.io "cluster" not found`, + }, + { + name: "version persisted in cluster document, replace it", + cluster: api.OpenShiftClusterProperties{ + PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{ + UpgradeableTo: &UpgradeableTo1, + }, + }, + annotation: map[string]string{ + "cloudcredential.openshift.io/upgradeable-to": "4.14.02", + }, + wantAnnotation: map[string]string{ + "cloudcredential.openshift.io/upgradeable-to": "4.14.59", + }, + }, + { + name: "annotations exist, append the upgradeable annotation", + cluster: api.OpenShiftClusterProperties{ + PlatformWorkloadIdentityProfile: &api.PlatformWorkloadIdentityProfile{ + UpgradeableTo: &UpgradeableTo1, + }, + }, + annotation: map[string]string{ + "foo": "bar", + }, + wantAnnotation: map[string]string{ + "foo": "bar", + "cloudcredential.openshift.io/upgradeable-to": "4.14.59", + }, + }, } { t.Run(tt.name, func(t *testing.T) { ctx := context.Background() @@ -510,10 +548,18 @@ func TestEnsureUpgradeAnnotations(t *testing.T) { defer controller.Finish() env := mock_env.NewMockInterface(controller) - oc := &tt.cluster + + oc := &api.OpenShiftCluster{ + Properties: tt.cluster, + } + + if tt.cloudCredentialsName == "" { + tt.cloudCredentialsName = "cluster" + } cloudcredentialobject := &operatorv1.CloudCredential{ ObjectMeta: metav1.ObjectMeta{ + Name: tt.cloudCredentialsName, Annotations: tt.annotation, }, } @@ -521,7 +567,7 @@ func TestEnsureUpgradeAnnotations(t *testing.T) { o := operator{ oc: oc, env: env, - operatorcli: fakeoperatorclient.NewSimpleClientset(cloudcredentialobject), + operatorcli: operatorfake.NewSimpleClientset(cloudcredentialobject), } err := o.EnsureUpgradeAnnotations(ctx) From 1da7fb84bc976e1e7c7f366aad0198550380a591 Mon Sep 17 00:00:00 2001 From: cadenmarchese Date: Thu, 23 May 2024 17:22:12 -0400 Subject: [PATCH 4/7] mutable:true struct tags --- pkg/api/v20240812preview/openshiftcluster.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/api/v20240812preview/openshiftcluster.go b/pkg/api/v20240812preview/openshiftcluster.go index 474b15f9d1c..ae89d745e27 100644 --- a/pkg/api/v20240812preview/openshiftcluster.go +++ b/pkg/api/v20240812preview/openshiftcluster.go @@ -290,8 +290,8 @@ type IngressProfile struct { // PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters. type PlatformWorkloadIdentityProfile struct { - UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty"` - PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"` + UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty" mutable:"true"` + PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty" mutable:"true"` } // UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to @@ -299,10 +299,10 @@ type UpgradeableTo string // PlatformWorkloadIdentity stores information representing a single workload identity. type PlatformWorkloadIdentity struct { - OperatorName string `json:"operatorName,omitempty"` - ResourceID string `json:"resourceId,omitempty"` - ClientID string `json:"clientId,omitempty" swagger:"readOnly"` - ObjectID string `json:"objectId,omitempty" swagger:"readOnly"` + OperatorName string `json:"operatorName,omitempty" mutable:"true"` + ResourceID string `json:"resourceId,omitempty" mutable:"true"` + ClientID string `json:"clientId,omitempty" swagger:"readOnly" mutable:"true"` + ObjectID string `json:"objectId,omitempty" swagger:"readOnly" mutable:"true"` } // ClusterUserAssignedIdentity stores information about a user-assigned managed identity in a predefined format required by Microsoft's Managed Identity team. From 0c47ee7f2cb4259f68413eb183bdd1c9849f3d06 Mon Sep 17 00:00:00 2001 From: cadenmarchese Date: Thu, 30 May 2024 13:48:54 -0400 Subject: [PATCH 5/7] fix typos, use semver --- pkg/api/admin/openshiftcluster.go | 2 +- pkg/api/openshiftcluster.go | 2 +- pkg/api/v20240812preview/openshiftcluster.go | 2 +- .../v20240812preview/openshiftcluster_validatestatic.go | 8 ++++---- .../openshiftcluster_validatestatic_test.go | 4 ++-- .../redhatopenshift/v2024_08_12_preview/models/_models.py | 4 ++-- .../v2024_08_12_preview/models/_models_py3.py | 4 ++-- .../preview/2024-08-12-preview/redhatopenshift.json | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/api/admin/openshiftcluster.go b/pkg/api/admin/openshiftcluster.go index de790d76968..ed328772e43 100644 --- a/pkg/api/admin/openshiftcluster.go +++ b/pkg/api/admin/openshiftcluster.go @@ -422,7 +422,7 @@ type PlatformWorkloadIdentityProfile struct { PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"` } -// UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to +// UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to type UpgradeableTo string // PlatformWorkloadIdentity stores information representing a single workload identity. diff --git a/pkg/api/openshiftcluster.go b/pkg/api/openshiftcluster.go index f4efa59c51f..e0517ad1090 100644 --- a/pkg/api/openshiftcluster.go +++ b/pkg/api/openshiftcluster.go @@ -777,7 +777,7 @@ type PlatformWorkloadIdentityProfile struct { PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"` } -// UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to +// UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to type UpgradeableTo string // PlatformWorkloadIdentity stores information representing a single workload identity. diff --git a/pkg/api/v20240812preview/openshiftcluster.go b/pkg/api/v20240812preview/openshiftcluster.go index ae89d745e27..28e7d4bd171 100644 --- a/pkg/api/v20240812preview/openshiftcluster.go +++ b/pkg/api/v20240812preview/openshiftcluster.go @@ -294,7 +294,7 @@ type PlatformWorkloadIdentityProfile struct { PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty" mutable:"true"` } -// UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to +// UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to type UpgradeableTo string // PlatformWorkloadIdentity stores information representing a single workload identity. diff --git a/pkg/api/v20240812preview/openshiftcluster_validatestatic.go b/pkg/api/v20240812preview/openshiftcluster_validatestatic.go index 7de4109b0e7..b5011fdd210 100644 --- a/pkg/api/v20240812preview/openshiftcluster_validatestatic.go +++ b/pkg/api/v20240812preview/openshiftcluster_validatestatic.go @@ -8,11 +8,11 @@ import ( "net" "net/http" "net/url" - "regexp" "strings" azcorearm "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/go-autorest/autorest/azure" + "github.com/coreos/go-semver/semver" "github.com/Azure/ARO-RP/pkg/api" "github.com/Azure/ARO-RP/pkg/api/util/immutable" @@ -445,9 +445,9 @@ func (sv openShiftClusterStaticValidator) validatePlatformWorkloadIdentityProfil } if pwip.UpgradeableTo != nil { - matches, err := regexp.MatchString(`^4\.[0-9]{2}\.`, string(*pwip.UpgradeableTo)) - if !matches || err != nil { - return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, fmt.Sprintf("%s.UpgradeableTo[%v]", path, *pwip.UpgradeableTo), "UpgradeableTo must be a valid OpenShift version.") + _, err := semver.NewVersion(string(*pwip.UpgradeableTo)) + if err != nil { + return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, fmt.Sprintf("%s.UpgradeableTo[%v]", path, *pwip.UpgradeableTo), "UpgradeableTo must be a valid OpenShift version in the format 'x.y.z'.") } } diff --git a/pkg/api/v20240812preview/openshiftcluster_validatestatic_test.go b/pkg/api/v20240812preview/openshiftcluster_validatestatic_test.go index 3688e8e1f12..884df39ea8a 100644 --- a/pkg/api/v20240812preview/openshiftcluster_validatestatic_test.go +++ b/pkg/api/v20240812preview/openshiftcluster_validatestatic_test.go @@ -1164,7 +1164,7 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) { func TestOpenShiftClusterStaticValidatePlatformWorkloadIdentityProfile(t *testing.T) { validUpgradeableToValue := UpgradeableTo("4.14.29") - invalidUpgradeableToValue := UpgradeableTo("16.107.90") + invalidUpgradeableToValue := UpgradeableTo("16.107.invalid") createTests := []*validateTest{ { @@ -1345,7 +1345,7 @@ func TestOpenShiftClusterStaticValidatePlatformWorkloadIdentityProfile(t *testin UpgradeableTo: &invalidUpgradeableToValue, } }, - wantErr: `400: InvalidParameter: properties.platformWorkloadIdentityProfile.UpgradeableTo[16.107.90]: UpgradeableTo must be a valid OpenShift version.`, + wantErr: `400: InvalidParameter: properties.platformWorkloadIdentityProfile.UpgradeableTo[16.107.invalid]: UpgradeableTo must be a valid OpenShift version in the format 'x.y.z'.`, }, } diff --git a/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models.py b/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models.py index 3d6c4bfa60f..b7e1fab631d 100644 --- a/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models.py +++ b/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models.py @@ -1303,7 +1303,7 @@ def __init__( class PlatformWorkloadIdentityProfile(msrest.serialization.Model): """PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters. - :ivar upgradeable_to: UpgradeableTo stores a single OpenShift version a workload idetntiy + :ivar upgradeable_to: UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to. :vartype upgradeable_to: str :ivar platform_workload_identities: @@ -1321,7 +1321,7 @@ def __init__( **kwargs ): """ - :keyword upgradeable_to: UpgradeableTo stores a single OpenShift version a workload idetntiy + :keyword upgradeable_to: UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to. :paramtype upgradeable_to: str :keyword platform_workload_identities: diff --git a/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models_py3.py b/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models_py3.py index e38a84f2987..b8c2d9a1d1d 100644 --- a/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models_py3.py +++ b/python/client/azure/mgmt/redhatopenshift/v2024_08_12_preview/models/_models_py3.py @@ -1412,7 +1412,7 @@ def __init__( class PlatformWorkloadIdentityProfile(msrest.serialization.Model): """PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters. - :ivar upgradeable_to: UpgradeableTo stores a single OpenShift version a workload idetntiy + :ivar upgradeable_to: UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to. :vartype upgradeable_to: str :ivar platform_workload_identities: @@ -1433,7 +1433,7 @@ def __init__( **kwargs ): """ - :keyword upgradeable_to: UpgradeableTo stores a single OpenShift version a workload idetntiy + :keyword upgradeable_to: UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to. :paramtype upgradeable_to: str :keyword platform_workload_identities: diff --git a/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json index 482fba9cc5a..95e0131f58f 100644 --- a/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json +++ b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json @@ -2607,7 +2607,7 @@ } }, "UpgradeableTo": { - "description": "UpgradeableTo stores a single OpenShift version a workload idetntiy cluster can be upgraded to", + "description": "UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to", "type": "string" }, "UserAssignedIdentities": { From 1fae910e49a910709eaa9f3245eda2593a874a2e Mon Sep 17 00:00:00 2001 From: cadenmarchese Date: Thu, 30 May 2024 13:59:57 -0400 Subject: [PATCH 6/7] use the singular, make client --- .sha256sum | 10 +--------- pkg/cluster/arooperator.go | 4 ++-- pkg/cluster/install.go | 2 +- pkg/operator/deploy/deploy.go | 4 ++-- pkg/operator/deploy/deploy_test.go | 4 ++-- pkg/util/mocks/operator/deploy/deploy.go | 12 ++++++------ 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/.sha256sum b/.sha256sum index 4f9a06e1463..a198ffcb71c 100644 --- a/.sha256sum +++ b/.sha256sum @@ -1,9 +1 @@ -6182ae0b21f71602ac4deb2f04ca4446182795982d160cee9643ab5f3d68db12 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json -8d07850b3e105c16a397c459261dd78feb7bc20f45f26d9cec5137edaf16fa8d swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2021-09-01-preview/redhatopenshift.json -e4e80ae293dce1a6acfde17fcbd1399487a2fa3587babe6bc69c4ebbdabaa570 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-04-01/redhatopenshift.json -b1f1de0fe40d05de90742b17928968923b936adc294000f58974f50a297581dd swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-09-04/redhatopenshift.json -01ba9562a8dac2824998ff0ad0d2465f79e6a66597bdb321e9409b9f2d12d222 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-04-01/redhatopenshift.json -c023515341196746454c0ae7af077d40d3ec13f6b88b33cb558f0a7ab17a5a24 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2023-07-01-preview/redhatopenshift.json -440748951dd1c3b34b5ccbdcb7cd966e3b89490887a1f1d64429561fad789515 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-09-04/redhatopenshift.json -74a46fdde6ceb0121fe1515c7e11e902dd921b54cffe693307fb02b3dc88f26e swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-11-22/redhatopenshift.json -76e20d8da5c40013e0b5133bb454ba48a86aab9ad9563f53c8d32b7526bebc19 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json +f1e9d42d7c4c0081282e065e7845455db28ed6924687f1acecafb5fbc43ae0c3 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json diff --git a/pkg/cluster/arooperator.go b/pkg/cluster/arooperator.go index db672124c11..ca187e23fbe 100644 --- a/pkg/cluster/arooperator.go +++ b/pkg/cluster/arooperator.go @@ -65,8 +65,8 @@ func (m *manager) ensureCredentialsRequest(ctx context.Context) error { return m.aroOperatorDeployer.CreateOrUpdateCredentialsRequest(ctx) } -func (m *manager) ensureUpgradeAnnotations(ctx context.Context) error { - return m.aroOperatorDeployer.EnsureUpgradeAnnotations(ctx) +func (m *manager) ensureUpgradeAnnotation(ctx context.Context) error { + return m.aroOperatorDeployer.EnsureUpgradeAnnotation(ctx) } func (m *manager) renewMDSDCertificate(ctx context.Context) error { diff --git a/pkg/cluster/install.go b/pkg/cluster/install.go index 6ddcbfb7190..072b9cb29c2 100644 --- a/pkg/cluster/install.go +++ b/pkg/cluster/install.go @@ -213,7 +213,7 @@ func (m *manager) Update(ctx context.Context) error { steps.Action(m.updateAROSecret), steps.Action(m.restartAROOperatorMaster), // depends on m.updateOpenShiftSecret; the point of restarting is to pick up any changes made to the secret steps.Condition(m.aroDeploymentReady, 5*time.Minute, true), - steps.Action(m.ensureUpgradeAnnotations), + steps.Action(m.ensureUpgradeAnnotation), steps.Action(m.reconcileLoadBalancerProfile), } diff --git a/pkg/operator/deploy/deploy.go b/pkg/operator/deploy/deploy.go index a143efa39bb..1fbc93a7cd0 100644 --- a/pkg/operator/deploy/deploy.go +++ b/pkg/operator/deploy/deploy.go @@ -57,7 +57,7 @@ type Operator interface { Restart(context.Context, []string) error IsRunningDesiredVersion(context.Context) (bool, error) RenewMDSDCertificate(context.Context) error - EnsureUpgradeAnnotations(context.Context) error + EnsureUpgradeAnnotation(context.Context) error } type operator struct { @@ -436,7 +436,7 @@ func (o *operator) RenewMDSDCertificate(ctx context.Context) error { return nil } -func (o *operator) EnsureUpgradeAnnotations(ctx context.Context) error { +func (o *operator) EnsureUpgradeAnnotation(ctx context.Context) error { if o.oc.Properties.PlatformWorkloadIdentityProfile == nil || o.oc.Properties.ServicePrincipalProfile != nil { return nil diff --git a/pkg/operator/deploy/deploy_test.go b/pkg/operator/deploy/deploy_test.go index f2db22c0e4f..44f5e257a63 100644 --- a/pkg/operator/deploy/deploy_test.go +++ b/pkg/operator/deploy/deploy_test.go @@ -464,7 +464,7 @@ func TestCheckPodImageVersion(t *testing.T) { } } -func TestEnsureUpgradeAnnotations(t *testing.T) { +func TestTestEnsureUpgradeAnnotation(t *testing.T) { UpgradeableTo1 := api.UpgradeableTo("4.14.59") for _, tt := range []struct { @@ -570,7 +570,7 @@ func TestEnsureUpgradeAnnotations(t *testing.T) { operatorcli: operatorfake.NewSimpleClientset(cloudcredentialobject), } - err := o.EnsureUpgradeAnnotations(ctx) + err := o.EnsureUpgradeAnnotation(ctx) utilerror.AssertErrorMessage(t, err, tt.wantErr) result, _ := o.operatorcli.OperatorV1().CloudCredentials().List(ctx, metav1.ListOptions{}) for _, v := range result.Items { diff --git a/pkg/util/mocks/operator/deploy/deploy.go b/pkg/util/mocks/operator/deploy/deploy.go index f3536da8087..30f4efc2576 100644 --- a/pkg/util/mocks/operator/deploy/deploy.go +++ b/pkg/util/mocks/operator/deploy/deploy.go @@ -62,18 +62,18 @@ func (mr *MockOperatorMockRecorder) CreateOrUpdateCredentialsRequest(arg0 interf return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdateCredentialsRequest", reflect.TypeOf((*MockOperator)(nil).CreateOrUpdateCredentialsRequest), arg0) } -// EnsureUpgradeAnnotations mocks base method. -func (m *MockOperator) EnsureUpgradeAnnotations(arg0 context.Context) error { +// EnsureUpgradeAnnotation mocks base method. +func (m *MockOperator) EnsureUpgradeAnnotation(arg0 context.Context) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "EnsureUpgradeAnnotations", arg0) + ret := m.ctrl.Call(m, "EnsureUpgradeAnnotation", arg0) ret0, _ := ret[0].(error) return ret0 } -// EnsureUpgradeAnnotations indicates an expected call of EnsureUpgradeAnnotations. -func (mr *MockOperatorMockRecorder) EnsureUpgradeAnnotations(arg0 interface{}) *gomock.Call { +// EnsureUpgradeAnnotation indicates an expected call of EnsureUpgradeAnnotation. +func (mr *MockOperatorMockRecorder) EnsureUpgradeAnnotation(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsureUpgradeAnnotations", reflect.TypeOf((*MockOperator)(nil).EnsureUpgradeAnnotations), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsureUpgradeAnnotation", reflect.TypeOf((*MockOperator)(nil).EnsureUpgradeAnnotation), arg0) } // IsReady mocks base method. From 7916e5895657268b8af42558e5ffa5144939f29f Mon Sep 17 00:00:00 2001 From: cadenmarchese Date: Mon, 3 Jun 2024 08:38:33 -0400 Subject: [PATCH 7/7] re-add old SHA sums --- .sha256sum | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.sha256sum b/.sha256sum index a198ffcb71c..cca696c9d93 100644 --- a/.sha256sum +++ b/.sha256sum @@ -1 +1,9 @@ +6182ae0b21f71602ac4deb2f04ca4446182795982d160cee9643ab5f3d68db12 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json +8d07850b3e105c16a397c459261dd78feb7bc20f45f26d9cec5137edaf16fa8d swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2021-09-01-preview/redhatopenshift.json +e4e80ae293dce1a6acfde17fcbd1399487a2fa3587babe6bc69c4ebbdabaa570 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-04-01/redhatopenshift.json +b1f1de0fe40d05de90742b17928968923b936adc294000f58974f50a297581dd swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-09-04/redhatopenshift.json +01ba9562a8dac2824998ff0ad0d2465f79e6a66597bdb321e9409b9f2d12d222 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-04-01/redhatopenshift.json +c023515341196746454c0ae7af077d40d3ec13f6b88b33cb558f0a7ab17a5a24 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2023-07-01-preview/redhatopenshift.json +440748951dd1c3b34b5ccbdcb7cd966e3b89490887a1f1d64429561fad789515 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-09-04/redhatopenshift.json +74a46fdde6ceb0121fe1515c7e11e902dd921b54cffe693307fb02b3dc88f26e swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-11-22/redhatopenshift.json f1e9d42d7c4c0081282e065e7845455db28ed6924687f1acecafb5fbc43ae0c3 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2024-08-12-preview/redhatopenshift.json