From ff4c79702dba020d14c60450d82484f83c95e7f3 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Thu, 7 Sep 2023 13:06:09 +0200 Subject: [PATCH 1/2] Bump ready timeout, log more, add timestamps. --- dev/env/scripts/up.sh | 2 +- fleetshard/main.go | 10 ++++++++-- scripts/lib/log.sh | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dev/env/scripts/up.sh b/dev/env/scripts/up.sh index b587fc74e0..b0615a2a35 100755 --- a/dev/env/scripts/up.sh +++ b/dev/env/scripts/up.sh @@ -81,7 +81,7 @@ if [[ "$SPAWN_LOGGER" == "true" && -n "${LOG_DIR:-}" ]]; then fi # Sanity check. -wait_for_container_to_become_ready "$ACSMS_NAMESPACE" "application=fleetshard-sync" "fleetshard-sync" +wait_for_container_to_become_ready "$ACSMS_NAMESPACE" "application=fleetshard-sync" "fleetshard-sync" 500 # Prerequisite for port-forwarding are pods in ready state. wait_for_container_to_become_ready "$ACSMS_NAMESPACE" "application=fleet-manager" "fleet-manager" diff --git a/fleetshard/main.go b/fleetshard/main.go index 51da6c0f2c..7d848ed750 100644 --- a/fleetshard/main.go +++ b/fleetshard/main.go @@ -40,7 +40,10 @@ func main() { glog.Infof("ManagedDB.SecurityGroup: %s", config.ManagedDB.SecurityGroup) glog.Infof("ManagedDB.SubnetGroup: %s", config.ManagedDB.SubnetGroup) - runtime, err := runtime.NewRuntime(config, k8s.CreateClientOrDie()) + glog.Info("Creating k8s client...") + k8sClient := k8s.CreateClientOrDie() + glog.Info("Creating runtime...") + runtime, err := runtime.NewRuntime(config, k8sClient) if err != nil { glog.Fatal(err) } @@ -52,6 +55,7 @@ func main() { } }() + glog.Info("Creating metrics server...") metricServer := fleetshardmetrics.NewMetricsServer(config.MetricsAddress) go func() { if err := metricServer.ListenAndServe(); err != nil { @@ -60,8 +64,10 @@ func main() { }() sigs := make(chan os.Signal, 1) - signal.Notify(sigs, os.Interrupt, unix.SIGTERM) + notifySignals := []os.Signal{os.Interrupt, unix.SIGTERM} + signal.Notify(sigs, notifySignals...) + glog.Infof("Application started. Will shut down gracefully on %s.", notifySignals) sig := <-sigs runtime.Stop() if err := metricServer.Close(); err != nil { diff --git a/scripts/lib/log.sh b/scripts/lib/log.sh index 1266d88476..36c0cd7009 100644 --- a/scripts/lib/log.sh +++ b/scripts/lib/log.sh @@ -3,7 +3,7 @@ die() { { # shellcheck disable=SC2059 - printf "$*" + printf "$(date --iso-8601=ns) $*" echo } >&2 exit 1 @@ -11,6 +11,6 @@ die() { log() { # shellcheck disable=SC2059 - printf "$*" + printf "$(date --iso-8601=ns) $*" echo } From 93ca3c19b2fc7222a02227e1717ccfad69c08f68 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Thu, 7 Sep 2023 13:16:03 +0200 Subject: [PATCH 2/2] Log timestamps, reuse code. --- scripts/lib/log.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/lib/log.sh b/scripts/lib/log.sh index 36c0cd7009..16af1dbbf7 100644 --- a/scripts/lib/log.sh +++ b/scripts/lib/log.sh @@ -1,16 +1,12 @@ #!/usr/bin/env bash die() { - { - # shellcheck disable=SC2059 - printf "$(date --iso-8601=ns) $*" - echo - } >&2 + log "$@" >&2 exit 1 } log() { # shellcheck disable=SC2059 - printf "$(date --iso-8601=ns) $*" + printf "$(date "+%Y-%m-%dT%H:%M:%S,%N%:z") $*" echo }