Make the upload of env vars retryable in case of restarts

pull/6388/head
DanHam 8 years ago
parent 6226992757
commit e0bcba4913
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E

@ -426,12 +426,20 @@ func (p *Provisioner) createFlattenedEnvVars(elevated bool) (flattened string) {
}
func (p *Provisioner) uploadEnvVars(flattenedEnvVars string) (err error) {
// Upload all env vars to a powershell script on the target build file system
// Upload all env vars to a powershell script on the target build file
// system. Do this in the context of a single retryable function so
// that we gracefully handle any errors created by transient conditions
// such as a system restart
envVarReader := strings.NewReader(flattenedEnvVars)
log.Printf("Uploading env vars to %s", p.config.RemoteEnvVarPath)
err = p.communicator.Upload(p.config.RemoteEnvVarPath, envVarReader, nil)
err = p.retryable(func() error {
if err := p.communicator.Upload(p.config.RemoteEnvVarPath, envVarReader, nil); err != nil {
return fmt.Errorf("Error uploading ps script containing env vars: %s", err)
}
return err
})
if err != nil {
return fmt.Errorf("Error uploading ps script containing env vars: %s", err)
return err
}
return
}

Loading…
Cancel
Save