Fix duplicate headers in bao agent re-authentication (#2373)
Some checks failed
CI / Setup (push) Has been cancelled
CI / Verify doc-ui only PRs (push) Has been cancelled
CI / Run Go tests (push) Has been cancelled
CI / Run Go tests tagged with testonly (push) Has been cancelled
CI / Run Go tests with data race detection (push) Has been cancelled
CI / Test UI (push) Has been cancelled
CI / tests-completed (push) Has been cancelled
Run linters / Vulnerable dependencies (push) Has been cancelled
Run linters / Code checks (push) Has been cancelled
Run linters / Semgrep (push) Has been cancelled
Run linters / Go mod checks (push) Has been cancelled
Run linters / EL8 Go build checks (push) Has been cancelled
Run linters / Protobuf checks (push) Has been cancelled
CodeQL Advanced / Analyze (go) (push) Has been cancelled
Go Dependency Submission / go-dependency-submission (push) Has been cancelled
Mirror Repo / mirror (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled

Bao agent adds the headers to the client on every authentication run,
this causes the Kerberos authentication method to fail due to a
duplicated authentication header. Headers are also added on indefinitely
leading to increasing memory usage on each re-authentication run

Signed-off-by: Nikos Tsipinakis <nikos.tsipinakis@cern.ch>
This commit is contained in:
Nikos Tsipinakis
2026-02-03 22:40:33 +01:00
committed by GitHub
parent 5cfe6a30cf
commit 7bf0a1500d
2 changed files with 15 additions and 11 deletions

3
changelog/2373.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
agent/auth: Fix token reissue error with kerberos method
```

View File

@@ -180,6 +180,7 @@ func (ah *AuthHandler) Run(ctx context.Context, am AuthMethod) error {
}
headers.Set("User-Agent", ah.userAgent)
ah.client.SetHeaders(headers)
ah.client.SetCloneHeaders(true)
}
var watcher *api.LifetimeWatcher
@@ -261,21 +262,21 @@ func (ah *AuthHandler) Run(ctx context.Context, am AuthMethod) error {
}
}
if ah.wrapTTL > 0 {
wrapClient, err := clientToUse.Clone()
if err != nil {
ah.logger.Error("error creating client for wrapped call", "error", err, "backoff", backoffCfg)
metrics.IncrCounter([]string{ah.metricsSignifier, "auth", "failure"}, 1)
// Clone client as we don't want to persist the authentication headers set below
clientToUse, err = clientToUse.Clone()
if err != nil {
ah.logger.Error("error creating client for authentication call", "error", err, "backoff", backoffCfg)
metrics.IncrCounter([]string{ah.metricsSignifier, "auth", "failure"}, 1)
if backoff(ctx, backoffCfg) {
continue
}
return err
if backoff(ctx, backoffCfg) {
continue
}
wrapClient.SetWrappingLookupFunc(func(string, string) string {
return err
}
if ah.wrapTTL > 0 {
clientToUse.SetWrappingLookupFunc(func(string, string) string {
return ah.wrapTTL.String()
})
clientToUse = wrapClient
}
for key, values := range header {
for _, value := range values {