Skip to content

Commit

Permalink
stat: Return additional header for deletemarker replication (#1707)
Browse files Browse the repository at this point in the history
that indicates whether target is ready to receive deletemarker.
  • Loading branch information
poornas committed Oct 13, 2022
1 parent 528a26f commit 8257e70
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion api-datatypes.go
Expand Up @@ -147,7 +147,8 @@ type ObjectInfo struct {
// - FAILED
// - REPLICA (on the destination)
ReplicationStatus string `xml:"ReplicationStatus"`

// set to true if delete marker has backing object version on target, and eligible to replicate
ReplicationReady bool
// Lifecycle expiry-date and ruleID associated with the expiry
// not to be confused with `Expires` HTTP header.
Expiration time.Time
Expand Down
6 changes: 4 additions & 2 deletions api-stat.go
Expand Up @@ -90,6 +90,7 @@ func (c *Client) StatObject(ctx context.Context, bucketName, objectName string,

if resp != nil {
deleteMarker := resp.Header.Get(amzDeleteMarker) == "true"
replicationReady := resp.Header.Get(minioTgtReplicationReady) == "true"
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
if resp.StatusCode == http.StatusMethodNotAllowed && opts.VersionID != "" && deleteMarker {
errResp := ErrorResponse{
Expand All @@ -105,8 +106,9 @@ func (c *Client) StatObject(ctx context.Context, bucketName, objectName string,
}, errResp
}
return ObjectInfo{
VersionID: resp.Header.Get(amzVersionID),
IsDeleteMarker: deleteMarker,
VersionID: resp.Header.Get(amzVersionID),
IsDeleteMarker: deleteMarker,
ReplicationReady: replicationReady, // whether delete marker can be replicated
}, httpRespToErrorResponse(resp, bucketName, objectName)
}
}
Expand Down
5 changes: 3 additions & 2 deletions constants.go
Expand Up @@ -96,6 +96,7 @@ const (
minIOBucketReplicationObjectRetentionTimestamp = "X-Minio-Source-Replication-Retention-Timestamp"
// Header indicates last legalhold update time on source
minIOBucketReplicationObjectLegalHoldTimestamp = "X-Minio-Source-Replication-LegalHold-Timestamp"

minIOForceDelete = "x-minio-force-delete"
minIOForceDelete = "x-minio-force-delete"
// Header indicates delete marker replication request can be sent by source now.
minioTgtReplicationReady = "X-Minio-Replication-Ready"
)

0 comments on commit 8257e70

Please sign in to comment.