Skip to content

Commit

Permalink
Merge pull request kubevirt#213 from rmohr/migration
Browse files Browse the repository at this point in the history
Refactor migration controller
  • Loading branch information
admiyo authored May 30, 2017
2 parents e66715e + 82247ff commit 5fd6b93
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 581 deletions.
16 changes: 2 additions & 14 deletions cmd/virt-controller/virt-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,15 @@ func main() {
// Wait until VM cache has warmed up before we start watching pods
vmController.WaitForSync(stop)

//TODO order the parameters consistantly in the factories, or use an object.
_, migrationController, migrationQueue := watch.NewMigrationController(vmService, nil, restClient, clientSet)
migrationController.StartInformer(stop)
//FIXME when we have more than one worker, we need a lock on the VM
migrationController := watch.NewMigrationController(vmService, restClient, clientSet)
go migrationController.Run(1, stop)
migrationController.WaitForSync(stop)

// Start watching pods
_, podController := watch.NewPodController(vmCache, nil, clientSet, restClient, vmService)
podController.StartInformer(stop)
go podController.Run(1, stop)

_, migrationPodController := watch.NewMigrationPodController(vmCache, nil, clientSet, restClient, vmService, *migrationQueue)
migrationPodController.StartInformer(stop)
//FIXME when we have more than one worker, we need a lock on the VM
go migrationPodController.Run(1, stop)

_, jobController := watch.NewJobController(vmService, nil, clientSet, restClient, *migrationQueue)
jobController.StartInformer(stop)
go jobController.Run(1, stop)
jobController.WaitForSync(stop)

httpLogger := logger.With("service", "http")

httpLogger.Info().Log("action", "listening", "interface", *host, "port", *port)
Expand Down
6 changes: 2 additions & 4 deletions pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,6 @@ const (
// Create Migration has been called but nothing has been done with it
MigrationUnknown MigrationPhase = ""

// Migration is actively progressing
MigrationScheduled MigrationPhase = "Scheduled"

// Migration has been scheduled but no update on the status has been recorded
MigrationRunning MigrationPhase = "Running"

Expand All @@ -383,7 +380,8 @@ const (
// MigrationStatus is the last reported status of a VM Migratrion. Status may trail the actual
// state of a migration.
type MigrationStatus struct {
Phase MigrationPhase `json:"phase,omitempty"`
Phase MigrationPhase `json:"phase,omitempty"`
Instance *types.UID `json:"instance,omitempty"`
}

// Required to satisfy ObjectMetaAccessor interface
Expand Down
15 changes: 15 additions & 0 deletions pkg/kubecli/kubecli.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ func NewResourceEventHandlerFuncsForWorkqueue(queue workqueue.RateLimitingInterf
}
}

func NewResourceEventHandlerFuncsForFunc(f func(interface{})) cache.ResourceEventHandlerFuncs {
return cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
f(obj)
},
UpdateFunc: func(old interface{}, new interface{}) {
f(new)

},
DeleteFunc: func(obj interface{}) {
f(obj)
},
}
}

type Controller struct {
indexer cache.Store
queue workqueue.RateLimitingInterface
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-controller/services/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = Describe("VM", func() {
migration = v1.NewMinimalMigration(vm.ObjectMeta.Name+"-migration", vm.ObjectMeta.Name)
expected_migration = &v1.Migration{}
*expected_migration = *migration
expected_migration.Status.Phase = v1.MigrationScheduled
expected_migration.Status.Phase = v1.MigrationRunning

vm.ObjectMeta.UID = "testUID"
vm.ObjectMeta.SetUID(uuid.NewUUID())
Expand Down
86 changes: 0 additions & 86 deletions pkg/virt-controller/watch/job.go

This file was deleted.

148 changes: 0 additions & 148 deletions pkg/virt-controller/watch/job_test.go

This file was deleted.

Loading

0 comments on commit 5fd6b93

Please sign in to comment.