Merge pull request #6977 from wanyaoqi/automated-cherry-pick-of-#6975-upstream-release-3.2

Automated cherry pick of #6975: fix deploy backup server order
This commit is contained in:
Zexi Li
2020-06-30 23:09:03 +08:00
committed by GitHub
4 changed files with 20 additions and 6 deletions
+5 -2
View File
@@ -42,11 +42,14 @@ func (self *GuestDeployTask) OnInit(ctx context.Context, obj db.IStandaloneModel
}
func (self *GuestDeployTask) OnGuestNetworkReady(ctx context.Context, guest *models.SGuest) {
self.SetStage("OnDeployWaitServerStop", nil)
if jsonutils.QueryBoolean(self.Params, "restart", false) {
self.SetStage("OnDeployWaitServerStop", nil)
guest.StartGuestStopTask(ctx, self.UserCred, false, self.GetTaskId())
} else {
self.OnDeployWaitServerStop(ctx, guest, nil)
// Note: have to use LocalTaskRun, run to another place implement OnDeployWaitServerStop
taskman.LocalTaskRun(self, func() (jsonutils.JSONObject, error) {
return nil, nil
})
}
}
+5 -3
View File
@@ -36,10 +36,10 @@ type HAGuestDeployTask struct {
GuestDeployTask
}
func (self *HAGuestDeployTask) OnDeployGuestComplete(
func (self *HAGuestDeployTask) OnDeployWaitServerStop(
ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject,
) {
self.DeployBackup(ctx, guest, data)
self.DeployBackup(ctx, guest, nil)
}
func (self *HAGuestDeployTask) DeployBackup(ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject) {
@@ -57,7 +57,9 @@ func (self *HAGuestDeployTask) DeployBackup(ctx context.Context, guest *models.S
func (self *HAGuestDeployTask) OnDeploySlaveGuestComplete(
ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject,
) {
self.GuestDeployTask.OnDeployGuestComplete(ctx, guest, data)
host := guest.GetHost()
self.SetStage("OnDeployGuestComplete", nil)
self.DeployOnHost(ctx, guest, host)
}
func (self *HAGuestDeployTask) OnDeploySlaveGuestCompleteFailed(
+1 -1
View File
@@ -108,7 +108,7 @@ func (s *SNFSStorage) checkAndMount() error {
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
err = procutils.NewCommandContext(ctx,
err = procutils.NewRemoteCommandContextAsFarAsPossible(ctx,
"mount", "-t", "nfs", fmt.Sprintf("%s:%s", host, sharedDir), s.Path).Run()
if err != nil {
return err
+9
View File
@@ -61,6 +61,15 @@ func NewRemoteCommandAsFarAsPossible(name string, args ...string) *Command {
}
}
func NewRemoteCommandContextAsFarAsPossible(ctx context.Context, name string, args ...string) *Command {
return &Command{
path: name,
args: args,
cmd: execInstance.CommandContext(ctx, name, args...),
remoteCmd: true,
}
}
func (c *Command) StdinPipe() (io.WriteCloser, error) {
return c.cmd.StdinPipe()
}