{"action":"created","comment":{"url":"https://api.github.com/repos/snapcore/snapd/pulls/comments/222273665","pull_request_review_id":161117918,"id":222273665,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjI3MzY2NQ==","diff_hunk":"@@ -20,9 +20,47 @@\n package ifacestate\n \n import (\n+\t\"strings\"\n+\n \t\"github.com/snapcore/snapd/interfaces/hotplug\"\n )\n \n+// List of attributes that determine the computation of default device key.\n+// Attributes are grouped by similarity, the first non-empty attribute within the group goes into the key.\n+// The final key is composed of 4 attributes (some of which may be empty), separated by \"/\".\n+var attrGroups = [][]string{\n+\t// Name\n+\t{\"ID_V4L_PRODUCT\", \"NAME\", \"ID_NET_NAME\", \"PCI_SLOT_NAME\"},\n+\t// Vendor\n+\t{\"ID_VENDOR_ID\", \"ID_VENDOR\", \"ID_WWN\", \"ID_WWN_WITH_EXTENSION\", \"ID_VENDOR_FROM_DATABASE\", \"ID_VENDOR_ENC\", \"ID_OUI_FROM_DATABASE\"},\n+\t// Model\n+\t{\"ID_MODEL_ID\", \"ID_MODEL_ENC\"},\n+\t// Identifier\n+\t{\"ID_SERIAL\", \"ID_SERIAL_SHORT\", \"ID_NET_NAME_MAC\", \"ID_REVISION\"},\n+}\n+\n+// defaultDeviceKey computes device key from the attributes of\n+// HotplugDeviceInfo. Empty string is returned if too few attributes are present\n+// to compute a good key. Attributes used to compute device key are defined in\n+// attrGroups list above.\n+func defaultDeviceKey(devinfo *hotplug.HotplugDeviceInfo) string {","path":"overlord/ifacestate/hotplug.go","position":null,"original_position":27,"commit_id":"59139790ec30b85574f96c3ca847508cf5ce66cb","original_commit_id":"cf65367ea27db319fc2f95c7de5ec926fa26646f","user":{"login":"stolowski","id":168604,"node_id":"MDQ6VXNlcjE2ODYwNA==","avatar_url":"https://avatars0.githubusercontent.com/u/168604?v=4","gravatar_id":"","url":"https://api.github.com/users/stolowski","html_url":"https://github.com/stolowski","followers_url":"https://api.github.com/users/stolowski/followers","following_url":"https://api.github.com/users/stolowski/following{/other_user}","gists_url":"https://api.github.com/users/stolowski/gists{/gist_id}","starred_url":"https://api.github.com/users/stolowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stolowski/subscriptions","organizations_url":"https://api.github.com/users/stolowski/orgs","repos_url":"https://api.github.com/users/stolowski/repos","events_url":"https://api.github.com/users/stolowski/events{/privacy}","received_events_url":"https://api.github.com/users/stolowski/received_events","type":"User","site_admin":false},"body":"I agree, versioning makes sense. Also, +1 for using null instead of \"/\" as a separator, it could potentially lead to collisions indeed. I also changed the implementation to use sha checksums, the only downside of this that I see is it makes keys completely opaque, which makes debugging slightly harder.\r\n\r\nOne general and obvious issue I see is with reverts to old versions while new keys are in use in the state - we will not match affected devices.","created_at":"2018-10-03T11:28:23Z","updated_at":"2018-10-03T11:28:23Z","html_url":"https://github.com/snapcore/snapd/pull/5759#discussion_r222273665","pull_request_url":"https://api.github.com/repos/snapcore/snapd/pulls/5759","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/comments/222273665"},"html":{"href":"https://github.com/snapcore/snapd/pull/5759#discussion_r222273665"},"pull_request":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/5759"}},"in_reply_to_id":221558586},"pull_request":{"url":"https://api.github.com/repos/snapcore/snapd/pulls/5759","id":212930886,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyOTMwODg2","html_url":"https://github.com/snapcore/snapd/pull/5759","diff_url":"https://github.com/snapcore/snapd/pull/5759.diff","patch_url":"https://github.com/snapcore/snapd/pull/5759.patch","issue_url":"https://api.github.com/repos/snapcore/snapd/issues/5759","number":5759,"state":"open","locked":false,"title":"ifacestate: implementation of defaultDeviceKey function for hotplug","user":{"login":"stolowski","id":168604,"node_id":"MDQ6VXNlcjE2ODYwNA==","avatar_url":"https://avatars0.githubusercontent.com/u/168604?v=4","gravatar_id":"","url":"https://api.github.com/users/stolowski","html_url":"https://github.com/stolowski","followers_url":"https://api.github.com/users/stolowski/followers","following_url":"https://api.github.com/users/stolowski/following{/other_user}","gists_url":"https://api.github.com/users/stolowski/gists{/gist_id}","starred_url":"https://api.github.com/users/stolowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stolowski/subscriptions","organizations_url":"https://api.github.com/users/stolowski/orgs","repos_url":"https://api.github.com/users/stolowski/repos","events_url":"https://api.github.com/users/stolowski/events{/privacy}","received_events_url":"https://api.github.com/users/stolowski/received_events","type":"User","site_admin":false},"body":"Implementation of the `defaultDeviceKey` helper for hotplug. This function tries to compute a unique key from attributes reported by udev event (many of which may be missing). The goal is to have a key that's _unique for given interface type_. \r\nImplementations of interfaces that implement hotplug will have a way to override default key and provide own function to compute the key if they want to (e.g. if they are aware of attributes specific to given class of devices).\r\n","created_at":"2018-09-04T10:39:14Z","updated_at":"2018-10-03T11:28:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"590387d7313a59a531c8c02c2afed257be59d647","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1026148731,"node_id":"MDU6TGFiZWwxMDI2MTQ4NzMx","url":"https://api.github.com/repos/snapcore/snapd/labels/Hotplug","name":"Hotplug","color":"ecef8b","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/snapcore/snapd/pulls/5759/commits","review_comments_url":"https://api.github.com/repos/snapcore/snapd/pulls/5759/comments","review_comment_url":"https://api.github.com/repos/snapcore/snapd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snapcore/snapd/issues/5759/comments","statuses_url":"https://api.github.com/repos/snapcore/snapd/statuses/59139790ec30b85574f96c3ca847508cf5ce66cb","head":{"label":"stolowski:default-device-key","ref":"default-device-key","sha":"59139790ec30b85574f96c3ca847508cf5ce66cb","user":{"login":"stolowski","id":168604,"node_id":"MDQ6VXNlcjE2ODYwNA==","avatar_url":"https://avatars0.githubusercontent.com/u/168604?v=4","gravatar_id":"","url":"https://api.github.com/users/stolowski","html_url":"https://github.com/stolowski","followers_url":"https://api.github.com/users/stolowski/followers","following_url":"https://api.github.com/users/stolowski/following{/other_user}","gists_url":"https://api.github.com/users/stolowski/gists{/gist_id}","starred_url":"https://api.github.com/users/stolowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stolowski/subscriptions","organizations_url":"https://api.github.com/users/stolowski/orgs","repos_url":"https://api.github.com/users/stolowski/repos","events_url":"https://api.github.com/users/stolowski/events{/privacy}","received_events_url":"https://api.github.com/users/stolowski/received_events","type":"User","site_admin":false},"repo":{"id":66472850,"node_id":"MDEwOlJlcG9zaXRvcnk2NjQ3Mjg1MA==","name":"snapd","full_name":"stolowski/snapd","private":false,"owner":{"login":"stolowski","id":168604,"node_id":"MDQ6VXNlcjE2ODYwNA==","avatar_url":"https://avatars0.githubusercontent.com/u/168604?v=4","gravatar_id":"","url":"https://api.github.com/users/stolowski","html_url":"https://github.com/stolowski","followers_url":"https://api.github.com/users/stolowski/followers","following_url":"https://api.github.com/users/stolowski/following{/other_user}","gists_url":"https://api.github.com/users/stolowski/gists{/gist_id}","starred_url":"https://api.github.com/users/stolowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stolowski/subscriptions","organizations_url":"https://api.github.com/users/stolowski/orgs","repos_url":"https://api.github.com/users/stolowski/repos","events_url":"https://api.github.com/users/stolowski/events{/privacy}","received_events_url":"https://api.github.com/users/stolowski/received_events","type":"User","site_admin":false},"html_url":"https://github.com/stolowski/snapd","description":"The snapd and snap tools enable systems to work with .snap files.","fork":true,"url":"https://api.github.com/repos/stolowski/snapd","forks_url":"https://api.github.com/repos/stolowski/snapd/forks","keys_url":"https://api.github.com/repos/stolowski/snapd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stolowski/snapd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stolowski/snapd/teams","hooks_url":"https://api.github.com/repos/stolowski/snapd/hooks","issue_events_url":"https://api.github.com/repos/stolowski/snapd/issues/events{/number}","events_url":"https://api.github.com/repos/stolowski/snapd/events","assignees_url":"https://api.github.com/repos/stolowski/snapd/assignees{/user}","branches_url":"https://api.github.com/repos/stolowski/snapd/branches{/branch}","tags_url":"https://api.github.com/repos/stolowski/snapd/tags","blobs_url":"https://api.github.com/repos/stolowski/snapd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stolowski/snapd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stolowski/snapd/git/refs{/sha}","trees_url":"https://api.github.com/repos/stolowski/snapd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stolowski/snapd/statuses/{sha}","languages_url":"https://api.github.com/repos/stolowski/snapd/languages","stargazers_url":"https://api.github.com/repos/stolowski/snapd/stargazers","contributors_url":"https://api.github.com/repos/stolowski/snapd/contributors","subscribers_url":"https://api.github.com/repos/stolowski/snapd/subscribers","subscription_url":"https://api.github.com/repos/stolowski/snapd/subscription","commits_url":"https://api.github.com/repos/stolowski/snapd/commits{/sha}","git_commits_url":"https://api.github.com/repos/stolowski/snapd/git/commits{/sha}","comments_url":"https://api.github.com/repos/stolowski/snapd/comments{/number}","issue_comment_url":"https://api.github.com/repos/stolowski/snapd/issues/comments{/number}","contents_url":"https://api.github.com/repos/stolowski/snapd/contents/{+path}","compare_url":"https://api.github.com/repos/stolowski/snapd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stolowski/snapd/merges","archive_url":"https://api.github.com/repos/stolowski/snapd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stolowski/snapd/downloads","issues_url":"https://api.github.com/repos/stolowski/snapd/issues{/number}","pulls_url":"https://api.github.com/repos/stolowski/snapd/pulls{/number}","milestones_url":"https://api.github.com/repos/stolowski/snapd/milestones{/number}","notifications_url":"https://api.github.com/repos/stolowski/snapd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stolowski/snapd/labels{/name}","releases_url":"https://api.github.com/repos/stolowski/snapd/releases{/id}","deployments_url":"https://api.github.com/repos/stolowski/snapd/deployments","created_at":"2016-08-24T14:50:18Z","updated_at":"2016-08-24T14:50:21Z","pushed_at":"2018-10-03T11:18:53Z","git_url":"git://github.com/stolowski/snapd.git","ssh_url":"git@github.com:stolowski/snapd.git","clone_url":"https://github.com/stolowski/snapd.git","svn_url":"https://github.com/stolowski/snapd","homepage":"","size":74206,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"snapcore:master","ref":"master","sha":"6242ab938d62b5a0de44bde6ff5a887c0a9b441c","user":{"login":"snapcore","id":19532717,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NTMyNzE3","avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"repo":{"id":44672744,"node_id":"MDEwOlJlcG9zaXRvcnk0NDY3Mjc0NA==","name":"snapd","full_name":"snapcore/snapd","private":false,"owner":{"login":"snapcore","id":19532717,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NTMyNzE3","avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/snapcore/snapd","description":"The snapd and snap tools enable systems to work with .snap files.","fork":false,"url":"https://api.github.com/repos/snapcore/snapd","forks_url":"https://api.github.com/repos/snapcore/snapd/forks","keys_url":"https://api.github.com/repos/snapcore/snapd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snapd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snapd/teams","hooks_url":"https://api.github.com/repos/snapcore/snapd/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snapd/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snapd/events","assignees_url":"https://api.github.com/repos/snapcore/snapd/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snapd/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snapd/tags","blobs_url":"https://api.github.com/repos/snapcore/snapd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snapd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snapd/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snapd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snapd/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snapd/languages","stargazers_url":"https://api.github.com/repos/snapcore/snapd/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snapd/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snapd/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snapd/subscription","commits_url":"https://api.github.com/repos/snapcore/snapd/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snapd/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snapd/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snapd/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snapd/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snapd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snapd/merges","archive_url":"https://api.github.com/repos/snapcore/snapd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snapd/downloads","issues_url":"https://api.github.com/repos/snapcore/snapd/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snapd/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snapd/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snapd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snapd/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snapd/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snapd/deployments","created_at":"2015-10-21T11:51:46Z","updated_at":"2018-10-03T11:15:22Z","pushed_at":"2018-10-03T11:18:55Z","git_url":"git://github.com/snapcore/snapd.git","ssh_url":"git@github.com:snapcore/snapd.git","clone_url":"https://github.com/snapcore/snapd.git","svn_url":"https://github.com/snapcore/snapd","homepage":"","size":73082,"stargazers_count":1020,"watchers_count":1020,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":256,"mirror_url":null,"archived":false,"open_issues_count":44,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":256,"open_issues":44,"watchers":1020,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/5759"},"html":{"href":"https://github.com/snapcore/snapd/pull/5759"},"issue":{"href":"https://api.github.com/repos/snapcore/snapd/issues/5759"},"comments":{"href":"https://api.github.com/repos/snapcore/snapd/issues/5759/comments"},"review_comments":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/5759/comments"},"review_comment":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/5759/commits"},"statuses":{"href":"https://api.github.com/repos/snapcore/snapd/statuses/59139790ec30b85574f96c3ca847508cf5ce66cb"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"stolowski"}}