{"action":"created","comment":{"url":"https://api.github.com/repos/hashicorp/nomad/pulls/comments/174970948","pull_request_review_id":104416341,"id":174970948,"diff_hunk":"@@ -73,43 +83,149 @@ func (fm *FingerprintManager) setupDrivers(drivers []string) error {\n \t\t\treturn err\n \t\t}\n \n-\t\tdetected, err := fm.fingerprint(name, d)\n+\t\tdetected, err := fm.fingerprintDriver(name, d)\n \t\tif err != nil {\n \t\t\tfm.logger.Printf(\"[DEBUG] client.fingerprint_manager: fingerprinting for %v failed: %+v\", name, err)\n \t\t\treturn err\n \t\t}\n \n+\t\tif hc, ok := d.(fingerprint.HealthCheck); ok {\n+\t\t\tfm.runHealthCheck(name, hc)\n+\t\t} else {\n+\t\t\t// for drivers which are not of type health check, update them to have their\n+\t\t\t// health status match the status of whether they are detected or not.\n+\t\t\thealthInfo := &structs.DriverInfo{\n+\t\t\t\tHealthy:    detected,\n+\t\t\t\tUpdateTime: time.Now(),\n+\t\t\t}\n+\t\t\tif node := fm.updateNodeFromDriver(name, nil, healthInfo); node != nil {\n+\t\t\t\tfm.nodeLock.Lock()\n+\t\t\t\tfm.node = node\n+\t\t\t\tfm.nodeLock.Unlock()\n+\t\t\t}\n+\t\t}\n+\n+\t\tgo fm.watchDriver(d, name)\n+\n \t\t// log the fingerprinters which have been applied\n \t\tif detected {\n \t\t\tavailDrivers = append(availDrivers, name)\n \t\t}\n-\n-\t\tp, period := d.Periodic()\n-\t\tif p {\n-\t\t\tgo fm.run(d, period, name)\n-\t\t}\n \t}\n \n \tfm.logger.Printf(\"[DEBUG] client.fingerprint_manager: detected drivers %v\", availDrivers)\n \treturn nil\n }\n \n+// watchDrivers facilitates the different periods between fingerprint and\n+// health checking a driver\n+func (fm *FingerprintManager) watchDriver(d driver.Driver, name string) {\n+\t_, fingerprintPeriod := d.Periodic()\n+\tfm.logger.Printf(\"[DEBUG] client.fingerprint_manager: fingerprinting driver %s every %v\", name, fingerprintPeriod)\n+\n+\tvar healthCheckPeriod time.Duration\n+\thc, isHealthCheck := d.(fingerprint.HealthCheck)\n+\tif isHealthCheck {\n+\t\treq := &cstructs.HealthCheckIntervalRequest{}\n+\t\tvar resp cstructs.HealthCheckIntervalResponse\n+\t\thc.GetHealthCheckInterval(req, &resp)\n+\t\tif resp.Eligible {\n+\t\t\tfm.logger.Printf(\"[DEBUG] client.fingerprint_manager: health checking driver %s every %v\", name, healthCheckPeriod)\n+\t\t\thealthCheckPeriod = resp.Period\n+\t\t}\n+\t}\n+\n+\tt1 := time.NewTimer(fingerprintPeriod)\n+\tdefer t1.Stop()\n+\tt2 := time.NewTimer(healthCheckPeriod)\n+\tdefer t2.Stop()\n+\n+\tfor {\n+\t\tselect {\n+\t\tcase <-fm.shutdownCh:\n+\t\t\treturn\n+\t\tcase <-t1.C:\n+\t\t\tt1.Reset(fingerprintPeriod)\n+\t\t\t_, err := fm.fingerprintDriver(name, d)\n+\t\t\tif err != nil {\n+\t\t\t\tfm.logger.Printf(\"[DEBUG] client.fingerprint_manager: periodic fingerprinting for driver %v failed: %+v\", name, err)\n+\t\t\t}\n+\t\tcase <-t2.C:\n+\t\t\tif isHealthCheck {","path":"client/fingerprint_manager.go","position":143,"original_position":143,"commit_id":"244389cf06cbd9e5e19f590828e3057e23d20a2c","original_commit_id":"244389cf06cbd9e5e19f590828e3057e23d20a2c","user":{"login":"dadgar","id":1047914,"avatar_url":"https://avatars0.githubusercontent.com/u/1047914?v=4","gravatar_id":"","url":"https://api.github.com/users/dadgar","html_url":"https://github.com/dadgar","followers_url":"https://api.github.com/users/dadgar/followers","following_url":"https://api.github.com/users/dadgar/following{/other_user}","gists_url":"https://api.github.com/users/dadgar/gists{/gist_id}","starred_url":"https://api.github.com/users/dadgar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dadgar/subscriptions","organizations_url":"https://api.github.com/users/dadgar/orgs","repos_url":"https://api.github.com/users/dadgar/repos","events_url":"https://api.github.com/users/dadgar/events{/privacy}","received_events_url":"https://api.github.com/users/dadgar/received_events","type":"User","site_admin":false},"body":"I feel like we shouldn't run the health check if detected isn't true. Otherwise you will log errors continuously, right?\r\n\r\nI think you also skip the initial health check here and just rely on this loop: https://github.com/hashicorp/nomad/pull/3856/files#diff-8cf4b6aaa496508270af1cd14fdc1527R92","created_at":"2018-03-16T00:28:49Z","updated_at":"2018-03-16T00:29:43Z","html_url":"https://github.com/hashicorp/nomad/pull/3856#discussion_r174970948","pull_request_url":"https://api.github.com/repos/hashicorp/nomad/pulls/3856","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/hashicorp/nomad/pulls/comments/174970948"},"html":{"href":"https://github.com/hashicorp/nomad/pull/3856#discussion_r174970948"},"pull_request":{"href":"https://api.github.com/repos/hashicorp/nomad/pulls/3856"}}},"pull_request":{"url":"https://api.github.com/repos/hashicorp/nomad/pulls/3856","id":168078427,"html_url":"https://github.com/hashicorp/nomad/pull/3856","diff_url":"https://github.com/hashicorp/nomad/pull/3856.diff","patch_url":"https://github.com/hashicorp/nomad/pull/3856.patch","issue_url":"https://api.github.com/repos/hashicorp/nomad/issues/3856","number":3856,"state":"open","locked":false,"title":"Client driver health checks for Docker","user":{"login":"chelseakomlo","id":2530163,"avatar_url":"https://avatars2.githubusercontent.com/u/2530163?v=4","gravatar_id":"","url":"https://api.github.com/users/chelseakomlo","html_url":"https://github.com/chelseakomlo","followers_url":"https://api.github.com/users/chelseakomlo/followers","following_url":"https://api.github.com/users/chelseakomlo/following{/other_user}","gists_url":"https://api.github.com/users/chelseakomlo/gists{/gist_id}","starred_url":"https://api.github.com/users/chelseakomlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chelseakomlo/subscriptions","organizations_url":"https://api.github.com/users/chelseakomlo/orgs","repos_url":"https://api.github.com/users/chelseakomlo/repos","events_url":"https://api.github.com/users/chelseakomlo/events{/privacy}","received_events_url":"https://api.github.com/users/chelseakomlo/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-08T20:27:27Z","updated_at":"2018-03-16T00:29:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ec2f1b9903a25f6d06e6ef26d465909c44d02a0a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hashicorp/nomad/pulls/3856/commits","review_comments_url":"https://api.github.com/repos/hashicorp/nomad/pulls/3856/comments","review_comment_url":"https://api.github.com/repos/hashicorp/nomad/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hashicorp/nomad/issues/3856/comments","statuses_url":"https://api.github.com/repos/hashicorp/nomad/statuses/244389cf06cbd9e5e19f590828e3057e23d20a2c","head":{"label":"hashicorp:f-client-add-health-checks","ref":"f-client-add-health-checks","sha":"244389cf06cbd9e5e19f590828e3057e23d20a2c","user":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars2.githubusercontent.com/u/761456?v=4","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"repo":{"id":36653430,"name":"nomad","full_name":"hashicorp/nomad","owner":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars2.githubusercontent.com/u/761456?v=4","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hashicorp/nomad","description":"Nomad is a flexible, enterprise-grade cluster scheduler designed to easily integrate into existing workflows. Nomad can run a diverse workload of micro-service, batch, containerized and non-containerized applications. Nomad is easy to operate and scale and integrates seamlessly with Consul and Vault.","fork":false,"url":"https://api.github.com/repos/hashicorp/nomad","forks_url":"https://api.github.com/repos/hashicorp/nomad/forks","keys_url":"https://api.github.com/repos/hashicorp/nomad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hashicorp/nomad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hashicorp/nomad/teams","hooks_url":"https://api.github.com/repos/hashicorp/nomad/hooks","issue_events_url":"https://api.github.com/repos/hashicorp/nomad/issues/events{/number}","events_url":"https://api.github.com/repos/hashicorp/nomad/events","assignees_url":"https://api.github.com/repos/hashicorp/nomad/assignees{/user}","branches_url":"https://api.github.com/repos/hashicorp/nomad/branches{/branch}","tags_url":"https://api.github.com/repos/hashicorp/nomad/tags","blobs_url":"https://api.github.com/repos/hashicorp/nomad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hashicorp/nomad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hashicorp/nomad/git/refs{/sha}","trees_url":"https://api.github.com/repos/hashicorp/nomad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hashicorp/nomad/statuses/{sha}","languages_url":"https://api.github.com/repos/hashicorp/nomad/languages","stargazers_url":"https://api.github.com/repos/hashicorp/nomad/stargazers","contributors_url":"https://api.github.com/repos/hashicorp/nomad/contributors","subscribers_url":"https://api.github.com/repos/hashicorp/nomad/subscribers","subscription_url":"https://api.github.com/repos/hashicorp/nomad/subscription","commits_url":"https://api.github.com/repos/hashicorp/nomad/commits{/sha}","git_commits_url":"https://api.github.com/repos/hashicorp/nomad/git/commits{/sha}","comments_url":"https://api.github.com/repos/hashicorp/nomad/comments{/number}","issue_comment_url":"https://api.github.com/repos/hashicorp/nomad/issues/comments{/number}","contents_url":"https://api.github.com/repos/hashicorp/nomad/contents/{+path}","compare_url":"https://api.github.com/repos/hashicorp/nomad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hashicorp/nomad/merges","archive_url":"https://api.github.com/repos/hashicorp/nomad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hashicorp/nomad/downloads","issues_url":"https://api.github.com/repos/hashicorp/nomad/issues{/number}","pulls_url":"https://api.github.com/repos/hashicorp/nomad/pulls{/number}","milestones_url":"https://api.github.com/repos/hashicorp/nomad/milestones{/number}","notifications_url":"https://api.github.com/repos/hashicorp/nomad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hashicorp/nomad/labels{/name}","releases_url":"https://api.github.com/repos/hashicorp/nomad/releases{/id}","deployments_url":"https://api.github.com/repos/hashicorp/nomad/deployments","created_at":"2015-06-01T10:21:00Z","updated_at":"2018-03-15T21:04:29Z","pushed_at":"2018-03-15T22:34:10Z","git_url":"git://github.com/hashicorp/nomad.git","ssh_url":"git@github.com:hashicorp/nomad.git","clone_url":"https://github.com/hashicorp/nomad.git","svn_url":"https://github.com/hashicorp/nomad","homepage":"https://www.nomadproject.io/","size":94561,"stargazers_count":3337,"watchers_count":3337,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":650,"mirror_url":null,"archived":false,"open_issues_count":348,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":650,"open_issues":348,"watchers":3337,"default_branch":"master"}},"base":{"label":"hashicorp:master","ref":"master","sha":"0cc4e3caf0c696c8eb44790ca26fdf45d18d10bf","user":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars2.githubusercontent.com/u/761456?v=4","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"repo":{"id":36653430,"name":"nomad","full_name":"hashicorp/nomad","owner":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars2.githubusercontent.com/u/761456?v=4","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hashicorp/nomad","description":"Nomad is a flexible, enterprise-grade cluster scheduler designed to easily integrate into existing workflows. Nomad can run a diverse workload of micro-service, batch, containerized and non-containerized applications. Nomad is easy to operate and scale and integrates seamlessly with Consul and Vault.","fork":false,"url":"https://api.github.com/repos/hashicorp/nomad","forks_url":"https://api.github.com/repos/hashicorp/nomad/forks","keys_url":"https://api.github.com/repos/hashicorp/nomad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hashicorp/nomad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hashicorp/nomad/teams","hooks_url":"https://api.github.com/repos/hashicorp/nomad/hooks","issue_events_url":"https://api.github.com/repos/hashicorp/nomad/issues/events{/number}","events_url":"https://api.github.com/repos/hashicorp/nomad/events","assignees_url":"https://api.github.com/repos/hashicorp/nomad/assignees{/user}","branches_url":"https://api.github.com/repos/hashicorp/nomad/branches{/branch}","tags_url":"https://api.github.com/repos/hashicorp/nomad/tags","blobs_url":"https://api.github.com/repos/hashicorp/nomad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hashicorp/nomad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hashicorp/nomad/git/refs{/sha}","trees_url":"https://api.github.com/repos/hashicorp/nomad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hashicorp/nomad/statuses/{sha}","languages_url":"https://api.github.com/repos/hashicorp/nomad/languages","stargazers_url":"https://api.github.com/repos/hashicorp/nomad/stargazers","contributors_url":"https://api.github.com/repos/hashicorp/nomad/contributors","subscribers_url":"https://api.github.com/repos/hashicorp/nomad/subscribers","subscription_url":"https://api.github.com/repos/hashicorp/nomad/subscription","commits_url":"https://api.github.com/repos/hashicorp/nomad/commits{/sha}","git_commits_url":"https://api.github.com/repos/hashicorp/nomad/git/commits{/sha}","comments_url":"https://api.github.com/repos/hashicorp/nomad/comments{/number}","issue_comment_url":"https://api.github.com/repos/hashicorp/nomad/issues/comments{/number}","contents_url":"https://api.github.com/repos/hashicorp/nomad/contents/{+path}","compare_url":"https://api.github.com/repos/hashicorp/nomad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hashicorp/nomad/merges","archive_url":"https://api.github.com/repos/hashicorp/nomad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hashicorp/nomad/downloads","issues_url":"https://api.github.com/repos/hashicorp/nomad/issues{/number}","pulls_url":"https://api.github.com/repos/hashicorp/nomad/pulls{/number}","milestones_url":"https://api.github.com/repos/hashicorp/nomad/milestones{/number}","notifications_url":"https://api.github.com/repos/hashicorp/nomad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hashicorp/nomad/labels{/name}","releases_url":"https://api.github.com/repos/hashicorp/nomad/releases{/id}","deployments_url":"https://api.github.com/repos/hashicorp/nomad/deployments","created_at":"2015-06-01T10:21:00Z","updated_at":"2018-03-15T21:04:29Z","pushed_at":"2018-03-15T22:34:10Z","git_url":"git://github.com/hashicorp/nomad.git","ssh_url":"git@github.com:hashicorp/nomad.git","clone_url":"https://github.com/hashicorp/nomad.git","svn_url":"https://github.com/hashicorp/nomad","homepage":"https://www.nomadproject.io/","size":94561,"stargazers_count":3337,"watchers_count":3337,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":650,"mirror_url":null,"archived":false,"open_issues_count":348,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":650,"open_issues":348,"watchers":3337,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hashicorp/nomad/pulls/3856"},"html":{"href":"https://github.com/hashicorp/nomad/pull/3856"},"issue":{"href":"https://api.github.com/repos/hashicorp/nomad/issues/3856"},"comments":{"href":"https://api.github.com/repos/hashicorp/nomad/issues/3856/comments"},"review_comments":{"href":"https://api.github.com/repos/hashicorp/nomad/pulls/3856/comments"},"review_comment":{"href":"https://api.github.com/repos/hashicorp/nomad/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hashicorp/nomad/pulls/3856/commits"},"statuses":{"href":"https://api.github.com/repos/hashicorp/nomad/statuses/244389cf06cbd9e5e19f590828e3057e23d20a2c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dadgar"}}