Skip to content

Commit

Permalink
Merge branch 'main' into chore/udate-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-karpenko committed Jul 24, 2024
2 parents 19e3459 + 533e707 commit c571da4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

All notable changes to this project will be documented in this file.

## [0.1.5] - 2024-07-12
## [0.1.6] - 2024-07-24
### Details
#### Fixed
- Fix non-inclusive ranges of random generators by @alex-karpenko in [#9](https://github.com/alex-karpenko/kube-lease-manager/pull/9)
- Fix concurrent Lease resource creating by @alex-karpenko in [#11](https://github.com/alex-karpenko/kube-lease-manager/pull/11)

## [0.1.5] - 2024-07-13
### Details
#### Added
- Add example of watch approach - simple jobs logger by @alex-karpenko in [#8](https://github.com/alex-karpenko/kube-lease-manager/pull/8)
Expand Down Expand Up @@ -36,6 +42,7 @@ All notable changes to this project will be documented in this file.
#### Changed
- First release by @alex-karpenko in [#1](https://github.com/alex-karpenko/kube-lease-manager/pull/1)

[0.1.6]: https://github.com/alex-karpenko/kube-lease-manager/compare/v0.1.5..v0.1.6
[0.1.5]: https://github.com/alex-karpenko/kube-lease-manager/compare/v0.1.4..v0.1.5
[0.1.4]: https://github.com/alex-karpenko/kube-lease-manager/compare/v0.1.3..v0.1.4
[0.1.3]: https://github.com/alex-karpenko/kube-lease-manager/compare/v0.1.2..v0.1.3
Expand Down
10 changes: 9 additions & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,15 @@ impl LeaseState {
if let Ok(lease) = result {
Ok(lease)
} else if let Err(LeaseStateError::NonexistentLease(_)) = result {
self.api.create(&pp, &data).await.map_err(LeaseStateError::from)
// Try to create new Lease resource,
// but don't panic if someone else created it while we're trying
match self.api.create(&pp, &data).await {
Ok(lease) => Ok(lease),
Err(kube::Error::Api(err)) if err.reason == "AlreadyExists" && err.code == 409 => {
self.get().await
}
Err(err) => Err(LeaseStateError::from(err)),
}
} else {
result
}
Expand Down

0 comments on commit c571da4

Please sign in to comment.