Skip to content

Commit

Permalink
delete finished Jobs after 100 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
ebiiim committed Jan 5, 2023
1 parent e3b67a1 commit 889e092
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.2.1 - 2023-01-05

### Changed

- 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.

## 0.2.0 - 2022-12-10

### Added
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/
Deploy the Operator with the following command. It creates `gitbackup-system` namespace and deploys CRDs, controllers and other resources.

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

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

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

## Developing
Expand Down
3 changes: 3 additions & 0 deletions controllers/repository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ func (r *RepositoryReconciler) reconcileCronJob(ctx context.Context, repo v1beta
WithJobTemplate(batchv1apply.JobTemplateSpec().WithSpec(batchv1apply.JobSpec().
WithParallelism(1).
WithCompletions(1).
// Delete history after 100 hours.
// Since this is a backup task, basically it should be fine as long as the latest run was successful.
WithTTLSecondsAfterFinished(3600 * 100).
WithTemplate(podTemplateSpec)))
if repo.Spec.TimeZone != nil {
cronJobSpec.WithTimeZone(*repo.Spec.TimeZone)
Expand Down

0 comments on commit 889e092

Please sign in to comment.