Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete snaphost when task is deleted #776

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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