Move logging about aws waiters to the access config prepare() so that it's only spit out once per builder.
This commit is contained in:
parent
0cc1493baf
commit
042e9ad14b
|
@ -110,6 +110,7 @@ func (c *AccessConfig) Session() (*session.Session, error) {
|
||||||
if c.DecodeAuthZMessages {
|
if c.DecodeAuthZMessages {
|
||||||
DecodeAuthZMessages(c.session)
|
DecodeAuthZMessages(c.session)
|
||||||
}
|
}
|
||||||
|
LogEnvOverrideWarnings()
|
||||||
|
|
||||||
return c.session, nil
|
return c.session, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -307,6 +308,36 @@ func getEnvOverrides() overridableWaitVars {
|
||||||
return envValues
|
return envValues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LogEnvOverrideWarnings() {
|
||||||
|
pollDelay := os.Getenv("AWS_POLL_DELAY_SECONDS")
|
||||||
|
timeoutSeconds := os.Getenv("AWS_TIMEOUT_SECONDS")
|
||||||
|
maxAttempts := os.Getenv("AWS_MAX_ATTEMPTS")
|
||||||
|
|
||||||
|
if maxAttempts != "" && timeoutSeconds != "" {
|
||||||
|
warning := fmt.Sprintf("[WARNING] (aws): AWS_MAX_ATTEMPTS and " +
|
||||||
|
"AWS_TIMEOUT_SECONDS are both set. Packer will use " +
|
||||||
|
"AWS_MAX_ATTEMPTS and discard AWS_TIMEOUT_SECONDS.")
|
||||||
|
if pollDelay == "" {
|
||||||
|
warning = fmt.Sprintf("%s Since you have not set the poll delay, "+
|
||||||
|
"Packer will default to a 2-second delay.", warning)
|
||||||
|
}
|
||||||
|
log.Printf(warning)
|
||||||
|
} else if timeoutSeconds != "" {
|
||||||
|
log.Printf("[WARNING] (aws): env var AWS_TIMEOUT_SECONDS is " +
|
||||||
|
"deprecated in favor of AWS_MAX_ATTEMPTS. If you have not " +
|
||||||
|
"explicitly set AWS_POLL_DELAY_SECONDS, we are defaulting to a " +
|
||||||
|
"poll delay of 2 seconds, regardless of the AWS waiter's default.")
|
||||||
|
}
|
||||||
|
if maxAttempts == "" && timeoutSeconds == "" && pollDelay == "" {
|
||||||
|
log.Printf("[INFO] (aws): No AWS timeout and polling overrides have been set. " +
|
||||||
|
"Packer will default to waiter-specific delays and timeouts. If you would " +
|
||||||
|
"like to customize the length of time between retries and max " +
|
||||||
|
"number of retries you may do so by setting the environment " +
|
||||||
|
"variables AWS_POLL_DELAY_SECONDS and AWS_MAX_ATTEMPTS to your " +
|
||||||
|
"desired values.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func applyEnvOverrides(envOverrides overridableWaitVars) []request.WaiterOption {
|
func applyEnvOverrides(envOverrides overridableWaitVars) []request.WaiterOption {
|
||||||
waitOpts := make([]request.WaiterOption, 0)
|
waitOpts := make([]request.WaiterOption, 0)
|
||||||
// If user has set poll delay seconds, overwrite it. If user has NOT,
|
// If user has set poll delay seconds, overwrite it. If user has NOT,
|
||||||
|
@ -320,18 +351,7 @@ func applyEnvOverrides(envOverrides overridableWaitVars) []request.WaiterOption
|
||||||
// attempts, default to whatever the waiter has set as a default.
|
// attempts, default to whatever the waiter has set as a default.
|
||||||
if envOverrides.awsMaxAttempts.overridden {
|
if envOverrides.awsMaxAttempts.overridden {
|
||||||
waitOpts = append(waitOpts, request.WithWaiterMaxAttempts(envOverrides.awsMaxAttempts.Val))
|
waitOpts = append(waitOpts, request.WithWaiterMaxAttempts(envOverrides.awsMaxAttempts.Val))
|
||||||
}
|
|
||||||
|
|
||||||
if envOverrides.awsMaxAttempts.overridden && envOverrides.awsTimeoutSeconds.overridden {
|
|
||||||
log.Printf("WARNING: AWS_MAX_ATTEMPTS and AWS_TIMEOUT_SECONDS are" +
|
|
||||||
" both set. Packer will be using AWS_MAX_ATTEMPTS and discarding " +
|
|
||||||
"AWS_TIMEOUT_SECONDS. If you have not set AWS_POLL_DELAY_SECONDS, " +
|
|
||||||
"Packer will default to a 2 second poll delay.")
|
|
||||||
} else if envOverrides.awsTimeoutSeconds.overridden {
|
} else if envOverrides.awsTimeoutSeconds.overridden {
|
||||||
log.Printf("DEPRECATION WARNING: env var AWS_TIMEOUT_SECONDS is " +
|
|
||||||
"deprecated in favor of AWS_MAX_ATTEMPTS. If you have not " +
|
|
||||||
"explicitly set AWS_POLL_DELAY_SECONDS, we are defaulting to a " +
|
|
||||||
"poll delay of 2 seconds, regardless of the AWS waiter's default.")
|
|
||||||
maxAttempts := envOverrides.awsTimeoutSeconds.Val / envOverrides.awsPollDelaySeconds.Val
|
maxAttempts := envOverrides.awsTimeoutSeconds.Val / envOverrides.awsPollDelaySeconds.Val
|
||||||
// override the delay so we can get the timeout right
|
// override the delay so we can get the timeout right
|
||||||
if !envOverrides.awsPollDelaySeconds.overridden {
|
if !envOverrides.awsPollDelaySeconds.overridden {
|
||||||
|
@ -340,14 +360,6 @@ func applyEnvOverrides(envOverrides overridableWaitVars) []request.WaiterOption
|
||||||
}
|
}
|
||||||
waitOpts = append(waitOpts, request.WithWaiterMaxAttempts(maxAttempts))
|
waitOpts = append(waitOpts, request.WithWaiterMaxAttempts(maxAttempts))
|
||||||
}
|
}
|
||||||
if len(waitOpts) == 0 {
|
|
||||||
log.Printf("No AWS timeout and polling overrides have been set. " +
|
|
||||||
"Packer will default to waiter-specific delays and timeouts. If you would " +
|
|
||||||
"like to customize the length of time between retries and max " +
|
|
||||||
"number of retries you may do so by setting the environment " +
|
|
||||||
"variables AWS_POLL_DELAY_SECONDS and AWS_MAX_ATTEMPTS to your " +
|
|
||||||
"desired values.")
|
|
||||||
}
|
|
||||||
|
|
||||||
return waitOpts
|
return waitOpts
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
|
||||||
if len(errs.Errors) > 0 {
|
if len(errs.Errors) > 0 {
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
awscommon.LogEnvOverrideWarnings()
|
||||||
|
|
||||||
packer.LogSecretFilter.Set(p.config.AccessKey, p.config.SecretKey, p.config.Token)
|
packer.LogSecretFilter.Set(p.config.AccessKey, p.config.SecretKey, p.config.Token)
|
||||||
log.Println(p.config)
|
log.Println(p.config)
|
||||||
|
|
Loading…
Reference in New Issue