本文整理汇总了Golang中github.com/evergreen-ci/evergreen/model/host.Host.SetUnprovisioned方法的典型用法代码示例。如果您正苦于以下问题:Golang Host.SetUnprovisioned方法的具体用法?Golang Host.SetUnprovisioned怎么用?Golang Host.SetUnprovisioned使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/evergreen-ci/evergreen/model/host.Host
的用法示例。
在下文中一共展示了Host.SetUnprovisioned方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ProvisionHost
// Provision the host, and update the database accordingly.
func (init *HostInit) ProvisionHost(h *host.Host) error {
// run the setup script
evergreen.Logger.Logf(slogger.INFO, "Setting up host %v", h.Id)
output, err := init.setupHost(h)
// deal with any errors that occured while running the setup
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Error running setup script: %v", err)
// another hostinit process beat us there
if err == ErrHostAlreadyInitializing {
evergreen.Logger.Logf(slogger.DEBUG, "Attempted to initialize already initializing host %v", h.Id)
return nil
}
alerts.RunHostProvisionFailTriggers(h)
event.LogProvisionFailed(h.Id, output)
// setup script failed, mark the host's provisioning as failed
if err := h.SetUnprovisioned(); err != nil {
evergreen.Logger.Logf(slogger.ERROR, "unprovisioning host %v failed: %v", h.Id, err)
}
return fmt.Errorf("error initializing host %v: %v", h.Id, err)
}
evergreen.Logger.Logf(slogger.INFO, "Setup complete for host %v", h.Id)
if h.ProvisionOptions != nil &&
h.ProvisionOptions.LoadCLI &&
h.ProvisionOptions.OwnerId != "" {
evergreen.Logger.Logf(slogger.INFO, "Uploading client binary to host %v", h.Id)
lcr, err := init.LoadClient(h)
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Failed to load client binary onto host %v: %v", h.Id, err)
} else if err == nil && len(h.ProvisionOptions.TaskId) > 0 {
evergreen.Logger.Logf(slogger.INFO, "Fetching data for task %v onto host %v", h.ProvisionOptions.TaskId, h.Id)
err = init.fetchRemoteTaskData(h.ProvisionOptions.TaskId, lcr.BinaryPath, lcr.ConfigPath, h)
evergreen.Logger.Logf(slogger.ERROR, "Failed to fetch data onto host %v: %v", h.Id, err)
}
}
// the setup was successful. update the host accordingly in the database
if err := h.MarkAsProvisioned(); err != nil {
return fmt.Errorf("error marking host %v as provisioned: %v", err)
}
evergreen.Logger.Logf(slogger.INFO, "Host %v successfully provisioned", h.Id)
return nil
}
示例2: ProvisionHost
// Provision the host, and update the database accordingly.
func (init *HostInit) ProvisionHost(h *host.Host) error {
// run the setup script
output, err := init.setupHost(h)
// deal with any errors that occured while running the setup
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Error running setup script: %v", err)
// another hostinit process beat us there
if err == ErrHostAlreadyInitializing {
evergreen.Logger.Logf(slogger.DEBUG,
"Attempted to initialize already initializing host %v", h.Id)
return nil
}
// log the provisioning failure
setupLog := ""
if output != nil {
setupLog = string(output)
}
alerts.RunHostProvisionFailTriggers(h)
event.LogProvisionFailed(h.Id, setupLog)
// setup script failed, mark the host's provisioning as failed
if err := h.SetUnprovisioned(); err != nil {
evergreen.Logger.Logf(slogger.ERROR, "unprovisioning host %v failed: %v", h.Id, err)
}
return fmt.Errorf("error initializing host %v: %v", h.Id, err)
}
// the setup was successful. update the host accordingly in the database
if err := h.MarkAsProvisioned(); err != nil {
return fmt.Errorf("error marking host %v as provisioned: %v", err)
}
evergreen.Logger.Logf(slogger.INFO, "Host %v successfully provisioned", h.Id)
return nil
}