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

Enable/Disable by glob #381

Merged
merged 1 commit into from
Apr 1, 2016
Merged

Conversation

yosiat
Copy link
Contributor

@yosiat yosiat commented Mar 26, 2016

Issue - #337

  • Add FindTasks method for fetching all rawTask[] by a predicate
  • Enabling/Disabling by glob

For example:
> kapacitor enable "window_*"
Will enable all tasks that starts with "window_"
The same for disable

Notes:

  • I think this would be nice for delete as well
  • The enable is not efficient as possible - I am accessing boltdb for each task, I can change it, but I think it will hurt the readability
  • If at least one task is failed to enable/disable I am stopping and returning an error - are we ok about this behaviour?

@nathanielc
Copy link
Contributor

I think this would be nice for delete as well

+1

The enable is not efficient as possible - I am accessing boltdb for each task, I can change it, but I think it will hurt the readability

Simple is better

If at least one task is failed to enable/disable I am stopping and returning an error - are we ok about this behavior?

Yes

if askedTaskName == taskName {
return true, nil
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are not doing any matching here why are we not looping over LoadRaw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm.. I agree, but the reason we need to handle the case where tasks is empty, and we want to fetch all tasks.

The looping LoadRaw is more simple & elegant.. do you have any way can do this and still support the empty tasks array?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing it but I do not see the change in behavior from the previous implementation to this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure we are on the same idea, you are suggesting that instead of using FindTasks and looking at the bucket we will do something like this:

for taskName := range tasks {
   raw:=ts.LoadRaw(taskName)
  // convert to TaskSummaryInfo, and IsEnabled, and ExecutionStatus
}

If you are suggesting doing this approach, we have the case where the tasks are empty and we want to fetch all tasks - "/tasks", so we are using FindTasks to find the matching tasks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not suggesting that, but rather looking at the original implementation it handled the case where tasks was empty via the ForEach boltdb bucket call. I see that method has changed but I do not see how its behavior has changed so I am confused as to why it was modified. I am probably just missing something....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, you are suggesting to undo the change in this function? I changed this function to use the FindTasks, but after a little bit of thinking it makes things harder.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is no need to use the FindTasks if it is not necessary.

@yosiat yosiat force-pushed the enable-disable-glob branch from b1d68f6 to 9c9dcbd Compare March 31, 2016 16:25
@yosiat
Copy link
Contributor Author

yosiat commented Apr 1, 2016

@nathanielc are we ok on this PR or do you want me to implement delete by glob as well before we merge?

@yosiat yosiat force-pushed the enable-disable-glob branch from cacea41 to 083bccf Compare April 1, 2016 17:07
@nathanielc
Copy link
Contributor

@yosiat This looks good to go. Do you want to add a CHANGELOG entry real quick?

@yosiat
Copy link
Contributor Author

yosiat commented Apr 1, 2016

I will do in one hour, I forgot to update the usage for the relevant
commands in kapacitor cmd
On Apr 1, 2016 8:27 PM, "Nathaniel Cook" [email protected] wrote:

@yosiat https://github.com/yosiat This looks good to go. Do you want to
add a CHANGELOG entry real quick?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#381 (comment)

@yosiat yosiat force-pushed the enable-disable-glob branch from 083bccf to d14eeeb Compare April 1, 2016 18:38
@yosiat
Copy link
Contributor Author

yosiat commented Apr 1, 2016

@nathanielc Updated and added help usage..
please make sure it's ok, and I will squash the commits


Or, you can enable by glob:

$ kapacitor enable *_alert
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines look like there are extras?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops.. I did copy/paste, Will fix this.

@yosiat yosiat force-pushed the enable-disable-glob branch from 3bd1236 to e893c52 Compare April 1, 2016 19:03
@nathanielc
Copy link
Contributor

@yosiat Looks good, I'll merge when its squashed

* Enabling and disabling tasks by glob, for example:
  `kapacitor enable window_*`
* Deleting tasks by glob
* Adding FindTasks method for finding tasks by predicate
@yosiat yosiat force-pushed the enable-disable-glob branch from e893c52 to b9d188d Compare April 1, 2016 19:42
@yosiat
Copy link
Contributor Author

yosiat commented Apr 1, 2016

@nathanielc squashed

@nathanielc nathanielc merged commit bc3aa6d into influxdata:master Apr 1, 2016
@yosiat yosiat deleted the enable-disable-glob branch April 2, 2016 10:57
@devfacet
Copy link

devfacet commented Apr 7, 2016

@yosiat : does it mean kapacitor enable "*" and kapacitor disable "*" enabled and disable all the tasks?

@yosiat
Copy link
Contributor Author

yosiat commented Apr 8, 2016

@fatihcode yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants