{"action":"created","comment":{"url":"https://api.github.com/repos/intelsdi-x/snap/pulls/comments/73760476","id":73760476,"diff_hunk":"@@ -114,14 +114,226 @@ func stringValToInt(val string) (int, error) {\n \treturn int(parsedField), nil\n }\n \n+func (t *task) checkScheduleWindow(start time.Time, stop time.Time) error {\n+\t// if the stop time defined by the user is in the past, then throw\n+\t// an error (at least some of the defined window should be in the future)\n+\tif time.Now().Add(createTaskNowPad).After(stop) {\n+\t\treturn fmt.Errorf(\"Usage error (poorly defined time window); when constructing a new 'windowed' schedule, part of that window must be in the future\")\n+\t} else if start.After(stop) {","path":"cmd/snapctl/task.go","position":23,"original_position":9,"commit_id":"a9083794b2093bec4ef70c5ee1b02174115687be","original_commit_id":"a9083794b2093bec4ef70c5ee1b02174115687be","user":{"login":"geauxvirtual","id":1395030,"avatar_url":"https://avatars.githubusercontent.com/u/1395030?v=3","gravatar_id":"","url":"https://api.github.com/users/geauxvirtual","html_url":"https://github.com/geauxvirtual","followers_url":"https://api.github.com/users/geauxvirtual/followers","following_url":"https://api.github.com/users/geauxvirtual/following{/other_user}","gists_url":"https://api.github.com/users/geauxvirtual/gists{/gist_id}","starred_url":"https://api.github.com/users/geauxvirtual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geauxvirtual/subscriptions","organizations_url":"https://api.github.com/users/geauxvirtual/orgs","repos_url":"https://api.github.com/users/geauxvirtual/repos","events_url":"https://api.github.com/users/geauxvirtual/events{/privacy}","received_events_url":"https://api.github.com/users/geauxvirtual/received_events","type":"User","site_admin":false},"body":"I would remove the `else if` and just `if` as each statement will return from the function with an error if the `if` statement is true.","created_at":"2016-08-05T21:14:38Z","updated_at":"2016-08-05T21:14:38Z","html_url":"https://github.com/intelsdi-x/snap/pull/1127#discussion_r73760476","pull_request_url":"https://api.github.com/repos/intelsdi-x/snap/pulls/1127","_links":{"self":{"href":"https://api.github.com/repos/intelsdi-x/snap/pulls/comments/73760476"},"html":{"href":"https://github.com/intelsdi-x/snap/pull/1127#discussion_r73760476"},"pull_request":{"href":"https://api.github.com/repos/intelsdi-x/snap/pulls/1127"}}},"pull_request":{"url":"https://api.github.com/repos/intelsdi-x/snap/pulls/1127","id":80299746,"html_url":"https://github.com/intelsdi-x/snap/pull/1127","diff_url":"https://github.com/intelsdi-x/snap/pull/1127.diff","patch_url":"https://github.com/intelsdi-x/snap/pull/1127.patch","issue_url":"https://api.github.com/repos/intelsdi-x/snap/issues/1127","number":1127,"state":"open","locked":false,"title":"Fixes #1113 and Resolves #1126; improves task creation process in `snapctl`","user":{"login":"tjmcs","id":1375734,"avatar_url":"https://avatars.githubusercontent.com/u/1375734?v=3","gravatar_id":"","url":"https://api.github.com/users/tjmcs","html_url":"https://github.com/tjmcs","followers_url":"https://api.github.com/users/tjmcs/followers","following_url":"https://api.github.com/users/tjmcs/following{/other_user}","gists_url":"https://api.github.com/users/tjmcs/gists{/gist_id}","starred_url":"https://api.github.com/users/tjmcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjmcs/subscriptions","organizations_url":"https://api.github.com/users/tjmcs/orgs","repos_url":"https://api.github.com/users/tjmcs/repos","events_url":"https://api.github.com/users/tjmcs/events{/privacy}","received_events_url":"https://api.github.com/users/tjmcs/received_events","type":"User","site_admin":false},"body":"Fixes #1113 \r\nResolves #1126\r\n\r\n**Summary of changes**\r\n\r\nThere are two sets of changes in this pull request. The first, which fix Issue #1113 are fairly simple and don't change the behavior of the system at all. They can be summarized as follows:\r\n- Removed a line of code from the `core/task.go` file that used to set the `max-failure` value to `10` for all tasks, replacing it with a conditional that set the underlying option only in those cases where a `MaxFailures` value was included as part of the task creation request.\r\n- Modified the `scheduler/task.go` file so that the value of the `DefaultStopOnFailure` constant defined in that file is set to `10` (making it consistent with the behavior that used to be defined elsewhere but was inconsistently set to a value of `3` in this file)\r\n- Removed the definitions of a similar constant (the `DefaultMaxFailures` constant) from the `cmd/snapctl/flags.go` and `mgmt/rest/flags.go` files\r\n- Modified the command-line flag used to set the `max-failures` parameter so that it is a string flag rather than an integer flag and added code to parse this string value as an integer (and throw an error if the value passed in through this command-line flag cannot be parsed as an integer). This removes the string `(default: 0)` from the help output for the `snapctl task create ...` command.\r\n\r\nThe second set of changes were made to resolve Issue #1126. This set of changes *does* modify the behavior of the system, changing the `snapctl` command so that it honors any command-line flags that the user might have set, regardless of whether the user is creating a task using a task manifest or a workflow manifest. In the case where the user is creating a task using a task manifest and has included (new) definitions for parameters in appear that task manifest as command-line arguments, those command-line argument values will take precedence over the values defined in the task manifest. The changes in this second commit can best be summarized as follows:\r\n- Added methods to the `task` interface that can be used to parse any command-line parameters that might have been set by the user so that those command-line parameter values can be used when creating a new task. In the case where a workflow manifest is being used, those values will be used to set the necessary values for the underlying task. When a task manifest is being used those values will override the corresponding values from the task manifest file.\r\n- Added code to check the boundaries of a `windowed` task schedule (if one is defined in the task manifest and/or on the command-line) to ensure that the time window defined is valid.\r\n- Modified the functions used to create a task using either a task manifest or a workflow manifest so that they both call into our new methods to apply the command-line parameters defined by the user when creating the task.\r\n\r\n**Note**; this pull request is a replacement for PR #1120, which fixed and resolved the same issues but in a single commit. This PR breaks out the fix into two separate commits, making it much clearer what is being changed and how.\r\n\r\n**Testing done**\r\n\r\nTested the first set of changes manually by running two tests using two different task manifests:\r\n- For the first test, created a task using a task manifest that had an undefined value for the `max-failures` parameter, then unloading the collector plugin(s) that the task depended on and ensuring that the task was disabled after `10` failures (the default)\r\n- For the second test, created a task using a task manifest that had a value set for the `max-failures` parameter (the value we chose was `3`, but any value greater than zero would do for this test), then unloading the collector plugin(s) that the task depended on and ensuring that the task was disabled after the chosen number of failures (in our case, `3`).\r\n\r\nThe second set of changes were also tested manually by running a single test:\r\n- A task was created using the second a task manifest from our previous tests (which assigned a value of `3` to the `max-failures` parameter and a value of `1s` for the `interval`), but passing in different values on the command-line for these two parameters (we chose values of `5` and `750ms`, respectively, for our test).\r\n- For this test, we first ensured that our task was running at a shorter interval than the interval defined in the task manifest (it was, with the interval between task runs matching the `750ms` value passed in on the command line; four times every three seconds or 80 times a minute).\r\n- We then unloaded the collector plugin(s) that the task depended on, and verified that the task was disabled after `5` failures rather than `3`.\r\n\r\nFinally, the current set of legacy tests was run to ensure that we hadn't changed the behavior of the system from the previous behavior, we'd only added the ability to override some of the parameters defined in the task manifest using values defined on the command-line.\r\n\r\n@intelsdi-x/snap-maintainers\r\n","created_at":"2016-08-05T20:07:33Z","updated_at":"2016-08-05T21:14:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fad7945de87e035b8a7ce570788077419156b834","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/intelsdi-x/snap/pulls/1127/commits","review_comments_url":"https://api.github.com/repos/intelsdi-x/snap/pulls/1127/comments","review_comment_url":"https://api.github.com/repos/intelsdi-x/snap/pulls/comments{/number}","comments_url":"https://api.github.com/repos/intelsdi-x/snap/issues/1127/comments","statuses_url":"https://api.github.com/repos/intelsdi-x/snap/statuses/a9083794b2093bec4ef70c5ee1b02174115687be","head":{"label":"tjmcs:tb/fix-task-create-and-disable","ref":"tb/fix-task-create-and-disable","sha":"a9083794b2093bec4ef70c5ee1b02174115687be","user":{"login":"tjmcs","id":1375734,"avatar_url":"https://avatars.githubusercontent.com/u/1375734?v=3","gravatar_id":"","url":"https://api.github.com/users/tjmcs","html_url":"https://github.com/tjmcs","followers_url":"https://api.github.com/users/tjmcs/followers","following_url":"https://api.github.com/users/tjmcs/following{/other_user}","gists_url":"https://api.github.com/users/tjmcs/gists{/gist_id}","starred_url":"https://api.github.com/users/tjmcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjmcs/subscriptions","organizations_url":"https://api.github.com/users/tjmcs/orgs","repos_url":"https://api.github.com/users/tjmcs/repos","events_url":"https://api.github.com/users/tjmcs/events{/privacy}","received_events_url":"https://api.github.com/users/tjmcs/received_events","type":"User","site_admin":false},"repo":{"id":52919144,"name":"snap","full_name":"tjmcs/snap","owner":{"login":"tjmcs","id":1375734,"avatar_url":"https://avatars.githubusercontent.com/u/1375734?v=3","gravatar_id":"","url":"https://api.github.com/users/tjmcs","html_url":"https://github.com/tjmcs","followers_url":"https://api.github.com/users/tjmcs/followers","following_url":"https://api.github.com/users/tjmcs/following{/other_user}","gists_url":"https://api.github.com/users/tjmcs/gists{/gist_id}","starred_url":"https://api.github.com/users/tjmcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjmcs/subscriptions","organizations_url":"https://api.github.com/users/tjmcs/orgs","repos_url":"https://api.github.com/users/tjmcs/repos","events_url":"https://api.github.com/users/tjmcs/events{/privacy}","received_events_url":"https://api.github.com/users/tjmcs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tjmcs/snap","description":"A powerful telemetry framework","fork":true,"url":"https://api.github.com/repos/tjmcs/snap","forks_url":"https://api.github.com/repos/tjmcs/snap/forks","keys_url":"https://api.github.com/repos/tjmcs/snap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tjmcs/snap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tjmcs/snap/teams","hooks_url":"https://api.github.com/repos/tjmcs/snap/hooks","issue_events_url":"https://api.github.com/repos/tjmcs/snap/issues/events{/number}","events_url":"https://api.github.com/repos/tjmcs/snap/events","assignees_url":"https://api.github.com/repos/tjmcs/snap/assignees{/user}","branches_url":"https://api.github.com/repos/tjmcs/snap/branches{/branch}","tags_url":"https://api.github.com/repos/tjmcs/snap/tags","blobs_url":"https://api.github.com/repos/tjmcs/snap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tjmcs/snap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tjmcs/snap/git/refs{/sha}","trees_url":"https://api.github.com/repos/tjmcs/snap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tjmcs/snap/statuses/{sha}","languages_url":"https://api.github.com/repos/tjmcs/snap/languages","stargazers_url":"https://api.github.com/repos/tjmcs/snap/stargazers","contributors_url":"https://api.github.com/repos/tjmcs/snap/contributors","subscribers_url":"https://api.github.com/repos/tjmcs/snap/subscribers","subscription_url":"https://api.github.com/repos/tjmcs/snap/subscription","commits_url":"https://api.github.com/repos/tjmcs/snap/commits{/sha}","git_commits_url":"https://api.github.com/repos/tjmcs/snap/git/commits{/sha}","comments_url":"https://api.github.com/repos/tjmcs/snap/comments{/number}","issue_comment_url":"https://api.github.com/repos/tjmcs/snap/issues/comments{/number}","contents_url":"https://api.github.com/repos/tjmcs/snap/contents/{+path}","compare_url":"https://api.github.com/repos/tjmcs/snap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tjmcs/snap/merges","archive_url":"https://api.github.com/repos/tjmcs/snap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tjmcs/snap/downloads","issues_url":"https://api.github.com/repos/tjmcs/snap/issues{/number}","pulls_url":"https://api.github.com/repos/tjmcs/snap/pulls{/number}","milestones_url":"https://api.github.com/repos/tjmcs/snap/milestones{/number}","notifications_url":"https://api.github.com/repos/tjmcs/snap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tjmcs/snap/labels{/name}","releases_url":"https://api.github.com/repos/tjmcs/snap/releases{/id}","deployments_url":"https://api.github.com/repos/tjmcs/snap/deployments","created_at":"2016-03-01T23:52:27Z","updated_at":"2016-03-01T23:52:29Z","pushed_at":"2016-08-05T19:27:58Z","git_url":"git://github.com/tjmcs/snap.git","ssh_url":"git@github.com:tjmcs/snap.git","clone_url":"https://github.com/tjmcs/snap.git","svn_url":"https://github.com/tjmcs/snap","homepage":"http://github.com/intelsdi-x/snap","size":10567,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"intelsdi-x:master","ref":"master","sha":"6309bcdd4a8f5702bb5dc2694bd0e44484dca731","user":{"login":"intelsdi-x","id":8398747,"avatar_url":"https://avatars.githubusercontent.com/u/8398747?v=3","gravatar_id":"","url":"https://api.github.com/users/intelsdi-x","html_url":"https://github.com/intelsdi-x","followers_url":"https://api.github.com/users/intelsdi-x/followers","following_url":"https://api.github.com/users/intelsdi-x/following{/other_user}","gists_url":"https://api.github.com/users/intelsdi-x/gists{/gist_id}","starred_url":"https://api.github.com/users/intelsdi-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intelsdi-x/subscriptions","organizations_url":"https://api.github.com/users/intelsdi-x/orgs","repos_url":"https://api.github.com/users/intelsdi-x/repos","events_url":"https://api.github.com/users/intelsdi-x/events{/privacy}","received_events_url":"https://api.github.com/users/intelsdi-x/received_events","type":"Organization","site_admin":false},"repo":{"id":22931257,"name":"snap","full_name":"intelsdi-x/snap","owner":{"login":"intelsdi-x","id":8398747,"avatar_url":"https://avatars.githubusercontent.com/u/8398747?v=3","gravatar_id":"","url":"https://api.github.com/users/intelsdi-x","html_url":"https://github.com/intelsdi-x","followers_url":"https://api.github.com/users/intelsdi-x/followers","following_url":"https://api.github.com/users/intelsdi-x/following{/other_user}","gists_url":"https://api.github.com/users/intelsdi-x/gists{/gist_id}","starred_url":"https://api.github.com/users/intelsdi-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intelsdi-x/subscriptions","organizations_url":"https://api.github.com/users/intelsdi-x/orgs","repos_url":"https://api.github.com/users/intelsdi-x/repos","events_url":"https://api.github.com/users/intelsdi-x/events{/privacy}","received_events_url":"https://api.github.com/users/intelsdi-x/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intelsdi-x/snap","description":"The open telemetry framework","fork":false,"url":"https://api.github.com/repos/intelsdi-x/snap","forks_url":"https://api.github.com/repos/intelsdi-x/snap/forks","keys_url":"https://api.github.com/repos/intelsdi-x/snap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intelsdi-x/snap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intelsdi-x/snap/teams","hooks_url":"https://api.github.com/repos/intelsdi-x/snap/hooks","issue_events_url":"https://api.github.com/repos/intelsdi-x/snap/issues/events{/number}","events_url":"https://api.github.com/repos/intelsdi-x/snap/events","assignees_url":"https://api.github.com/repos/intelsdi-x/snap/assignees{/user}","branches_url":"https://api.github.com/repos/intelsdi-x/snap/branches{/branch}","tags_url":"https://api.github.com/repos/intelsdi-x/snap/tags","blobs_url":"https://api.github.com/repos/intelsdi-x/snap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intelsdi-x/snap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intelsdi-x/snap/git/refs{/sha}","trees_url":"https://api.github.com/repos/intelsdi-x/snap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intelsdi-x/snap/statuses/{sha}","languages_url":"https://api.github.com/repos/intelsdi-x/snap/languages","stargazers_url":"https://api.github.com/repos/intelsdi-x/snap/stargazers","contributors_url":"https://api.github.com/repos/intelsdi-x/snap/contributors","subscribers_url":"https://api.github.com/repos/intelsdi-x/snap/subscribers","subscription_url":"https://api.github.com/repos/intelsdi-x/snap/subscription","commits_url":"https://api.github.com/repos/intelsdi-x/snap/commits{/sha}","git_commits_url":"https://api.github.com/repos/intelsdi-x/snap/git/commits{/sha}","comments_url":"https://api.github.com/repos/intelsdi-x/snap/comments{/number}","issue_comment_url":"https://api.github.com/repos/intelsdi-x/snap/issues/comments{/number}","contents_url":"https://api.github.com/repos/intelsdi-x/snap/contents/{+path}","compare_url":"https://api.github.com/repos/intelsdi-x/snap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intelsdi-x/snap/merges","archive_url":"https://api.github.com/repos/intelsdi-x/snap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intelsdi-x/snap/downloads","issues_url":"https://api.github.com/repos/intelsdi-x/snap/issues{/number}","pulls_url":"https://api.github.com/repos/intelsdi-x/snap/pulls{/number}","milestones_url":"https://api.github.com/repos/intelsdi-x/snap/milestones{/number}","notifications_url":"https://api.github.com/repos/intelsdi-x/snap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intelsdi-x/snap/labels{/name}","releases_url":"https://api.github.com/repos/intelsdi-x/snap/releases{/id}","deployments_url":"https://api.github.com/repos/intelsdi-x/snap/deployments","created_at":"2014-08-13T21:04:51Z","updated_at":"2016-08-05T11:44:47Z","pushed_at":"2016-08-05T20:07:34Z","git_url":"git://github.com/intelsdi-x/snap.git","ssh_url":"git@github.com:intelsdi-x/snap.git","clone_url":"https://github.com/intelsdi-x/snap.git","svn_url":"https://github.com/intelsdi-x/snap","homepage":"http://snap-telemetry.io","size":25202,"stargazers_count":883,"watchers_count":883,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":122,"mirror_url":null,"open_issues_count":119,"forks":122,"open_issues":119,"watchers":883,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/intelsdi-x/snap/pulls/1127"},"html":{"href":"https://github.com/intelsdi-x/snap/pull/1127"},"issue":{"href":"https://api.github.com/repos/intelsdi-x/snap/issues/1127"},"comments":{"href":"https://api.github.com/repos/intelsdi-x/snap/issues/1127/comments"},"review_comments":{"href":"https://api.github.com/repos/intelsdi-x/snap/pulls/1127/comments"},"review_comment":{"href":"https://api.github.com/repos/intelsdi-x/snap/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/intelsdi-x/snap/pulls/1127/commits"},"statuses":{"href":"https://api.github.com/repos/intelsdi-x/snap/statuses/a9083794b2093bec4ef70c5ee1b02174115687be"}}}}
{"actor":{"display_login":"geauxvirtual"}}