Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structs to show ILM expiry details #238

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 56 additions & 24 deletions cluster-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ func (adm *AdminClient) SiteReplicationInfo(ctx context.Context) (info SiteRepli

// SRPeerJoinReq - arg body for SRPeerJoin
type SRPeerJoinReq struct {
SvcAcctAccessKey string `json:"svcAcctAccessKey"`
SvcAcctSecretKey string `json:"svcAcctSecretKey"`
SvcAcctParent string `json:"svcAcctParent"`
Peers map[string]PeerInfo `json:"peers"`
SvcAcctAccessKey string `json:"svcAcctAccessKey"`
SvcAcctSecretKey string `json:"svcAcctSecretKey"`
SvcAcctParent string `json:"svcAcctParent"`
Peers map[string]PeerInfo `json:"peers"`
ReplicateILMExpiry bool `json:"replicate-ilm-expiry"`
}

// PeerInfo - contains some properties of a cluster peer.
Expand All @@ -163,9 +164,10 @@ type PeerInfo struct {
Name string `json:"name"`
// Deployment ID is useful as it is immutable - though endpoint may
// change.
DeploymentID string `json:"deploymentID"`
SyncState SyncStatus `json:"sync"` // whether to enable| disable synchronous replication
DefaultBandwidth BucketBandwidth `json:"defaultbandwidth"` // bandwidth limit per bucket in bytes/sec
DeploymentID string `json:"deploymentID"`
SyncState SyncStatus `json:"sync"` // whether to enable| disable synchronous replication
DefaultBandwidth BucketBandwidth `json:"defaultbandwidth"` // bandwidth limit per bucket in bytes/sec
ReplicateILMExpiry bool `json:"replicate-ilm-expiry"`
}

// BucketBandwidth has default bandwidth limit per bucket in bytes/sec
Expand Down Expand Up @@ -622,18 +624,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,13 +672,14 @@ 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
Sites map[string]PeerInfo // deployment->sitename
StatsSummary map[string]SRSiteSummary // map of deployment id -> site stat
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
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
// mismatches or if a specific bucket's stats are requested
BucketStats map[string]map[string]SRBucketStatsSummary
Expand All @@ -683,6 +694,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 +744,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 +765,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 +779,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 +800,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 +839,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 +854,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 +867,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
Loading