From c32220762f7c30d8917763088d3f04e3e35c7464 Mon Sep 17 00:00:00 2001 From: Marina Biryukova Date: Wed, 27 Dec 2023 13:06:11 +0300 Subject: [PATCH] [#288] Fix possibility of panic during SIGHUP Signed-off-by: Marina Biryukova --- CHANGELOG.md | 1 + cmd/s3-gw/service.go | 5 ++++- internal/logs/logs.go | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ea40fec..07ae8836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This document outlines major changes between releases. - Fix marshaling errors in `DeleteObjects` method (#222) - Fix status code in GET/HEAD delete marker (#226) - Fix `NextVersionIDMarker` in `list-object-versions` (#248) +- Fix possibility of panic during SIGHUP (#288) ### Added - Add new `frostfs.buffer_max_size_for_put` config param and sync TZ hash for PUT operations (#197) diff --git a/cmd/s3-gw/service.go b/cmd/s3-gw/service.go index 18aefaee..6b8b9937 100644 --- a/cmd/s3-gw/service.go +++ b/cmd/s3-gw/service.go @@ -34,6 +34,9 @@ func (ms *Service) ShutDown(ctx context.Context) { ms.log.Info(logs.ShuttingDownService, zap.String("endpoint", ms.Addr)) err := ms.Shutdown(ctx) if err != nil { - ms.log.Panic(logs.CantShutDownService) + ms.log.Error(logs.CantGracefullyShutDownService, zap.Error(err)) + if err = ms.Close(); err != nil { + ms.log.Panic(logs.CantShutDownService, zap.Error(err)) + } } } diff --git a/internal/logs/logs.go b/internal/logs/logs.go index 951ba44e..c3ca1fa7 100644 --- a/internal/logs/logs.go +++ b/internal/logs/logs.go @@ -12,6 +12,7 @@ const ( ServiceCouldntStartOnConfiguredPort = "service couldn't start on configured port" // Warn in ../../cmd/s3-gw/service.go ServiceHasntStartedSinceItsDisabled = "service hasn't started since it's disabled" // Info in ../../cmd/s3-gw/service.go ShuttingDownService = "shutting down service" // Info in ../../cmd/s3-gw/service.go + CantGracefullyShutDownService = "can't gracefully shut down service, force stop" // Error in ../../cmd/s3-gw/service.go ContainerResolverWillBeDisabled = "container resolver will be disabled because of resolvers 'resolver_order' is empty" // Info in ../../cmd/s3-gw/app.go FailedToInitializeTracing = "failed to initialize tracing" // Warn in ../../cmd/s3-gw/app.go TracingConfigUpdated = "tracing config updated" // Info in ../../cmd/s3-gw/app.go