Skip to content

Commit

Permalink
controller: Stop logging errors on shutdown (#12167)
Browse files Browse the repository at this point in the history
When a controller is shutdown, the admin server fails. This failure is logged
as an error, even when the shutdown was graceful.

This change updates the shutdown behavior to log more appropriately.

Signed-off-by: wafuwafu13 <[email protected]>
  • Loading branch information
wafuwafu13 authored Mar 22, 2024
1 parent ccdf6b7 commit 9a5284f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package destination

import (
"errors"
"net/http"
"testing"
"time"

Expand Down Expand Up @@ -113,8 +115,9 @@ func TestEndpointProfileTranslator(t *testing.T) {
// The queue should be full and the next update should fail.
t.Logf("Queue length=%d capacity=%d", translator.queueLen(), updateQueueCapacity)
if err := translator.Update(podAddr); err == nil {
t.Fatalf("Expected update to fail; queue=%d; capacity=%d", translator.queueLen(), updateQueueCapacity)

if !errors.Is(err, http.ErrServerClosed) {
t.Fatalf("Expected update to fail; queue=%d; capacity=%d", translator.queueLen(), updateQueueCapacity)
}
}

select {
Expand Down
8 changes: 7 additions & 1 deletion controller/cmd/destination/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package destination

import (
"context"
"errors"
"flag"
"net"
"net/http"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -56,7 +58,11 @@ func Main(args []string) {
go func() {
log.Infof("starting admin server on %s", *metricsAddr)
if err := adminServer.ListenAndServe(); err != nil {
log.Errorf("failed to start destination admin server: %s", err)
if errors.Is(err, http.ErrServerClosed) {
log.Infof("Admin server closed (%s)", *metricsAddr)
} else {
log.Errorf("Admin server error (%s): %s", *metricsAddr, err)
}
}
}()

Expand Down

0 comments on commit 9a5284f

Please sign in to comment.