{"action":"created","comment":{"url":"https://api.github.com/repos/minio/minio/pulls/comments/72584367","id":72584367,"diff_hunk":"@@ -522,6 +530,131 @@ func healFormatXLFreshDisks(storageDisks []StorageAPI) error {\n \treturn saveFormatXL(orderedDisks, newFormatConfigs)\n }\n \n+// Heals corrupted format json in all disks\n+func healFormatXLCorruptedDisks(storageDisks []StorageAPI) error {\n+\tformatConfigs := make([]*formatConfigV1, len(storageDisks))\n+\tvar referenceConfig *formatConfigV1\n+\t// Loads `format.json` from all disks.\n+\tfor index, disk := range storageDisks {\n+\t\t// Disk not found or ignored is a valid case.\n+\t\tif disk == nil {\n+\t\t\t// Return nil, one of the disk is offline.\n+\t\t\treturn nil\n+\t\t}\n+\t\tformatXL, err := loadFormat(disk)\n+\t\tif err != nil {\n+\t\t\tif err == errUnformattedDisk || err == errCorruptedFormat {\n+\t\t\t\t// format.json is missing or corrupted, should be healed.\n+\t\t\t\tcontinue\n+\t\t\t} else if err == errDiskNotFound { // Is a valid case we\n+\t\t\t\t// can proceed without healing.\n+\t\t\t\treturn nil\n+\t\t\t}\n+\t\t\t// Return error for unsupported errors.\n+\t\t\treturn err\n+\t\t} // Success.\n+\t\tformatConfigs[index] = formatXL\n+\t}\n+\n+\t// All `format.json` has been read successfully, previously completed.\n+\tif isFormatFound(formatConfigs) {\n+\t\t// Return success.\n+\t\treturn nil\n+\t}\n+\n+\t// All disks are fresh, format.json will be written by initFormatXL()\n+\tif isFormatNotFound(formatConfigs) {\n+\t\treturn initFormatXL(storageDisks)\n+\t}\n+\n+\t// Validate format configs for consistency in JBOD and disks.\n+\tif err := checkFormatXL(formatConfigs); err != nil {\n+\t\treturn err\n+\t}\n+\n+\tif referenceConfig == nil {\n+\t\t// This config will be used to update the drives missing format.json.\n+\t\tfor _, formatConfig := range formatConfigs {\n+\t\t\tif formatConfig == nil {\n+\t\t\t\tcontinue\n+\t\t\t}\n+\t\t\treferenceConfig = formatConfig\n+\t\t\tbreak\n+\t\t}\n+\t}\n+\n+\t// Collect new JBOD.\n+\tnewJBOD := referenceConfig.XL.JBOD\n+\n+\t// Reorder the disks based on the JBOD order.\n+\torderedDisks, err := reorderDisks(storageDisks, formatConfigs)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\t// From ordered disks fill the UUID position.\n+\tfor index, disk := range orderedDisks {\n+\t\tif disk == nil {\n+\t\t\tnewJBOD[index] = getUUID()\n+\t\t}\n+\t}\n+\n+\t// For disks with corrupted formats, inspect the disk index from any object:\n+\t//  1. Search for any object\n+\t//  2. Parse its metafile and calculate its index based on index and distribution information\n+\tfor index, format := range formatConfigs {","path":"format-config-v1.go","position":111,"original_position":136,"commit_id":"faebed3f4b0d7e9afbc045868eaa5d739330ed2e","original_commit_id":"5f7517d33f114fde37ca956fdeda54179fae3179","user":{"login":"harshavardhana","id":622699,"avatar_url":"https://avatars.githubusercontent.com/u/622699?v=3","gravatar_id":"","url":"https://api.github.com/users/harshavardhana","html_url":"https://github.com/harshavardhana","followers_url":"https://api.github.com/users/harshavardhana/followers","following_url":"https://api.github.com/users/harshavardhana/following{/other_user}","gists_url":"https://api.github.com/users/harshavardhana/gists{/gist_id}","starred_url":"https://api.github.com/users/harshavardhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshavardhana/subscriptions","organizations_url":"https://api.github.com/users/harshavardhana/orgs","repos_url":"https://api.github.com/users/harshavardhana/repos","events_url":"https://api.github.com/users/harshavardhana/events{/privacy}","received_events_url":"https://api.github.com/users/harshavardhana/received_events","type":"User","site_admin":false},"body":"It would nicer to move this into a function of its own. Easy to test. ","created_at":"2016-07-28T08:41:07Z","updated_at":"2016-07-28T08:41:07Z","html_url":"https://github.com/minio/minio/pull/2297#discussion_r72584367","pull_request_url":"https://api.github.com/repos/minio/minio/pulls/2297","_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/comments/72584367"},"html":{"href":"https://github.com/minio/minio/pull/2297#discussion_r72584367"},"pull_request":{"href":"https://api.github.com/repos/minio/minio/pulls/2297"}}},"pull_request":{"url":"https://api.github.com/repos/minio/minio/pulls/2297","id":78890049,"html_url":"https://github.com/minio/minio/pull/2297","diff_url":"https://github.com/minio/minio/pull/2297.diff","patch_url":"https://github.com/minio/minio/pull/2297.patch","issue_url":"https://api.github.com/repos/minio/minio/issues/2297","number":2297,"state":"open","locked":false,"title":"[Need review] Heal corrupted formats of disks already containing objects","user":{"login":"vadmeste","id":283197,"avatar_url":"https://avatars.githubusercontent.com/u/283197?v=3","gravatar_id":"","url":"https://api.github.com/users/vadmeste","html_url":"https://github.com/vadmeste","followers_url":"https://api.github.com/users/vadmeste/followers","following_url":"https://api.github.com/users/vadmeste/following{/other_user}","gists_url":"https://api.github.com/users/vadmeste/gists{/gist_id}","starred_url":"https://api.github.com/users/vadmeste/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vadmeste/subscriptions","organizations_url":"https://api.github.com/users/vadmeste/orgs","repos_url":"https://api.github.com/users/vadmeste/repos","events_url":"https://api.github.com/users/vadmeste/events{/privacy}","received_events_url":"https://api.github.com/users/vadmeste/received_events","type":"User","site_admin":false},"body":"* reduceFormatErrs return multiple errors because we can have different disks with different erros\r\n* Add healFormatXLCorruptedDisks()\r\n\r\nFixes #2182 \r\n\r\n","created_at":"2016-07-26T17:13:40Z","updated_at":"2016-07-28T08:41:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b0c8d019254cfc0255960e7eb0286b7b3ea7a6e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/minio/minio/pulls/2297/commits","review_comments_url":"https://api.github.com/repos/minio/minio/pulls/2297/comments","review_comment_url":"https://api.github.com/repos/minio/minio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/minio/minio/issues/2297/comments","statuses_url":"https://api.github.com/repos/minio/minio/statuses/faebed3f4b0d7e9afbc045868eaa5d739330ed2e","head":{"label":"vadmeste:heal_corrupted","ref":"heal_corrupted","sha":"faebed3f4b0d7e9afbc045868eaa5d739330ed2e","user":{"login":"vadmeste","id":283197,"avatar_url":"https://avatars.githubusercontent.com/u/283197?v=3","gravatar_id":"","url":"https://api.github.com/users/vadmeste","html_url":"https://github.com/vadmeste","followers_url":"https://api.github.com/users/vadmeste/followers","following_url":"https://api.github.com/users/vadmeste/following{/other_user}","gists_url":"https://api.github.com/users/vadmeste/gists{/gist_id}","starred_url":"https://api.github.com/users/vadmeste/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vadmeste/subscriptions","organizations_url":"https://api.github.com/users/vadmeste/orgs","repos_url":"https://api.github.com/users/vadmeste/repos","events_url":"https://api.github.com/users/vadmeste/events{/privacy}","received_events_url":"https://api.github.com/users/vadmeste/received_events","type":"User","site_admin":false},"repo":{"id":30432336,"name":"minio","full_name":"vadmeste/minio","owner":{"login":"vadmeste","id":283197,"avatar_url":"https://avatars.githubusercontent.com/u/283197?v=3","gravatar_id":"","url":"https://api.github.com/users/vadmeste","html_url":"https://github.com/vadmeste","followers_url":"https://api.github.com/users/vadmeste/followers","following_url":"https://api.github.com/users/vadmeste/following{/other_user}","gists_url":"https://api.github.com/users/vadmeste/gists{/gist_id}","starred_url":"https://api.github.com/users/vadmeste/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vadmeste/subscriptions","organizations_url":"https://api.github.com/users/vadmeste/orgs","repos_url":"https://api.github.com/users/vadmeste/repos","events_url":"https://api.github.com/users/vadmeste/events{/privacy}","received_events_url":"https://api.github.com/users/vadmeste/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vadmeste/minio","description":"Minio is an open source object storage inspired by Amazon S3 and Facebook Haystack ","fork":true,"url":"https://api.github.com/repos/vadmeste/minio","forks_url":"https://api.github.com/repos/vadmeste/minio/forks","keys_url":"https://api.github.com/repos/vadmeste/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vadmeste/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vadmeste/minio/teams","hooks_url":"https://api.github.com/repos/vadmeste/minio/hooks","issue_events_url":"https://api.github.com/repos/vadmeste/minio/issues/events{/number}","events_url":"https://api.github.com/repos/vadmeste/minio/events","assignees_url":"https://api.github.com/repos/vadmeste/minio/assignees{/user}","branches_url":"https://api.github.com/repos/vadmeste/minio/branches{/branch}","tags_url":"https://api.github.com/repos/vadmeste/minio/tags","blobs_url":"https://api.github.com/repos/vadmeste/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vadmeste/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vadmeste/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/vadmeste/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vadmeste/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/vadmeste/minio/languages","stargazers_url":"https://api.github.com/repos/vadmeste/minio/stargazers","contributors_url":"https://api.github.com/repos/vadmeste/minio/contributors","subscribers_url":"https://api.github.com/repos/vadmeste/minio/subscribers","subscription_url":"https://api.github.com/repos/vadmeste/minio/subscription","commits_url":"https://api.github.com/repos/vadmeste/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/vadmeste/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/vadmeste/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/vadmeste/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/vadmeste/minio/contents/{+path}","compare_url":"https://api.github.com/repos/vadmeste/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vadmeste/minio/merges","archive_url":"https://api.github.com/repos/vadmeste/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vadmeste/minio/downloads","issues_url":"https://api.github.com/repos/vadmeste/minio/issues{/number}","pulls_url":"https://api.github.com/repos/vadmeste/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/vadmeste/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/vadmeste/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vadmeste/minio/labels{/name}","releases_url":"https://api.github.com/repos/vadmeste/minio/releases{/id}","deployments_url":"https://api.github.com/repos/vadmeste/minio/deployments","created_at":"2015-02-06T20:48:08Z","updated_at":"2016-01-11T08:27:57Z","pushed_at":"2016-07-28T00:30:09Z","git_url":"git://github.com/vadmeste/minio.git","ssh_url":"git@github.com:vadmeste/minio.git","clone_url":"https://github.com/vadmeste/minio.git","svn_url":"https://github.com/vadmeste/minio","homepage":"http://minio.io","size":14886,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"minio:master","ref":"master","sha":"77248bd6e8a50d8f0d88f95d5ed9624e2aad6585","user":{"login":"minio","id":695951,"avatar_url":"https://avatars.githubusercontent.com/u/695951?v=3","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"repo":{"id":29261473,"name":"minio","full_name":"minio/minio","owner":{"login":"minio","id":695951,"avatar_url":"https://avatars.githubusercontent.com/u/695951?v=3","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/minio/minio","description":"Minio is an object storage server compatible with Amazon S3 and licensed under Apache 2.0 License","fork":false,"url":"https://api.github.com/repos/minio/minio","forks_url":"https://api.github.com/repos/minio/minio/forks","keys_url":"https://api.github.com/repos/minio/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minio/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minio/minio/teams","hooks_url":"https://api.github.com/repos/minio/minio/hooks","issue_events_url":"https://api.github.com/repos/minio/minio/issues/events{/number}","events_url":"https://api.github.com/repos/minio/minio/events","assignees_url":"https://api.github.com/repos/minio/minio/assignees{/user}","branches_url":"https://api.github.com/repos/minio/minio/branches{/branch}","tags_url":"https://api.github.com/repos/minio/minio/tags","blobs_url":"https://api.github.com/repos/minio/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minio/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minio/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/minio/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minio/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/minio/minio/languages","stargazers_url":"https://api.github.com/repos/minio/minio/stargazers","contributors_url":"https://api.github.com/repos/minio/minio/contributors","subscribers_url":"https://api.github.com/repos/minio/minio/subscribers","subscription_url":"https://api.github.com/repos/minio/minio/subscription","commits_url":"https://api.github.com/repos/minio/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/minio/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/minio/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/minio/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/minio/minio/contents/{+path}","compare_url":"https://api.github.com/repos/minio/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minio/minio/merges","archive_url":"https://api.github.com/repos/minio/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minio/minio/downloads","issues_url":"https://api.github.com/repos/minio/minio/issues{/number}","pulls_url":"https://api.github.com/repos/minio/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/minio/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/minio/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minio/minio/labels{/name}","releases_url":"https://api.github.com/repos/minio/minio/releases{/id}","deployments_url":"https://api.github.com/repos/minio/minio/deployments","created_at":"2015-01-14T19:23:58Z","updated_at":"2016-07-28T08:28:30Z","pushed_at":"2016-07-28T06:51:57Z","git_url":"git://github.com/minio/minio.git","ssh_url":"git@github.com:minio/minio.git","clone_url":"https://github.com/minio/minio.git","svn_url":"https://github.com/minio/minio","homepage":"https://minio.io/downloads/","size":16464,"stargazers_count":1881,"watchers_count":1881,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":160,"mirror_url":null,"open_issues_count":44,"forks":160,"open_issues":44,"watchers":1881,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/2297"},"html":{"href":"https://github.com/minio/minio/pull/2297"},"issue":{"href":"https://api.github.com/repos/minio/minio/issues/2297"},"comments":{"href":"https://api.github.com/repos/minio/minio/issues/2297/comments"},"review_comments":{"href":"https://api.github.com/repos/minio/minio/pulls/2297/comments"},"review_comment":{"href":"https://api.github.com/repos/minio/minio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/minio/minio/pulls/2297/commits"},"statuses":{"href":"https://api.github.com/repos/minio/minio/statuses/faebed3f4b0d7e9afbc045868eaa5d739330ed2e"}}}}
{"actor":{"display_login":"harshavardhana"}}