diff --git a/cmd/consul-dataplane/main.go b/cmd/consul-dataplane/main.go index d5098e5a..93cd40da 100644 --- a/cmd/consul-dataplane/main.go +++ b/cmd/consul-dataplane/main.go @@ -99,12 +99,11 @@ func init() { IntVar(flags, &flagOpts.dataplaneConfig.Envoy.ShutdownGracePeriodSeconds, "shutdown-grace-period-seconds", "DP_SHUTDOWN_GRACE_PERIOD_SECONDS", "Amount of time to wait after receiving a SIGTERM signal before terminating the proxy.") StringVar(flags, &flagOpts.dataplaneConfig.Envoy.GracefulShutdownPath, "graceful-shutdown-path", "DP_GRACEFUL_SHUTDOWN_PATH", "An HTTP path to serve the graceful shutdown endpoint.") IntVar(flags, &flagOpts.dataplaneConfig.Envoy.GracefulPort, "graceful-port", "DP_GRACEFUL_PORT", "A port to serve HTTP endpoints for graceful shutdown.") - - // Default is false, may be useful for debugging unexpected termination. - BoolVar(flags, &flagOpts.dataplaneConfig.Envoy.DumpEnvoyConfigOnExitEnabled, "dump-envoy-config-on-exit", "DP_DUMP_ENVOY_CONFIG_ON_EXIT", "Call the Envoy /config_dump endpoint during consul-dataplane controlled shutdown.") - //######################### IntVar(flags, &flagOpts.dataplaneConfig.Envoy.StartupGracePeriodSeconds, "startup-grace-period-seconds", "DP_STARTUP_GRACE_PERIOD_SECONDS", "Amount of time to wait for consul-dataplane startup.") StringVar(flags, &flagOpts.dataplaneConfig.Envoy.GracefulStartupPath, "graceful-startup-path", "DP_GRACEFUL_STARTUP_PATH", "An HTTP path to serve the graceful startup endpoint.") + // Default is false, may be useful for debugging unexpected termination. + BoolVar(flags, &flagOpts.dataplaneConfig.Envoy.DumpEnvoyConfigOnExitEnabled, "dump-envoy-config-on-exit", "DP_DUMP_ENVOY_CONFIG_ON_EXIT", "Call the Envoy /config_dump endpoint during consul-dataplane controlled shutdown.") + flags.StringVar(&flagOpts.configFile, "config-file", "", "The json config file for configuring consul data plane") } diff --git a/pkg/consuldp/config.go b/pkg/consuldp/config.go index c9353377..df7add46 100644 --- a/pkg/consuldp/config.go +++ b/pkg/consuldp/config.go @@ -293,15 +293,14 @@ type EnvoyConfig struct { ShutdownGracePeriodSeconds int // GracefulShutdownPath is the path on which the HTTP endpoint to initiate a graceful shutdown of Envoy is served GracefulShutdownPath string - // GracefulPort is the port on which the HTTP server for graceful shutdown endpoints will be available. - GracefulPort int - // DumpEnvoyConfigOnExitEnabled configures whether to call Envoy's /config_dump endpoint during consul-dataplane controlled shutdown. - DumpEnvoyConfigOnExitEnabled bool - //############## //StartupGracePeriodSeconds is the amount of time to block application after startup for Envoy proxy to be ready. StartupGracePeriodSeconds int // GracefulStartupPath is the path on which the HTTP endpoint to initiate a graceful startup of Envoy is served GracefulStartupPath string + // GracefulPort is the port on which the HTTP server for graceful shutdown endpoints will be available. + GracefulPort int + // DumpEnvoyConfigOnExitEnabled configures whether to call Envoy's /config_dump endpoint during consul-dataplane controlled shutdown. + DumpEnvoyConfigOnExitEnabled bool // ExtraArgs are the extra arguments passed to envoy at startup of the proxy ExtraArgs []string } diff --git a/pkg/consuldp/lifecycle.go b/pkg/consuldp/lifecycle.go index da3cb7fe..b8655d97 100644 --- a/pkg/consuldp/lifecycle.go +++ b/pkg/consuldp/lifecycle.go @@ -219,9 +219,9 @@ func (m *lifecycleConfig) gracefulShutdown() { func (m *lifecycleConfig) gracefulStartupHandler(rw http.ResponseWriter, _ *http.Request) { - m.gracefulStartup() //Unlike in gracefulShutdown, we want to delay the OK response until envoy is ready //in order to block application container. + m.gracefulStartup() rw.WriteHeader(http.StatusOK) } @@ -229,8 +229,8 @@ func (m *lifecycleConfig) gracefulStartupHandler(rw http.ResponseWriter, _ *http // gracefulStartup blocks until the startup grace period has elapsed or we have confirmed that // Envoy proxy is ready. func (m *lifecycleConfig) gracefulStartup() { - m.logger.Info("Blocking container startup until Envoy ready / grace period elapsed") - timeout := time.Duration(m.shutdownGracePeriodSeconds) * time.Second + timeout := time.Duration(m.startupGracePeriodSeconds) * time.Second + m.logger.Info("Blocking container startup until Envoy ready or until graceful timeout elapsed", "timeout", timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel()