Skip to content

Commit 889e092

Browse files
committed
delete finished Jobs after 100 hours
1 parent e3b67a1 commit 889e092

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.2.1 - 2023-01-05
4+
5+
### Changed
6+
7+
- Finished Jobs (regardless of completeness) will be deleted after 100 hours. Since this is a backup task, basically it should be fine as long as the latest run was successful.
8+
39
## 0.2.0 - 2022-12-10
410

511
### Added

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/
6060
Deploy the Operator with the following command. It creates `gitbackup-system` namespace and deploys CRDs, controllers and other resources.
6161

6262
```sh
63-
kubectl apply -f https://github.com/ebiiim/gitbackup/releases/download/v0.2.0/gitbackup.yaml
63+
kubectl apply -f https://github.com/ebiiim/gitbackup/releases/download/v0.2.1/gitbackup.yaml
6464
```
6565

6666
### Backup a Git repository with a `Repository` resource
@@ -162,7 +162,7 @@ gitbackup-coll1-gitbackup 0 6 * * * False 0 <none> 5s
162162
Delete the Operator and resources with the following command.
163163

164164
```sh
165-
kubectl delete -f https://github.com/ebiiim/gitbackup/releases/download/v0.2.0/gitbackup.yaml
165+
kubectl delete -f https://github.com/ebiiim/gitbackup/releases/download/v0.2.1/gitbackup.yaml
166166
```
167167

168168
## Developing

controllers/repository_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ func (r *RepositoryReconciler) reconcileCronJob(ctx context.Context, repo v1beta
203203
WithJobTemplate(batchv1apply.JobTemplateSpec().WithSpec(batchv1apply.JobSpec().
204204
WithParallelism(1).
205205
WithCompletions(1).
206+
// Delete history after 100 hours.
207+
// Since this is a backup task, basically it should be fine as long as the latest run was successful.
208+
WithTTLSecondsAfterFinished(3600 * 100).
206209
WithTemplate(podTemplateSpec)))
207210
if repo.Spec.TimeZone != nil {
208211
cronJobSpec.WithTimeZone(*repo.Spec.TimeZone)

0 commit comments

Comments
 (0)