mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Revert "Revert "Add delete marker replication support (#10396)""
This reverts commit 267d7bf0a9.
This commit is contained in:
@@ -46,6 +46,11 @@ func (s StatusType) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
// Empty returns true if this status is not set
|
||||
func (s StatusType) Empty() bool {
|
||||
return string(s) == ""
|
||||
}
|
||||
|
||||
var (
|
||||
errReplicationTooManyRules = Errorf("Replication configuration allows a maximum of 1000 rules")
|
||||
errReplicationNoRule = Errorf("Replication configuration should have at least one rule")
|
||||
@@ -156,8 +161,11 @@ func (c Config) GetDestination() Destination {
|
||||
func (c Config) Replicate(obj ObjectOpts) bool {
|
||||
|
||||
for _, rule := range c.FilterActionableRules(obj) {
|
||||
|
||||
if obj.DeleteMarker {
|
||||
// check MinIO extension for versioned deletes
|
||||
if !obj.DeleteMarker && obj.VersionID != "" && rule.DeleteReplication.Status == Disabled {
|
||||
return false
|
||||
}
|
||||
if obj.DeleteMarker && rule.DeleteMarkerReplication.Status == Disabled {
|
||||
// Indicates whether MinIO will remove a delete marker. By default, delete markers
|
||||
// are not replicated.
|
||||
return false
|
||||
@@ -165,9 +173,6 @@ func (c Config) Replicate(obj ObjectOpts) bool {
|
||||
if obj.SSEC {
|
||||
return false
|
||||
}
|
||||
if obj.VersionID != "" && !obj.IsLatest {
|
||||
return false
|
||||
}
|
||||
if rule.Status == Disabled {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -45,12 +45,50 @@ func (d DeleteMarkerReplication) Validate() error {
|
||||
if d.IsEmpty() {
|
||||
return errDeleteMarkerReplicationMissing
|
||||
}
|
||||
if d.Status != Disabled {
|
||||
if d.Status != Disabled && d.Status != Enabled {
|
||||
return errInvalidDeleteMarkerReplicationStatus
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteReplication - whether versioned deletes are replicated - this is a MinIO only
|
||||
// extension.
|
||||
type DeleteReplication struct {
|
||||
Status Status `xml:"Status"` // should be set to "Disabled" by default
|
||||
}
|
||||
|
||||
// IsEmpty returns true if DeleteReplication is not set
|
||||
func (d DeleteReplication) IsEmpty() bool {
|
||||
return len(d.Status) == 0
|
||||
}
|
||||
|
||||
// Validate validates whether the status is disabled.
|
||||
func (d DeleteReplication) Validate() error {
|
||||
if d.IsEmpty() {
|
||||
return errDeleteReplicationMissing
|
||||
}
|
||||
if d.Status != Disabled && d.Status != Enabled {
|
||||
return errInvalidDeleteReplicationStatus
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalXML - decodes XML data.
|
||||
func (d *DeleteReplication) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) (err error) {
|
||||
// Make subtype to avoid recursive UnmarshalXML().
|
||||
type deleteReplication DeleteReplication
|
||||
drep := deleteReplication{}
|
||||
|
||||
if err := dec.DecodeElement(&drep, &start); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(drep.Status) == 0 {
|
||||
drep.Status = Disabled
|
||||
}
|
||||
d.Status = drep.Status
|
||||
return nil
|
||||
}
|
||||
|
||||
// Rule - a rule for replication configuration.
|
||||
type Rule struct {
|
||||
XMLName xml.Name `xml:"Rule" json:"Rule"`
|
||||
@@ -58,8 +96,10 @@ type Rule struct {
|
||||
Status Status `xml:"Status" json:"Status"`
|
||||
Priority int `xml:"Priority" json:"Priority"`
|
||||
DeleteMarkerReplication DeleteMarkerReplication `xml:"DeleteMarkerReplication" json:"DeleteMarkerReplication"`
|
||||
Destination Destination `xml:"Destination" json:"Destination"`
|
||||
Filter Filter `xml:"Filter" json:"Filter"`
|
||||
// MinIO extension to replicate versioned deletes
|
||||
DeleteReplication DeleteReplication `xml:"DeleteReplication" json:"DeleteReplication"`
|
||||
Destination Destination `xml:"Destination" json:"Destination"`
|
||||
Filter Filter `xml:"Filter" json:"Filter"`
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -70,6 +110,8 @@ var (
|
||||
errPriorityMissing = Errorf("Priority must be specified")
|
||||
errInvalidDeleteMarkerReplicationStatus = Errorf("Delete marker replication is currently not supported")
|
||||
errDestinationSourceIdentical = Errorf("Destination bucket cannot be the same as the source bucket.")
|
||||
errDeleteReplicationMissing = Errorf("Delete replication must be specified")
|
||||
errInvalidDeleteReplicationStatus = Errorf("Delete replication is either enable|disable")
|
||||
)
|
||||
|
||||
// validateID - checks if ID is valid or not.
|
||||
@@ -146,6 +188,9 @@ func (r Rule) Validate(bucket string, sameTarget bool) error {
|
||||
if err := r.DeleteMarkerReplication.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.DeleteReplication.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if r.Priority < 0 {
|
||||
return errPriorityMissing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user