mirror of
https://github.com/minio/minio.git
synced 2025-11-10 22:10:12 -05:00
Implement heal-upload admin API (#3914)
This API is meant for administrative tools like mc-admin to heal an ongoing multipart upload on a Minio server. N B This set of admin APIs apply only for Minio servers. `github.com/minio/minio/pkg/madmin` provides a go SDK for this (and other admin) operations. Specifically, func HealUpload(bucket, object, uploadID string, dryRun bool) error Sample admin API request: POST /?heal&bucket=mybucket&object=myobject&upload-id=myuploadID&dry-run - Header(s): ["x-minio-operation"] = "upload" Notes: - bucket, object and upload-id are mandatory query parameters - if dry-run is set, API returns success if all parameters passed are valid.
This commit is contained in:
committed by
Harshavardhana
parent
d4eea224d4
commit
c192e5c9b2
@@ -44,6 +44,7 @@ func main() {
|
||||
| | |[`HealObject`](#HealObject)|||
|
||||
| | |[`HealFormat`](#HealFormat)|||
|
||||
| | |[`ListUploadsHeal`](#ListUploadsHeal)|||
|
||||
| | |[`HealUpload`](#HealUpload)|||
|
||||
|
||||
## 1. Constructor
|
||||
<a name="Minio"></a>
|
||||
@@ -278,6 +279,62 @@ __Example__
|
||||
log.Println("successfully healed storage format on available disks.")
|
||||
|
||||
```
|
||||
<a name="ListUploadsHeal"> </a>
|
||||
### ListUploadsHeal(bucket, prefix string, recursive bool, doneCh <-chan struct{}) (<-chan UploadInfo, error)
|
||||
List ongoing multipart uploads that need healing.
|
||||
|
||||
| Param | Type | Description |
|
||||
|---|---|---|
|
||||
|`ui.Key` | _string_ | Name of the object being uploaded |
|
||||
|`ui.UploadID` | _string_ | UploadID of the ongoing multipart upload |
|
||||
|`ui.HealUploadInfo.Status` | _healStatus_| One of `Healthy`, `CanHeal`, `Corrupted`, `QuorumUnavailable`|
|
||||
|`ui.Err`| _error_ | non-nil if fetching fetching healing information failed |
|
||||
|
||||
__Example__
|
||||
|
||||
``` go
|
||||
|
||||
// Set true if recursive listing is needed.
|
||||
isRecursive := true
|
||||
// List objects that need healing for a given bucket and
|
||||
// prefix.
|
||||
healUploadsCh, err := madmClnt.ListUploadsHeal(bucket, prefix, isRecursive, doneCh)
|
||||
if err != nil {
|
||||
log.Fatalln("Failed to get list of uploads to be healed: ", err)
|
||||
}
|
||||
|
||||
for upload := range healUploadsCh {
|
||||
if upload.Err != nil {
|
||||
log.Println("upload listing error: ", upload.Err)
|
||||
}
|
||||
|
||||
if upload.HealUploadInfo != nil {
|
||||
switch healInfo := *upload.HealUploadInfo; healInfo.Status {
|
||||
case madmin.CanHeal:
|
||||
fmt.Println(upload.Key, " can be healed.")
|
||||
case madmin.QuorumUnavailable:
|
||||
fmt.Println(upload.Key, " can't be healed until quorum is available.")
|
||||
case madmin.Corrupted:
|
||||
fmt.Println(upload.Key, " can't be healed, not enough information.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
<a name="HealUpload"></a>
|
||||
### HealUpload(bucket, object, uploadID string, isDryRun bool) error
|
||||
If upload is successfully healed returns nil, otherwise returns error indicating the reason for failure. If isDryRun is true, then the upload is not healed, but heal upload request is validated by the server. e.g, if the upload exists, if upload name is valid etc.
|
||||
|
||||
``` go
|
||||
isDryRun = false
|
||||
err = madmClnt.HealUpload("mybucket", "myobject", "myuploadID", isDryRun)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
log.Println("successfully healed mybucket/myobject/myuploadID")
|
||||
```
|
||||
|
||||
## 5. Config operations
|
||||
|
||||
@@ -354,46 +411,3 @@ __Example__
|
||||
}
|
||||
log.Println("SetConfig: ", string(buf.Bytes()))
|
||||
```
|
||||
|
||||
<a name="ListUploadsHeal"> </a>
|
||||
### ListUploadsHeal(bucket, prefix string, recursive bool, doneCh <-chan struct{}) (<-chan UploadInfo, error)
|
||||
List ongoing multipart uploads that need healing.
|
||||
|
||||
| Param | Type | Description |
|
||||
|---|---|---|
|
||||
|`ui.Key` | _string_ | Name of the object being uploaded |
|
||||
|`ui.UploadID` | _string_ | UploadID of the ongoing multipart upload |
|
||||
|`ui.HealUploadInfo.Status` | _healStatus_| One of `Healthy`, `CanHeal`, `Corrupted`, `QuorumUnavailable`|
|
||||
|`ui.Err`| _error_ | non-nil if fetching fetching healing information failed |
|
||||
|
||||
__Example__
|
||||
|
||||
``` go
|
||||
|
||||
// Set true if recursive listing is needed.
|
||||
isRecursive := true
|
||||
// List objects that need healing for a given bucket and
|
||||
// prefix.
|
||||
healUploadsCh, err := madmClnt.ListUploadsHeal(bucket, prefix, isRecursive, doneCh)
|
||||
if err != nil {
|
||||
log.Fatalln("Failed to get list of uploads to be healed: ", err)
|
||||
}
|
||||
|
||||
for upload := range healUploadsCh {
|
||||
if upload.Err != nil {
|
||||
log.Println("upload listing error: ", upload.Err)
|
||||
}
|
||||
|
||||
if upload.HealUploadInfo != nil {
|
||||
switch healInfo := *upload.HealUploadInfo; healInfo.Status {
|
||||
case madmin.CanHeal:
|
||||
fmt.Println(upload.Key, " can be healed.")
|
||||
case madmin.QuorumUnavailable:
|
||||
fmt.Println(upload.Key, " can't be healed until quorum is available.")
|
||||
case madmin.Corrupted:
|
||||
fmt.Println(upload.Key, " can't be healed, not enough information.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user