mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-17 22:58:53 +00:00
clusterset v1beta1 migration (#315)
Signed-off-by: ldpliu <daliu@redhat.com>
This commit is contained in:
@@ -7,6 +7,8 @@ package clustermanagercontroller
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/openshift/library-go/pkg/assets"
|
||||
"github.com/openshift/library-go/pkg/operator/events"
|
||||
"github.com/openshift/library-go/pkg/operator/resource/resourceapply"
|
||||
@@ -21,7 +23,6 @@ import (
|
||||
"open-cluster-management.io/registration-operator/pkg/helpers"
|
||||
"open-cluster-management.io/registration-operator/pkg/operators/clustermanager/controllers/migrationcontroller"
|
||||
"open-cluster-management.io/registration-operator/pkg/operators/crdmanager"
|
||||
"reflect"
|
||||
migrationclient "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1"
|
||||
)
|
||||
|
||||
@@ -51,10 +52,8 @@ var (
|
||||
|
||||
// removed CRD StoredVersions
|
||||
removedCRDStoredVersions = map[string]string{
|
||||
"placements.cluster.open-cluster-management.io": "v1alpha1",
|
||||
"placementdecisions.cluster.open-cluster-management.io": "v1alpha1",
|
||||
"managedclustersets.cluster.open-cluster-management.io": "v1alpha1",
|
||||
"managedclustersetbindings.cluster.open-cluster-management.io": "v1alpha1",
|
||||
"managedclustersets.cluster.open-cluster-management.io": "v1beta1",
|
||||
"managedclustersetbindings.cluster.open-cluster-management.io": "v1beta1",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -163,7 +162,7 @@ func (c *crdReconcile) updateStoredVersion(ctx context.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
// remove v1alpha1 from its status
|
||||
// remove old versions from its status
|
||||
oldStoredVersions := crd.Status.StoredVersions
|
||||
newStoredVersions := make([]string, 0, len(oldStoredVersions))
|
||||
for _, stored := range oldStoredVersions {
|
||||
|
||||
@@ -44,7 +44,10 @@ var (
|
||||
// migrationRequestFiles = []string{
|
||||
// "cluster-manager/cluster-manager-managedclustersets-migration.yaml",
|
||||
// }
|
||||
migrationRequestFiles = []string{}
|
||||
migrationRequestFiles = []string{
|
||||
"cluster-manager/cluster-manager-managedclustersets-migration.yaml",
|
||||
"cluster-manager/cluster-manager-managedclustersetbindings-migration.yaml",
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -61,15 +61,11 @@ func TestApplyStorageVersionMigrations(t *testing.T) {
|
||||
{
|
||||
name: "created",
|
||||
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
||||
assertActions(t, actions, "get", "create", "get", "create", "get", "create", "get", "create")
|
||||
assertActions(t, actions, "get", "create", "get", "create")
|
||||
actual := actions[1].(clienttesting.CreateActionImpl).Object
|
||||
assertStorageVersionMigration(t, "managedclustersets.cluster.open-cluster-management.io", actual)
|
||||
actual = actions[3].(clienttesting.CreateActionImpl).Object
|
||||
assertStorageVersionMigration(t, "managedclustersetbindings.cluster.open-cluster-management.io", actual)
|
||||
actual = actions[5].(clienttesting.CreateActionImpl).Object
|
||||
assertStorageVersionMigration(t, "placements.cluster.open-cluster-management.io", actual)
|
||||
actual = actions[7].(clienttesting.CreateActionImpl).Object
|
||||
assertStorageVersionMigration(t, "placementdecisions.cluster.open-cluster-management.io", actual)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -87,15 +83,11 @@ func TestApplyStorageVersionMigrations(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
||||
assertActions(t, actions, "get", "create", "get", "update", "get", "create", "get", "update")
|
||||
assertActions(t, actions, "get", "create", "get", "update")
|
||||
actual := actions[1].(clienttesting.CreateActionImpl).Object
|
||||
assertStorageVersionMigration(t, "managedclustersets.cluster.open-cluster-management.io", actual)
|
||||
actual = actions[3].(clienttesting.UpdateActionImpl).Object
|
||||
assertStorageVersionMigration(t, "managedclustersetbindings.cluster.open-cluster-management.io", actual)
|
||||
actual = actions[5].(clienttesting.CreateActionImpl).Object
|
||||
assertStorageVersionMigration(t, "placements.cluster.open-cluster-management.io", actual)
|
||||
actual = actions[7].(clienttesting.UpdateActionImpl).Object
|
||||
assertStorageVersionMigration(t, "placementdecisions.cluster.open-cluster-management.io", actual)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user