{"action":"created","comment":{"url":"https://api.github.com/repos/ceph/ceph-container/pulls/comments/167202163","pull_request_review_id":95375638,"id":167202163,"diff_hunk":"@@ -1,80 +1,155 @@\n #!/bin/bash\n set -e\n \n+# Get a list of child devices from a root device\n+function get_child_partitions {\n+# $1: raw parent device\n+  if [ ! -e  \"${1}\" ] && [ ! -b \"${1}\" ]; then\n+    echo \"Error, ${1} doesn't seem to be a valid device!\"\n+    exit 1\n+  fi\n+  PARTS=$(lsblk -no KNAME \"${1}\")\n+  for p in $PARTS; do\n+    kname=$(lsblk --nodeps -no KNAME /dev/\"${p}\")\n+    pkname=$(lsblk --nodeps -no PKNAME /dev/\"${p}\")\n+    if [ \"${kname}\" != \"${pkname}\" ] && [ -n \"${pkname}\" ]; then\n+      echo /dev/\"${p}\"\n+    fi\n+  done\n+}\n+\n+# Get parent device of a partition\n+function get_parent_device {\n+# $1: partition to get the parent's device (eg. /dev/sda2)\n+  if [ ! -e \"${1}\" ] && [ ! -b \"${1}\" ]; then\n+    echo \"Error, ${1} doesn't seem to be a valid partition!\"\n+    exit 1\n+  fi\n+  lsblk --nodeps -no PKNAME \"${1}\"\n+}\n+\n+function is_blockdevice {\n+  if test -b \"${1}\"; then echo 1; else echo 0; fi\n+}\n+\n+function is_parentpartition {\n+  local result\n+  result=$(lsblk --nodeps -no PKNAME \"${1}\")\n+  if [ \"$result\" == \"\" ]; then\n+    echo 0\n+  else\n+    echo 1\n+  fi\n+}\n+\n+function has_boot_label {\n+  local result\n+  result=$(lsblk --nodeps -no LABEL \"${1}\")\n+  if [ \"$result\" == \"boot\" ]; then\n+    echo 0\n+  else\n+    echo 1\n+  fi\n+}\n+\n+function get_dmcrypt_uuid_part {\n+  # look for Ceph encrypted partitions\n+  # Get all dmcrypt for ${device}\n+  blkid -t TYPE=\"crypto_LUKS\" \"${1}\"* -o value -s PARTUUID\n+}\n+\n+function get_opened_dmcrypt {\n+  # Get actual opened dmcrypt for ${device}\n+  dmsetup ls --exec 'basename' --target crypt\n+}\n+\n+function zap_dmcrypt_device {\n+  # $1: list of cryptoluks partitions (returned by get_dmcrypt_uuid_part)\n+  # $2: list of opened dm (returned by get_opened_dmcrypt)\n+  if [ $# -ne 2 ]; then echo \"${FUNCNAME[0]}\" function needs 2 args; exit 1; fi\n+  local dm_uuid\n+  for dm_uuid in $1; do\n+    for dm in $2; do if [ \"${dm_uuid}\" == \"${dm}\" ]; then cryptsetup luksClose /dev/mapper/\"${dm_uuid}\"; fi done\n+    dm_path=\"/dev/disk/by-partuuid/${dm_uuid}\"\n+    dmsetup wipe_table --force \"${dm_uuid}\" || log \"Warning: dmsetup wipe_table non-zero return code\"\n+    dmsetup remove --force --retry \"${dm_uuid}\" || log \"Warning: dmsetup remove non-zero return code\"\n+    # erase all keyslots (remove encryption key)\n+    payload_offset=$(cryptsetup luksDump \"${dm_path}\" | awk '/Payload offset:/ { print $3 }')\n+    phys_sector_size=$(blockdev --getpbsz \"${dm_path}\")\n+    # If the sector size isn't a number, let's default to 512\n+    if ! is_integer \"${phys_sector_size}\"; then phys_sector_size=512; fi\n+    # remove LUKS header\n+    dd if=/dev/zero of=\"${dm_path}\" bs=\"${phys_sector_size}\" count=\"${payload_offset}\" oflag=direct\n+  done\n+}\n+\n+function get_all_ceph_devices {\n+  local all_devices\n+  # Let's iterate over all devices on the node.\n+  for device in $(blkid -o device)\n+  do\n+    local partlabel\n+    # get the partlabel for the current device.\n+    partlabel=$(blkid \"${device}\" -s PARTLABEL -o value)\n+\n+    # some device might not have partlabel, it means ${partlabel} will be empty\n+    # in that case, simply jump to the next iteration.\n+    if [ -z \"$partlabel\" ]; then continue; fi","path":"ceph-releases/luminous/ubuntu/16.04/daemon/zap_device.sh","position":null,"original_position":97,"commit_id":"5d52350b738d3d20bb647ba70a8f38a17d0084aa","original_commit_id":"2a1b96ca48e834c9d6f54c7d75bc662acce1855f","user":{"login":"guits","id":3717838,"avatar_url":"https://avatars1.githubusercontent.com/u/3717838?v=4","gravatar_id":"","url":"https://api.github.com/users/guits","html_url":"https://github.com/guits","followers_url":"https://api.github.com/users/guits/followers","following_url":"https://api.github.com/users/guits/following{/other_user}","gists_url":"https://api.github.com/users/guits/gists{/gist_id}","starred_url":"https://api.github.com/users/guits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guits/subscriptions","organizations_url":"https://api.github.com/users/guits/orgs","repos_url":"https://api.github.com/users/guits/repos","events_url":"https://api.github.com/users/guits/events{/privacy}","received_events_url":"https://api.github.com/users/guits/received_events","type":"User","site_admin":false},"body":"done","created_at":"2018-02-09T11:18:24Z","updated_at":"2018-02-09T11:20:49Z","html_url":"https://github.com/ceph/ceph-container/pull/900#discussion_r167202163","pull_request_url":"https://api.github.com/repos/ceph/ceph-container/pulls/900","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph-container/pulls/comments/167202163"},"html":{"href":"https://github.com/ceph/ceph-container/pull/900#discussion_r167202163"},"pull_request":{"href":"https://api.github.com/repos/ceph/ceph-container/pulls/900"}},"in_reply_to_id":167189566},"pull_request":{"url":"https://api.github.com/repos/ceph/ceph-container/pulls/900","id":168196540,"html_url":"https://github.com/ceph/ceph-container/pull/900","diff_url":"https://github.com/ceph/ceph-container/pull/900.diff","patch_url":"https://github.com/ceph/ceph-container/pull/900.patch","issue_url":"https://api.github.com/repos/ceph/ceph-container/issues/900","number":900,"state":"open","locked":false,"title":"Fix purge","user":{"login":"guits","id":3717838,"avatar_url":"https://avatars1.githubusercontent.com/u/3717838?v=4","gravatar_id":"","url":"https://api.github.com/users/guits","html_url":"https://github.com/guits","followers_url":"https://api.github.com/users/guits/followers","following_url":"https://api.github.com/users/guits/following{/other_user}","gists_url":"https://api.github.com/users/guits/gists{/gist_id}","starred_url":"https://api.github.com/users/guits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guits/subscriptions","organizations_url":"https://api.github.com/users/guits/orgs","repos_url":"https://api.github.com/users/guits/repos","events_url":"https://api.github.com/users/guits/events{/privacy}","received_events_url":"https://api.github.com/users/guits/received_events","type":"User","site_admin":false},"body":"When a cluster is purged, there is leftover on partitions since they are\r\nnot wiped properly and this prevent from redeploying a cluster, indeed,\r\nthe osd\r\ndisk activate process will complain about mismatching uuids.\r\n\r\nIn order to fix this issue, we must wipe the first 4k of each created\r\npartitions of the OSD device.","created_at":"2018-02-09T09:58:04Z","updated_at":"2018-02-09T11:20:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"309d151819b713f24425797925a4e28941d0097b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/ceph/ceph-container/pulls/900/commits","review_comments_url":"https://api.github.com/repos/ceph/ceph-container/pulls/900/comments","review_comment_url":"https://api.github.com/repos/ceph/ceph-container/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ceph/ceph-container/issues/900/comments","statuses_url":"https://api.github.com/repos/ceph/ceph-container/statuses/5d52350b738d3d20bb647ba70a8f38a17d0084aa","head":{"label":"ceph:fix_purge","ref":"fix_purge","sha":"5d52350b738d3d20bb647ba70a8f38a17d0084aa","user":{"login":"ceph","id":1015767,"avatar_url":"https://avatars3.githubusercontent.com/u/1015767?v=4","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"repo":{"id":29601598,"name":"ceph-container","full_name":"ceph/ceph-container","owner":{"login":"ceph","id":1015767,"avatar_url":"https://avatars3.githubusercontent.com/u/1015767?v=4","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ceph/ceph-container","description":"Docker files and images to run Ceph in containers","fork":false,"url":"https://api.github.com/repos/ceph/ceph-container","forks_url":"https://api.github.com/repos/ceph/ceph-container/forks","keys_url":"https://api.github.com/repos/ceph/ceph-container/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ceph/ceph-container/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ceph/ceph-container/teams","hooks_url":"https://api.github.com/repos/ceph/ceph-container/hooks","issue_events_url":"https://api.github.com/repos/ceph/ceph-container/issues/events{/number}","events_url":"https://api.github.com/repos/ceph/ceph-container/events","assignees_url":"https://api.github.com/repos/ceph/ceph-container/assignees{/user}","branches_url":"https://api.github.com/repos/ceph/ceph-container/branches{/branch}","tags_url":"https://api.github.com/repos/ceph/ceph-container/tags","blobs_url":"https://api.github.com/repos/ceph/ceph-container/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ceph/ceph-container/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ceph/ceph-container/git/refs{/sha}","trees_url":"https://api.github.com/repos/ceph/ceph-container/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ceph/ceph-container/statuses/{sha}","languages_url":"https://api.github.com/repos/ceph/ceph-container/languages","stargazers_url":"https://api.github.com/repos/ceph/ceph-container/stargazers","contributors_url":"https://api.github.com/repos/ceph/ceph-container/contributors","subscribers_url":"https://api.github.com/repos/ceph/ceph-container/subscribers","subscription_url":"https://api.github.com/repos/ceph/ceph-container/subscription","commits_url":"https://api.github.com/repos/ceph/ceph-container/commits{/sha}","git_commits_url":"https://api.github.com/repos/ceph/ceph-container/git/commits{/sha}","comments_url":"https://api.github.com/repos/ceph/ceph-container/comments{/number}","issue_comment_url":"https://api.github.com/repos/ceph/ceph-container/issues/comments{/number}","contents_url":"https://api.github.com/repos/ceph/ceph-container/contents/{+path}","compare_url":"https://api.github.com/repos/ceph/ceph-container/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ceph/ceph-container/merges","archive_url":"https://api.github.com/repos/ceph/ceph-container/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ceph/ceph-container/downloads","issues_url":"https://api.github.com/repos/ceph/ceph-container/issues{/number}","pulls_url":"https://api.github.com/repos/ceph/ceph-container/pulls{/number}","milestones_url":"https://api.github.com/repos/ceph/ceph-container/milestones{/number}","notifications_url":"https://api.github.com/repos/ceph/ceph-container/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ceph/ceph-container/labels{/name}","releases_url":"https://api.github.com/repos/ceph/ceph-container/releases{/id}","deployments_url":"https://api.github.com/repos/ceph/ceph-container/deployments","created_at":"2015-01-21T17:22:51Z","updated_at":"2018-02-08T17:40:51Z","pushed_at":"2018-02-09T11:20:25Z","git_url":"git://github.com/ceph/ceph-container.git","ssh_url":"git@github.com:ceph/ceph-container.git","clone_url":"https://github.com/ceph/ceph-container.git","svn_url":"https://github.com/ceph/ceph-container","homepage":null,"size":7063,"stargazers_count":671,"watchers_count":671,"language":"Shell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":302,"mirror_url":null,"archived":false,"open_issues_count":101,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":302,"open_issues":101,"watchers":671,"default_branch":"master"}},"base":{"label":"ceph:master","ref":"master","sha":"d0e61040d8cdcb2cca4ad504ee46aacded1cc55f","user":{"login":"ceph","id":1015767,"avatar_url":"https://avatars3.githubusercontent.com/u/1015767?v=4","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"repo":{"id":29601598,"name":"ceph-container","full_name":"ceph/ceph-container","owner":{"login":"ceph","id":1015767,"avatar_url":"https://avatars3.githubusercontent.com/u/1015767?v=4","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ceph/ceph-container","description":"Docker files and images to run Ceph in containers","fork":false,"url":"https://api.github.com/repos/ceph/ceph-container","forks_url":"https://api.github.com/repos/ceph/ceph-container/forks","keys_url":"https://api.github.com/repos/ceph/ceph-container/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ceph/ceph-container/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ceph/ceph-container/teams","hooks_url":"https://api.github.com/repos/ceph/ceph-container/hooks","issue_events_url":"https://api.github.com/repos/ceph/ceph-container/issues/events{/number}","events_url":"https://api.github.com/repos/ceph/ceph-container/events","assignees_url":"https://api.github.com/repos/ceph/ceph-container/assignees{/user}","branches_url":"https://api.github.com/repos/ceph/ceph-container/branches{/branch}","tags_url":"https://api.github.com/repos/ceph/ceph-container/tags","blobs_url":"https://api.github.com/repos/ceph/ceph-container/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ceph/ceph-container/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ceph/ceph-container/git/refs{/sha}","trees_url":"https://api.github.com/repos/ceph/ceph-container/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ceph/ceph-container/statuses/{sha}","languages_url":"https://api.github.com/repos/ceph/ceph-container/languages","stargazers_url":"https://api.github.com/repos/ceph/ceph-container/stargazers","contributors_url":"https://api.github.com/repos/ceph/ceph-container/contributors","subscribers_url":"https://api.github.com/repos/ceph/ceph-container/subscribers","subscription_url":"https://api.github.com/repos/ceph/ceph-container/subscription","commits_url":"https://api.github.com/repos/ceph/ceph-container/commits{/sha}","git_commits_url":"https://api.github.com/repos/ceph/ceph-container/git/commits{/sha}","comments_url":"https://api.github.com/repos/ceph/ceph-container/comments{/number}","issue_comment_url":"https://api.github.com/repos/ceph/ceph-container/issues/comments{/number}","contents_url":"https://api.github.com/repos/ceph/ceph-container/contents/{+path}","compare_url":"https://api.github.com/repos/ceph/ceph-container/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ceph/ceph-container/merges","archive_url":"https://api.github.com/repos/ceph/ceph-container/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ceph/ceph-container/downloads","issues_url":"https://api.github.com/repos/ceph/ceph-container/issues{/number}","pulls_url":"https://api.github.com/repos/ceph/ceph-container/pulls{/number}","milestones_url":"https://api.github.com/repos/ceph/ceph-container/milestones{/number}","notifications_url":"https://api.github.com/repos/ceph/ceph-container/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ceph/ceph-container/labels{/name}","releases_url":"https://api.github.com/repos/ceph/ceph-container/releases{/id}","deployments_url":"https://api.github.com/repos/ceph/ceph-container/deployments","created_at":"2015-01-21T17:22:51Z","updated_at":"2018-02-08T17:40:51Z","pushed_at":"2018-02-09T11:20:25Z","git_url":"git://github.com/ceph/ceph-container.git","ssh_url":"git@github.com:ceph/ceph-container.git","clone_url":"https://github.com/ceph/ceph-container.git","svn_url":"https://github.com/ceph/ceph-container","homepage":null,"size":7063,"stargazers_count":671,"watchers_count":671,"language":"Shell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":302,"mirror_url":null,"archived":false,"open_issues_count":101,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":302,"open_issues":101,"watchers":671,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph-container/pulls/900"},"html":{"href":"https://github.com/ceph/ceph-container/pull/900"},"issue":{"href":"https://api.github.com/repos/ceph/ceph-container/issues/900"},"comments":{"href":"https://api.github.com/repos/ceph/ceph-container/issues/900/comments"},"review_comments":{"href":"https://api.github.com/repos/ceph/ceph-container/pulls/900/comments"},"review_comment":{"href":"https://api.github.com/repos/ceph/ceph-container/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ceph/ceph-container/pulls/900/commits"},"statuses":{"href":"https://api.github.com/repos/ceph/ceph-container/statuses/5d52350b738d3d20bb647ba70a8f38a17d0084aa"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"guits"}}