Skip to content

Commit 4d12c93

Browse files
fix migration issues (#1159)
Signed-off-by: clyang82 <[email protected]> Co-authored-by: clyang82 <[email protected]>
1 parent ee3a3f4 commit 4d12c93

File tree

7 files changed

+13
-4
lines changed

7 files changed

+13
-4
lines changed

agent/pkg/spec/controller/syncers/migration_from_syncer.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"sigs.k8s.io/controller-runtime/pkg/client"
2020

2121
bundleevent "github.com/stolostron/multicluster-global-hub/pkg/bundle/event"
22+
"github.com/stolostron/multicluster-global-hub/pkg/constants"
2223
)
2324

2425
const (
@@ -137,10 +138,13 @@ func (s *managedClusterMigrationFromSyncer) Sync(ctx context.Context, payload []
137138
if annotations == nil {
138139
annotations = make(map[string]string)
139140
}
140-
if annotations["agent.open-cluster-management.io/klusterlet-config"] == klusterletConfig.Name {
141+
142+
_, migrating := annotations[constants.ManagedClusterMigrating]
143+
if migrating && annotations["agent.open-cluster-management.io/klusterlet-config"] == klusterletConfig.Name {
141144
continue
142145
}
143146
annotations["agent.open-cluster-management.io/klusterlet-config"] = klusterletConfig.Name
147+
annotations[constants.ManagedClusterMigrating] = ""
144148
mcl.SetAnnotations(annotations)
145149
if err := s.client.Update(ctx, mcl); err != nil {
146150
return err

agent/pkg/status/controller/managedclusters/managed_cluster_syncer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func LaunchManagedClusterSyncer(ctx context.Context, mgr ctrl.Manager, agentConf
3131
})
3232
}
3333
emitter := generic.ObjectEmitterWrapper(enum.ManagedClusterType, func(obj client.Object) bool {
34-
return true
34+
return !utils.HasAnnotation(obj, constants.ManagedClusterMigrating)
3535
}, tweakFunc, false)
3636

3737
return generic.LaunchGenericObjectSyncer(

operator/bundle/manifests/multicluster-global-hub-operator.clusterserviceversion.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ metadata:
3131
categories: Integration & Delivery,OpenShift Optional
3232
certified: "false"
3333
containerImage: quay.io/stolostron/multicluster-global-hub-operator:latest
34-
createdAt: "2024-09-26T06:54:09Z"
34+
createdAt: "2024-10-10T05:42:48Z"
3535
description: Manages the installation and upgrade of the Multicluster Global Hub.
3636
olm.skipRange: '>=1.2.0 <1.3.0'
3737
operatorframework.io/initialization-resource: '{"apiVersion":"operator.open-cluster-management.io/v1alpha4",
@@ -490,6 +490,7 @@ spec:
490490
- managedclusters
491491
verbs:
492492
- create
493+
- delete
493494
- get
494495
- list
495496
- update

operator/config/rbac/role.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ rules:
206206
- managedclusters
207207
verbs:
208208
- create
209+
- delete
209210
- get
210211
- list
211212
- update

operator/pkg/controllers/agent/manifests/templates/agent/multicluster-global-hub-agent-clusterrole.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,5 @@ rules:
247247
- get
248248
- create
249249
- update
250+
- delete
250251
{{- end -}}

operator/pkg/controllers/hubofhubs/controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ func watchMutatingWebhookConfigurationPredicate() predicate.TypedPredicate[*admi
563563
// +kubebuilder:rbac:groups=cluster.open-cluster-management.io,resources=placements,verbs=create;get;list;patch;update;delete
564564
// +kubebuilder:rbac:groups=cluster.open-cluster-management.io,resources=managedclustersetbindings,verbs=create;get;list;patch;update;delete
565565
// +kubebuilder:rbac:groups=cluster.open-cluster-management.io,resources=managedclustersets,verbs=get;list;patch;update
566-
// +kubebuilder:rbac:groups=cluster.open-cluster-management.io,resources=managedclusters,verbs=get;list;update;create
566+
// +kubebuilder:rbac:groups=cluster.open-cluster-management.io,resources=managedclusters,verbs=get;list;update;create;delete
567567
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch;create;update;delete
568568
// +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;delete
569569
// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;delete

pkg/constants/constants.go

+2
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ const (
173173
const (
174174
// ManagedClusterMigrationFinalizer is the finalizer for managed cluster migration
175175
ManagedClusterMigrationFinalizer = "global-hub.open-cluster-management.io/migration-cleanup"
176+
// ManagedClusterMigrating is under migrating so the global hub agent ignore reporting the status for the cluster
177+
ManagedClusterMigrating = "global-hub.open-cluster-management.io/migrating"
176178
// cloudevent source for global hub
177179
CloudEventSourceGlobalHub = "global-hub"
178180
// cloudevent extension keys

0 commit comments

Comments
 (0)