예제 #1
0
파일: runner.go 프로젝트: square/shift
// 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
}
예제 #2
0
파일: runner.go 프로젝트: square/shift
// 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")
	}
}