[MAR-3131] Set grace to 0 on non-positive lease duration (#12372)
* [MAR-3131] Set grace to 0 on non-positive lease duration * [MAR-3131] Add changelog * [VAULT-3131] Add test for negative lease duration
This commit is contained in:
parent
306071f8b8
commit
c379fd43a9
|
@ -377,7 +377,7 @@ func (r *LifetimeWatcher) doRenewWithOptions(tokenMode bool, nonRenewable bool,
|
||||||
// assumptions given the total lease time; it also adds some jitter to not have
|
// assumptions given the total lease time; it also adds some jitter to not have
|
||||||
// clients be in sync.
|
// clients be in sync.
|
||||||
func (r *LifetimeWatcher) calculateGrace(leaseDuration time.Duration) {
|
func (r *LifetimeWatcher) calculateGrace(leaseDuration time.Duration) {
|
||||||
if leaseDuration == 0 {
|
if leaseDuration <= 0 {
|
||||||
r.grace = 0
|
r.grace = 0
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,17 @@ func TestLifetimeWatcher(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
15 * time.Second,
|
||||||
|
"negative_lease_duration",
|
||||||
|
-15,
|
||||||
|
15,
|
||||||
|
func(_ string, _ int) (*Secret, error) {
|
||||||
|
return renewedSecret, nil
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note: bug
|
||||||
|
core/api: Fix an arm64 bug converting a negative int to an unsigned int
|
||||||
|
```
|
Loading…
Reference in New Issue