Skip to content

Commit

Permalink
Merge pull request #104 from vansante/skip-empty-prop
Browse files Browse the repository at this point in the history
If property becomes unset during process, skip the dataset
  • Loading branch information
vansante authored Jul 23, 2024
2 parents 8457150 + b2f7c84 commit 679c9e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions job/snapshots_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func (r *Runner) createDatasetSnapshot(ds *zfs.Dataset) error {
}()

intervalMinsProp := r.config.Properties.snapshotIntervalMinutes()
if !propertyIsSet(ds.ExtraProps[intervalMinsProp]) {
return nil // Not set (anymore), skip
}

intervalMins, err := strconv.ParseInt(ds.ExtraProps[intervalMinsProp], 10, 64)
if err != nil {
return fmt.Errorf("error parsing %s property on %s: %w", intervalMinsProp, ds.Name, err)
Expand Down
8 changes: 8 additions & 0 deletions job/snapshots_mark.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func (r *Runner) markPrunableExcessSnapshots() error {
return fmt.Errorf("error retrieving count retention dataset %s: %w", dataset, err)
}

if !propertyIsSet(ds.ExtraProps[countProp]) {
continue // Not set (anymore), skip
}

retentionCount, err := parseDatasetIntProperty(ds, countProp)
if err != nil {
return fmt.Errorf("error parsing %s property on %s: %w", countProp, dataset, err)
Expand Down Expand Up @@ -180,6 +184,10 @@ func (r *Runner) markPrunableSnapshotsByAge() error {
return fmt.Errorf("error retrieving time retention dataset %s: %w", dataset, err)
}

if !propertyIsSet(ds.ExtraProps[retentionProp]) {
continue // Not set (anymore), skip
}

retentionMinutes, err := parseDatasetIntProperty(ds, retentionProp)
if err != nil {
return fmt.Errorf("error parsing %s property on %s: %w", retentionProp, dataset, err)
Expand Down

0 comments on commit 679c9e1

Please sign in to comment.