Skip to content

Commit

Permalink
wip: minor syntax fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemorris committed Jun 1, 2023
1 parent 004914f commit 6f0ecdc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package lifecycle

import (
"errors"
"fmt"
"strconv"

Expand Down Expand Up @@ -63,7 +62,7 @@ func (lc Config) ShutdownGracePeriodSeconds(pod corev1.Pod) (int, error) {
if shutdownGracePeriodSecondsAnnotation, ok := pod.Annotations[constants.AnnotationSidecarProxyLifecycleShutdownGracePeriodSeconds]; ok {
val, err := strconv.ParseUint(shutdownGracePeriodSecondsAnnotation, 10, 64)
if err != nil {
return nil, fmt.Errorf("unable to parse annotation %q: %w", constants.AnnotationSidecarProxyLifecycleShutdownGracePeriodSeconds, err)
return 0, fmt.Errorf("unable to parse annotation %q: %w", constants.AnnotationSidecarProxyLifecycleShutdownGracePeriodSeconds, err)
}
shutdownGracePeriodSeconds = int(val)
}
Expand Down
58 changes: 29 additions & 29 deletions control-plane/connect-inject/webhook/consul_dataplane_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,36 +247,36 @@ func (w *MeshWebhook) getContainerSidecarArgs(namespace corev1.Namespace, mpi mu
args = append(args, fmt.Sprintf("-envoy-admin-bind-port=%d", 19000+mpi.serviceIndex))
}

enableProxyLifecycle, err := w.LifecycleConfig.EnableProxyLifecycle(pod)
if err != nil {
enableProxyLifecycle, err := w.LifecycleConfig.EnableProxyLifecycle(pod)
if err != nil {
return nil, fmt.Errorf("unable to determine if proxy lifecycle management is enabled: %w", err)
}
if enableProxyLifecycle {
shutdownDrainListeners, err := w.LifecycleConfig.EnableShutdownDrainListeners(pod)
if err != nil {
return nil, fmt.Errorf("unable to determine if proxy lifecycle shutdown listener draining is enabled: %w", err)
}
if shutdownDrainListeners {
args = append(args, "-shutdown-drain-listeners")
}

shutdownGracePeriodSeconds, err := w.LifecycleConfig.ShutdownGracePeriodSeconds(pod) {
if err != nil {
return nil, fmt.Errorf("unable to determine proxy lifecycle shutdown grace period: %w", err)
}
args = append(args, fmt.Sprintf("-shutdown-grace-period=%d", shutdownGracePeriodSeconds))

gracefulPort, err := w.LifecycleConfig.GracefulPort(pod)
if err != nil {
return nil, fmt.Errorf("unable to determine proxy lifecycle graceful port: %w", err)
}
args = append(args, fmt.Sprintf("-graceful-port=%d", gracefulPort))

gracefulShutdownPath := w.LifecycleConfig.GracefulShutdownPath(pod)
if err != nil {
return nil, fmt.Errorf("unable to determine proxy lifecycle graceful shutdown path: %w", err)
}
args = append(args, fmt.Sprintf("-graceful-shutdown-path=%s", gracefulShutdownPath))
}
if enableProxyLifecycle {
shutdownDrainListeners, err := w.LifecycleConfig.EnableShutdownDrainListeners(pod)
if err != nil {
return nil, fmt.Errorf("unable to determine if proxy lifecycle shutdown listener draining is enabled: %w", err)
}
if shutdownDrainListeners {
args = append(args, "-shutdown-drain-listeners")
}

shutdownGracePeriodSeconds, err := w.LifecycleConfig.ShutdownGracePeriodSeconds(pod)
if err != nil {
return nil, fmt.Errorf("unable to determine proxy lifecycle shutdown grace period: %w", err)
}
args = append(args, fmt.Sprintf("-shutdown-grace-period=%d", shutdownGracePeriodSeconds))

gracefulPort, err := w.LifecycleConfig.GracefulPort(pod)
if err != nil {
return nil, fmt.Errorf("unable to determine proxy lifecycle graceful port: %w", err)
}
args = append(args, fmt.Sprintf("-graceful-port=%d", gracefulPort))

gracefulShutdownPath := w.LifecycleConfig.GracefulShutdownPath(pod)
if err != nil {
return nil, fmt.Errorf("unable to determine proxy lifecycle graceful shutdown path: %w", err)
}
args = append(args, fmt.Sprintf("-graceful-shutdown-path=%s", gracefulShutdownPath))
}

// Set a default scrape path that can be overwritten by the annotation.
Expand Down

0 comments on commit 6f0ecdc

Please sign in to comment.