// killAllPtOscProcesses sends a SIGKILL to all pt-osc proccess associated // with running migrations, and returns a list of migration ids of killed processes func killAllPtOscProcesses() []int { killedMigrations := make([]int, 0) runningMigMutex.Lock() defer runningMigMutex.Unlock() for migrationId, _ := range runningMigrations { err := killPtOscById(migrationId) delete(runningMigrations, migrationId) if err != nil { glog.Error(err) continue } killedMigrations = append(killedMigrations, migrationId) } return killedMigrations }
// Kills the ptosc job and sends migration through api to be picked up by other hosts func (runner *runner) killAndOfferMigrations() { if len(runningMigrations) > 0 { killedMigrations := killAllPtOscProcesses() glog.Infof("Done killing, waiting for file sync gorountines to finish") fileSyncWaitGroup.Wait() // wait for all file syncing goroutines to finish glog.Infof("All file syncing gorountines are finished, proceeding...") for _, migrationId := range killedMigrations { glog.Infof("Offering migration mig_id=%v", migrationId) urlParams := map[string]string{"id": strconv.Itoa(migrationId)} _, err := runner.RestClient.Offer(urlParams) if err != nil { glog.Error(err) } } glog.Infof("Offered all killed migrations") } }