Skip to content

Commit 2ac189a

Browse files
Swopxvzf
authored andcommitted
fix: to verify: last updated wasn't updated in some insert
1 parent dfab0da commit 2ac189a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

internal/lease/leaseprovider.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (lp *leaseProviderImpl) cleanup(ctx context.Context) {
114114
func (lp *leaseProviderImpl) insert(ctx context.Context, leaseRequest *Request) (*Request, error) {
115115
log.Ctx(ctx).Debug().EmbedObject(leaseRequest).Msg("Inserting new lease request")
116116

117-
var updated bool = false
117+
updated := false
118118

119119
// Cleanup a potential leftover lease
120120
lp.cleanup(ctx)
@@ -135,7 +135,7 @@ func (lp *leaseProviderImpl) insert(ctx context.Context, leaseRequest *Request)
135135

136136
lp.known[leaseRequest.HeadSHA] = leaseRequest
137137
lp.known[leaseRequest.HeadSHA].Status = pointer.String(StatusPending)
138-
138+
updated = true
139139
} else {
140140
log.Ctx(ctx).Debug().EmbedObject(leaseRequest).Msg("Lease request is already existing")
141141
// Priority changed, update it
@@ -161,7 +161,7 @@ func (lp *leaseProviderImpl) insert(ctx context.Context, leaseRequest *Request)
161161
}
162162

163163
log.Ctx(ctx).Debug().EmbedObject(existing).Msg("Lease request updated")
164-
return existing, nil
164+
updated = true
165165
}
166166

167167
if updated {
@@ -274,5 +274,4 @@ func (lp *leaseProviderImpl) Release(ctx context.Context, leaseRequest *Request)
274274
}
275275

276276
return req, fmt.Errorf("unknown condition for commit %s", leaseRequest.HeadSHA)
277-
278277
}

0 commit comments

Comments
 (0)