Skip to content

Commit

Permalink
Structs to show ILM expiry details
Browse files Browse the repository at this point in the history
This would enable showing ILM expiry details while commands
`mc admin replicate info` and `mc admin replicate status`

Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
  • Loading branch information
shtripat committed Oct 20, 2023
1 parent 50ab944 commit 2abe3e4
Showing 1 changed file with 45 additions and 15 deletions.
60 changes: 45 additions & 15 deletions cluster-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,18 +622,26 @@ type SRIAMPolicy struct {
UpdatedAt time.Time `json:"updatedAt,omitempty"`
}

// ILMExpiryRule - represents an ILM expiry rule
type ILMExpiryRule struct {
ILMRule string `json:"ilm-rule"`
Bucket string `json:"bucket"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
}

// SRInfo gets replication metadata for a site
type SRInfo struct {
Enabled bool
Name string
DeploymentID string
Buckets map[string]SRBucketInfo // map of bucket metadata info
Policies map[string]SRIAMPolicy // map of IAM policy name to content
Policies map[string]SRIAMPolicy // map of IAM policy name to content
UserPolicies map[string]SRPolicyMapping // map of username -> user policy mapping
UserInfoMap map[string]UserInfo // map of user name to UserInfo
GroupDescMap map[string]GroupDesc // map of group name to GroupDesc
GroupPolicies map[string]SRPolicyMapping // map of groupname -> group policy mapping
ReplicationCfg map[string]replication.Config // map of bucket -> replication config
ILMExpiryRules map[string]ILMExpiryRule // map of ILM Expiry rule to content
}

// SRMetaInfo - returns replication metadata info for a site.
Expand Down Expand Up @@ -662,11 +670,12 @@ func (adm *AdminClient) SRMetaInfo(ctx context.Context, opts SRStatusOptions) (i

// SRStatusInfo returns detailed status on site replication status
type SRStatusInfo struct {
Enabled bool
MaxBuckets int // maximum buckets seen across sites
MaxUsers int // maximum users seen across sites
MaxGroups int // maximum groups seen across sites
MaxPolicies int // maximum policies across sites
Enabled bool
MaxBuckets int // maximum buckets seen across sites
MaxUsers int // maximum users seen across sites
MaxGroups int // maximum groups seen across sites
MaxPolicies int // maximum policies across sites
MaxILMExpiryRules int // maxmimum ILM Expiry rules across sites
Sites map[string]PeerInfo // deployment->sitename

Check failure on line 679 in cluster-commands.go

View workflow job for this annotation

GitHub Actions / Lint checks Go 1.21.x

File is not `gofumpt`-ed (gofumpt)
StatsSummary map[string]SRSiteSummary // map of deployment id -> site stat
// BucketStats map of bucket to slice of deployment IDs with stats. This is populated only if there are
Expand All @@ -683,6 +692,9 @@ type SRStatusInfo struct {
GroupStats map[string]map[string]SRGroupStatsSummary
// Metrics summary of SRMetrics
Metrics SRMetricsSummary // metrics summary. This is populated if buckets/bucket entity requested
// ILMExpiryStats map of ILM Expiry rules to slice of deployment IDs with stats. This is populated if there
// are mismatches or if a specific ILM expiry rule's stats are requested
ILMExpiryStats map[string]map[string]SRILMExpiryStatsSummary
}

// SRPolicyStatsSummary has status of policy replication misses
Expand Down Expand Up @@ -730,6 +742,13 @@ type SRBucketStatsSummary struct {
HasQuotaCfgSet bool
}

// SRILMExpiryStatsSummary has status of ILM Expiry rules metadata replication misses
type SRILMExpiryStatsSummary struct {
DeploymentID string
ILMExpiryRuleMismatch bool
HasILMExpiryRules bool
}

// SRSiteSummary holds the count of replicated items in site replication
type SRSiteSummary struct {
ReplicatedBuckets int // count of buckets replicated across sites
Expand All @@ -744,6 +763,7 @@ type SRSiteSummary struct {
ReplicatedQuotaConfig int // count of bucket with quota config replicated across sites
ReplicatedUserPolicyMappings int // count of user policy mappings replicated across sites
ReplicatedGroupPolicyMappings int // count of group policy mappings replicated across sites
ReplicatedILMExpiryRules int // count of ILM expiry rules replicated across sites

TotalBucketsCount int // total buckets on this site
TotalTagsCount int // total count of buckets with tags on this site
Expand All @@ -757,6 +777,7 @@ type SRSiteSummary struct {
TotalGroupsCount int // total number of groups seen on this site
TotalUserPolicyMappingCount int // total number of user policy mappings seen on this site
TotalGroupPolicyMappingCount int // total number of group policy mappings seen on this site
TotalILMExpiryRulesCount int // total number of ILM expiry rules seen on the site
}

// SREntityType specifies type of entity
Expand All @@ -777,24 +798,28 @@ const (

// SRGroupEntity Group entity type
SRGroupEntity

// SRILMExpiryRuleEntity ILM expiry rule entity type
SRILMExpiryRuleEntity
)

// SRStatusOptions holds SR status options
type SRStatusOptions struct {
Buckets bool
Policies bool
Users bool
Groups bool
Metrics bool
Entity SREntityType
EntityValue string
ShowDeleted bool
Buckets bool
Policies bool
Users bool
Groups bool
Metrics bool
ILMExpiryRules bool
Entity SREntityType
EntityValue string
ShowDeleted bool
}

// IsEntitySet returns true if entity option is set
func (o *SRStatusOptions) IsEntitySet() bool {
switch o.Entity {
case SRBucketEntity, SRPolicyEntity, SRUserEntity, SRGroupEntity:
case SRBucketEntity, SRPolicyEntity, SRUserEntity, SRGroupEntity, SRILMExpiryRuleEntity:
return true
default:
return false
Expand All @@ -812,6 +837,8 @@ func GetSREntityType(name string) SREntityType {
return SRGroupEntity
case "policy":
return SRPolicyEntity
case "ilm-expiry-rule":
return SRILMExpiryRuleEntity
default:
return Unspecified
}
Expand All @@ -825,6 +852,7 @@ func (o *SRStatusOptions) getURLValues() url.Values {
urlValues.Set("groups", strconv.FormatBool(o.Groups))
urlValues.Set("showDeleted", strconv.FormatBool(o.ShowDeleted))
urlValues.Set("metrics", strconv.FormatBool(o.Metrics))
urlValues.Set("ilm-expiry-rules", strconv.FormatBool(o.ILMExpiryRules))

if o.IsEntitySet() {
urlValues.Set("entityvalue", o.EntityValue)
Expand All @@ -837,6 +865,8 @@ func (o *SRStatusOptions) getURLValues() url.Values {
urlValues.Set("entity", "user")
case SRGroupEntity:
urlValues.Set("entity", "group")
case SRILMExpiryRuleEntity:
urlValues.Set("entity", "ilm-expiry-rule")
}
}
return urlValues
Expand Down

0 comments on commit 2abe3e4

Please sign in to comment.