Skip to content

Commit

Permalink
UPSTREAM: <carry>: add shutdown annotation to response header
Browse files Browse the repository at this point in the history
If it is useful we will combine this with the following carry:
20caad9: UPSTREAM: 115328: annotate early and late requests
  • Loading branch information
tkashem authored and bertinatto committed Mar 6, 2024
1 parent ec482bf commit c88b350
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ func withShutdownLateAnnotation(handler http.Handler, shutdownInitiated lifecycl
self = fmt.Sprintf("%s%t", self, requestor.GetName() == user.APIServerUser)
}

audit.AddAuditAnnotation(req.Context(), "apiserver.k8s.io/shutdown",
fmt.Sprintf("%s %s loopback=%t", late, self, isLoopback(req.RemoteAddr)))
message := fmt.Sprintf("%s %s loopback=%t", late, self, isLoopback(req.RemoteAddr))
audit.AddAuditAnnotation(req.Context(), "apiserver.k8s.io/shutdown", message)

handler.ServeHTTP(w, req)
w.Header().Set("X-OpenShift-Shutdown", message)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ func TestWithShutdownLateAnnotation(t *testing.T) {
t.Logf("got: %s", valueGot)
t.Errorf("expected annotation to match, diff: %s", cmp.Diff(test.annotationShouldContain, valueGot))
}
if header := w.Header().Get("X-OpenShift-Shutdown"); !strings.Contains(header, test.annotationShouldContain) {
t.Errorf("expected response header to match, diff: %s", cmp.Diff(test.annotationShouldContain, header))
}
}
})
}
Expand Down

0 comments on commit c88b350

Please sign in to comment.