Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6a5ddf5
test: add migration e2e test for OCM environment
yanmxa Jan 16, 2026
9b14ea6
fix: remove ClusterManager CRD download in e2e setup
yanmxa Jan 16, 2026
ba5454c
fix: add missing kubeconfig parameters in event_exporter_kafka.sh
yanmxa Jan 17, 2026
fd402f6
fix: restore ClusterManager CRD update for autoApproveUsers support
yanmxa Jan 17, 2026
6b14fb2
fix: remove stderr suppression for ClusterManager CRD update
yanmxa Jan 17, 2026
48e56c6
fix: move ClusterManager CRD update after clusteradm init
yanmxa Jan 17, 2026
f23badc
fix: update clusteradm version to match bundle version
yanmxa Jan 18, 2026
758d2b9
fix: move migration e2e test to the end to avoid breaking BYO tests
yanmxa Jan 18, 2026
1b0f1a6
fix: ensure namespace exists before applying ConfigMap in e2e tests
yanmxa Jan 18, 2026
14bdb28
fix: cleanup BYO test resources before migration test
yanmxa Jan 18, 2026
37d83fd
fix: only delete BYO MulticlusterGlobalHub instance, not undeploy ope…
yanmxa Jan 18, 2026
5fbdcb3
fix: explicitly delete BYO NodePort service before migration test
yanmxa Jan 18, 2026
634a456
refactor: optimize migration e2e PR with code simplification and cleanup
yanmxa Jan 19, 2026
6ce4f03
Remove unnecessary ClusterManager CRD workaround from e2e setup
yanmxa Jan 19, 2026
37a5640
gitignore: exclude .claude/rules/ from version control
yanmxa Jan 19, 2026
a03e955
chore: remove .claude/rules/ from version control
yanmxa Jan 19, 2026
ba40102
refactor: improve shell script consistency and code comments
yanmxa Jan 19, 2026
60c1f8c
fix: update ClusterManager CRD to support autoApproveUsers in e2e tests
yanmxa Jan 19, 2026
7bfe3cf
fix: apply ClusterManager CRD update to all hubs including managed hubs
yanmxa Jan 19, 2026
edeffd8
Revert "fix: ClusterManager CRD updates are unnecessary"
yanmxa Jan 19, 2026
ab26f78
fix: enable ManagedClusterAutoApproval feature gate for autoApproveUsers
yanmxa Jan 19, 2026
07e4898
fix: add wait time after enabling ManagedClusterAutoApproval feature …
yanmxa Jan 19, 2026
b84d941
refactor: use Eventually with timeout instead of sleep for robustness
yanmxa Jan 19, 2026
cf1e7fb
fix: set feature gate and autoApproveUsers in same update operation
yanmxa Jan 19, 2026
9f9331d
debug: add detailed logging for autoApproveUsers update and verification
yanmxa Jan 19, 2026
c11ee8e
fix: update ClusterManager CRD to support autoApproveUsers field
yanmxa Jan 19, 2026
2f4e3fd
fix: update ClusterManager CRD after clusteradm init
yanmxa Jan 19, 2026
dc700ec
revert: remove manual ClusterManager CRD update
yanmxa Jan 19, 2026
757fc09
fix: update ClusterManager CRD to support autoApproveUsers field
yanmxa Jan 19, 2026
4fe33e4
refactor: simplify bootstrap ClusterRole detection and use phase cons…
yanmxa Jan 20, 2026
92e6678
fix: validate bootstrap ClusterRole exists before creating binding
yanmxa Jan 20, 2026
c962ffc
fix: add missing ClusterRole to migration unit tests
yanmxa Jan 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Comment thread
yanmxa marked this conversation as resolved.
Comment thread
yanmxa marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ __pycache__
output
AGENTS.md
openspec/*
.claude/commands/openspec
.claude/commands/openspec
Comment thread
yanmxa marked this conversation as resolved.
Comment thread
yanmxa marked this conversation as resolved.
.claude/rules/
Comment thread
yanmxa marked this conversation as resolved.
.venv/
41 changes: 40 additions & 1 deletion agent/pkg/spec/migration/migration_to_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const (
KlusterletManifestWorkSuffix = "-klusterlet"
ClusterManagerName = "cluster-manager"
errMsgFailedToGet = "failed to get %s from source resource: %w"

Comment thread
yanmxa marked this conversation as resolved.
// Bootstrap ClusterRole names for different environments
Comment thread
yanmxa marked this conversation as resolved.
DefaultACMBootstrapClusterRole = "open-cluster-management:managedcluster:bootstrap:agent-registration"
Comment thread
yanmxa marked this conversation as resolved.
DefaultOCMBootstrapClusterRole = "open-cluster-management:bootstrap"
)

var (
Expand Down Expand Up @@ -436,6 +440,15 @@ func (s *MigrationTargetSyncer) initializing(ctx context.Context,
return err
Comment thread
yanmxa marked this conversation as resolved.
}
Comment thread
yanmxa marked this conversation as resolved.

Comment thread
yanmxa marked this conversation as resolved.
// In OCM environment, delay 1 minute after all resources are created to allow manual testing.
Comment thread
yanmxa marked this conversation as resolved.
// This delay is necessary because OCM environments may require additional setup time for
Comment thread
yanmxa marked this conversation as resolved.
// ClusterRole and RBAC resources to be properly propagated before proceeding with migration.
Comment thread
yanmxa marked this conversation as resolved.
Comment thread
yanmxa marked this conversation as resolved.
Comment thread
yanmxa marked this conversation as resolved.
// In ACM/MCE environments, these resources are pre-configured, so no delay is needed.
if isOCM, _ := s.isOCMEnvironment(ctx); isOCM {
log.Infof("OCM environment detected, delaying 1 minute after initializing to allow manual resource mocking")
time.Sleep(1 * time.Minute)
Comment thread
yanmxa marked this conversation as resolved.
}

return nil
}

Expand Down Expand Up @@ -795,10 +808,36 @@ func (s *MigrationTargetSyncer) ensureSubjectAccessReviewRole(ctx context.Contex
return nil
Comment thread
yanmxa marked this conversation as resolved.
Comment thread
yanmxa marked this conversation as resolved.
Comment thread
yanmxa marked this conversation as resolved.
}

Comment thread
yanmxa marked this conversation as resolved.
// isOCMEnvironment checks if running in OCM environment (not ACM/MCE)
// Returns (false, nil) if ACM ClusterRole exists
// Returns (true, nil) if only OCM ClusterRole exists
// Returns (false, error) if neither ClusterRole exists
func (s *MigrationTargetSyncer) isOCMEnvironment(ctx context.Context) (bool, error) {
cr := &rbacv1.ClusterRole{}
// If ACM ClusterRole exists, it's not OCM environment
Comment thread
yanmxa marked this conversation as resolved.
if err := s.client.Get(ctx, types.NamespacedName{Name: DefaultACMBootstrapClusterRole}, cr); err == nil {
return false, nil
}
// If only OCM ClusterRole exists, it's OCM environment
if err := s.client.Get(ctx, types.NamespacedName{Name: DefaultOCMBootstrapClusterRole}, cr); err == nil {
return true, nil
}
return false, fmt.Errorf("no bootstrap ClusterRole found: neither %s nor %s exists",
DefaultACMBootstrapClusterRole, DefaultOCMBootstrapClusterRole)
}

func (s *MigrationTargetSyncer) ensureRegistrationClusterRoleBinding(ctx context.Context,
msaName, msaNamespace string,
) error {
registrationClusterRoleName := "open-cluster-management:managedcluster:bootstrap:agent-registration"
isOCM, err := s.isOCMEnvironment(ctx)
if err != nil {
return err
}
registrationClusterRoleName := DefaultACMBootstrapClusterRole
if isOCM {
registrationClusterRoleName = DefaultOCMBootstrapClusterRole
}
log.Infof("using bootstrap ClusterRole: %s", registrationClusterRoleName)
registrationClusterRoleBindingName := GetAgentRegistrationClusterRoleBindingName(msaName)
registrationClusterRoleBinding := &rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Loading