Skip to content
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

auto detect kubevirt install #4791

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
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
8 changes: 3 additions & 5 deletions pkg/controller/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,11 @@ func (c *Controller) isVMIMigrationCRDInstalled() bool {
if err != nil {
return false
}
klog.V(3).Info("Detect VMI Migration CRD")
klog.Info("Found KubeVirt VMI Migration CRD")
return true
}

func (c *Controller) StartMigrationInformerFactory(ctx context.Context, kubevirtInformerFactory kubevirtController.KubeInformerFactory) {
taskStopCh := make(chan struct{})
isTaskRunning := false
zhangzujian marked this conversation as resolved.
Show resolved Hide resolved
ticker := time.NewTicker(10 * time.Second)
go func() {
Expand All @@ -156,15 +155,14 @@ func (c *Controller) StartMigrationInformerFactory(ctx context.Context, kubevirt
case <-ticker.C:
if !isTaskRunning && c.isVMIMigrationCRDInstalled() {
klog.Info("Start VMI migration informer")
kubevirtInformerFactory.Start(taskStopCh)
if !cache.WaitForCacheSync(taskStopCh, c.vmiMigrationSynced) {
kubevirtInformerFactory.Start(ctx.Done())
if !cache.WaitForCacheSync(ctx.Done(), c.vmiMigrationSynced) {
util.LogFatalAndExit(nil, "failed to wait for vmi migration caches to sync")
}
isTaskRunning = true
return
}
case <-ctx.Done():
close(taskStopCh)
return
}
}
Expand Down
Loading