// submitStatusRequest checks the service to validate that the deploy request completed successfully.
func (d *DeployWorker) submitStatusRequest(cl *coscl.Client, deployID string) string {
	var stat cosddb.DeployStatus

	// Check status every maxPollStatusPause seconds, maxPollStatusCount times.
	for a := 0; a <= maxPollStatusCount; a++ {
		time.Sleep(time.Second * maxPollStatusPause)
		resp, err := cl.Execute()
		if err != nil {
			return fmt.Sprintf("Could not submit status request for deployID %s", deployID, err.Error())
		}
		err = json.Unmarshal([]byte(resp), &stat)
		if err != nil {
			return fmt.Sprintf("Could not parse status response for deployID %s: %s", deployID, err.Error())
		}
		if stat.Status == cosddb.Started {
			continue
		}
		break
	}
	switch stat.Status {
	case cosddb.Started:
		return fmt.Sprintf("Deploy still running after polling period expired for deployID %s", deployID)
	case cosddb.Failed:
		return fmt.Sprintf("Deploy Failed for deployID %s", deployID)
	default:
	}
	return ""
}
// submitDeployRequest returns a unique deploy id after submitting a request via the client library to
// the coreos-deploy service in the cluster.
func (d *DeployWorker) submitDeployRequest(cl *coscl.Client) (string, string) {
	resp, err := cl.Execute()
	if err != nil {
		return "", fmt.Sprintf("Could not submit deploy request: %s", err.Error())
	}

	result := struct {
		DeployID string `json:"deployID"` // The UUID of the deploy.
	}{}
	err = json.Unmarshal([]byte(resp), &result)
	if err != nil {
		return "", fmt.Sprintf("Cannot parse returned deploy id: %s", err.Error())
	}
	return result.DeployID, ""
}