Skip to content

Commit

Permalink
delete snaphost when task is deleted (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Cook authored Aug 5, 2016
1 parent 6435788 commit b6983bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [#783](https://github.com/influxdata/kapacitor/pull/783): Fix panic when revoking tokens not already defined.
- [#784](https://github.com/influxdata/kapacitor/pull/784): Fix several issues with comment formatting in TICKscript.

- [#772](https://github.com/influxdata/kapacitor/issues/772): Delete task snapshot data when a task is deleted.

## v1.0.0-beta4 [2016-07-27]

Expand Down
9 changes: 8 additions & 1 deletion services/task_store/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ type TemplateDAO interface {
// Data access object for Snapshot data.
type SnapshotDAO interface {
// Load a saved snapshot.
// ErrNoSnapshotExists will be returned if HasSnapshot returns false.
// ErrNoSnapshotExists will be returned if the snapshot does not exist.
Get(id string) (*Snapshot, error)
// Save a snapshot.
Put(id string, snapshot *Snapshot) error
// Delete a snapshot
Delete(id string) error
// Whether a snapshot exists in the store.
Exists(id string) (bool, error)
}
Expand Down Expand Up @@ -563,6 +565,11 @@ func (d *snapshotKV) Put(id string, snapshot *Snapshot) error {
return d.store.Put(key, data)
}

func (d *snapshotKV) Delete(id string) error {
key := d.snapshotDataKey(id)
return d.store.Delete(key)
}

func (d *snapshotKV) Exists(id string) (bool, error) {
key := d.snapshotDataKey(id)
return d.store.Exists(key)
Expand Down
4 changes: 4 additions & 0 deletions services/task_store/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,10 @@ func (ts *Service) handleDeleteTask(w http.ResponseWriter, r *http.Request) {
}

func (ts *Service) deleteTask(id string) error {
// Delete associated snapshot
ts.snapshots.Delete(id)

// Delete task object
task, err := ts.tasks.Get(id)
if err != nil {
if err == ErrNoTaskExists {
Expand Down

0 comments on commit b6983bb

Please sign in to comment.