Fix panic in credential renewal job

This commit modifies the credential renewal job to handle a case where the `renewLease` method can
return `nil, nil`. Currently, a panic is caused by usage of the `renewedCred` variable in this scenario.

This commit adds a nil check and returns an error if the `renewedCred` variable is returned as `nil`.

Signed-off-by: David Bond <davidsbond93@gmail.com>
pull/5116/head
David Bond 2 years ago
parent b120a03f43
commit 036d7adb61
No known key found for this signature in database
GPG Key ID: A35B34F344ED7AFE

@ -604,6 +604,9 @@ func (r *CredentialRenewalJob) renewCred(ctx context.Context, c *privateCredenti
if err != nil {
return errors.Wrap(ctx, err, op, errors.WithMsg("unable to renew credential"))
}
if renewedCred == nil {
return errors.New(ctx, errors.Unknown, op, "vault returned empty credential")
}
cred.expiration = time.Duration(renewedCred.LeaseDuration) * time.Second
query, values := cred.updateExpirationQuery()

Loading…
Cancel
Save