Skip to content

Commit

Permalink
skip blocking if grace period = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorLeonHC committed Aug 17, 2023
1 parent 7670025 commit 90ec82c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/consul-dataplane/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ type EnvoyFlags struct {
GracefulShutdownPath *string `json:"gracefulShutdownPath,omitempty"`
GracefulPort *int `json:"gracefulPort,omitempty"`
DumpEnvoyConfigOnExitEnabled *bool `json:"dumpEnvoyConfigOnExitEnabled,omitempty"`

StartupGracePeriodSeconds *int `json:"startupGracePeriodSeconds,omitempty"`
GracefulStartupPath *string `json:"gracefulStartupPath,omitempty"`
//Time in seconds to wait for dataplane to be ready.
StartupGracePeriodSeconds *int `json:"startupGracePeriodSeconds,omitempty"`
//Endpoint for graceful startup function.
GracefulStartupPath *string `json:"gracefulStartupPath,omitempty"`
}

const (
Expand Down
3 changes: 3 additions & 0 deletions pkg/consuldp/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ 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() {
if m.startupGracePeriodSeconds == 0 {
return
}
timeout := time.Duration(m.startupGracePeriodSeconds) * time.Second
m.logger.Info(fmt.Sprintf("blocking container startup until Envoy ready or grace period of %d seconds elapsed", m.startupGracePeriodSeconds))
ctx, cancel := context.WithTimeout(context.Background(), timeout)
Expand Down

0 comments on commit 90ec82c

Please sign in to comment.