|
|
@ -18,6 +18,7 @@ package cmd |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"context" |
|
|
|
|
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"time" |
|
|
@ -179,20 +180,24 @@ func replicateObject(ctx context.Context, bucket, object, versionID string, obje |
|
|
|
if tgt == nil { |
|
|
|
if tgt == nil { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
gr, err := objectAPI.GetObjectNInfo(ctx, bucket, object, nil, http.Header{}, readLock, ObjectOptions{}) |
|
|
|
gr, err := objectAPI.GetObjectNInfo(ctx, bucket, object, nil, http.Header{}, readLock, ObjectOptions{ |
|
|
|
|
|
|
|
VersionID: versionID, |
|
|
|
|
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
defer gr.Close() |
|
|
|
|
|
|
|
objInfo := gr.ObjInfo |
|
|
|
objInfo := gr.ObjInfo |
|
|
|
size, err := objInfo.GetActualSize() |
|
|
|
size, err := objInfo.GetActualSize() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
|
|
|
|
gr.Close() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dest := cfg.GetDestination() |
|
|
|
dest := cfg.GetDestination() |
|
|
|
if dest.Bucket == "" { |
|
|
|
if dest.Bucket == "" { |
|
|
|
|
|
|
|
gr.Close() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
// In the rare event that replication is in pending state either due to
|
|
|
|
// In the rare event that replication is in pending state either due to
|
|
|
@ -201,6 +206,7 @@ func replicateObject(ctx context.Context, bucket, object, versionID string, obje |
|
|
|
if healPending { |
|
|
|
if healPending { |
|
|
|
_, err := tgt.StatObject(ctx, dest.Bucket, object, miniogo.StatObjectOptions{VersionID: objInfo.VersionID}) |
|
|
|
_, err := tgt.StatObject(ctx, dest.Bucket, object, miniogo.StatObjectOptions{VersionID: objInfo.VersionID}) |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
|
|
|
|
gr.Close() |
|
|
|
// object with same VersionID already exists, replication kicked off by
|
|
|
|
// object with same VersionID already exists, replication kicked off by
|
|
|
|
// PutObject might have completed.
|
|
|
|
// PutObject might have completed.
|
|
|
|
return |
|
|
|
return |
|
|
@ -210,6 +216,7 @@ func replicateObject(ctx context.Context, bucket, object, versionID string, obje |
|
|
|
|
|
|
|
|
|
|
|
replicationStatus := replication.Complete |
|
|
|
replicationStatus := replication.Complete |
|
|
|
_, err = tgt.PutObject(ctx, dest.Bucket, object, gr, size, "", "", putOpts) |
|
|
|
_, err = tgt.PutObject(ctx, dest.Bucket, object, gr, size, "", "", putOpts) |
|
|
|
|
|
|
|
gr.Close() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
replicationStatus = replication.Failed |
|
|
|
replicationStatus = replication.Failed |
|
|
|
// Notify replication failure event.
|
|
|
|
// Notify replication failure event.
|
|
|
@ -231,8 +238,10 @@ func replicateObject(ctx context.Context, bucket, object, versionID string, obje |
|
|
|
objInfo.metadataOnly = true // Perform only metadata updates.
|
|
|
|
objInfo.metadataOnly = true // Perform only metadata updates.
|
|
|
|
if _, err = objectAPI.CopyObject(ctx, bucket, object, bucket, object, objInfo, ObjectOptions{ |
|
|
|
if _, err = objectAPI.CopyObject(ctx, bucket, object, bucket, object, objInfo, ObjectOptions{ |
|
|
|
VersionID: objInfo.VersionID, |
|
|
|
VersionID: objInfo.VersionID, |
|
|
|
}, ObjectOptions{VersionID: objInfo.VersionID}); err != nil { |
|
|
|
}, ObjectOptions{ |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
VersionID: objInfo.VersionID, |
|
|
|
|
|
|
|
}); err != nil { |
|
|
|
|
|
|
|
logger.LogIf(ctx, fmt.Errorf("Unable to update replication metadata for %s: %s", objInfo.VersionID, err)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|