Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAR-3131] Set grace to 0 on non-positive lease duration #12372

Merged
merged 3 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/lifetime_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// clients be in sync.
func (r *LifetimeWatcher) calculateGrace(leaseDuration time.Duration) {
if leaseDuration == 0 {
if leaseDuration <= 0 {
r.grace = 0
return
}
Expand Down
11 changes: 11 additions & 0 deletions api/renewer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ func TestLifetimeWatcher(t *testing.T) {
nil,
false,
},
{
15 * time.Second,
"negative_lease_duration",
-15,
15,
func(_ string, _ int) (*Secret, error) {
return renewedSecret, nil
},
nil,
true,
},
}

for _, tc := range cases {
Expand Down
3 changes: 3 additions & 0 deletions changelog/12372.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note: bug
core/api: Fix an arm64 bug converting a negative int to an unsigned int
```