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

Field, Function and test fixes, adding missing struct to node stats #572

Merged
merged 6 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Adds the `Routing` field in SearchHit interface. ([#516](https://github.com/opensearch-project/opensearch-go/pull/516))
- Adds the `SearchPipelines` field to `SearchParams` ([#532](https://github.com/opensearch-project/opensearch-go/pull/532))
- Adds support for OpenSearch 2.14 ([#552](https://github.com/opensearch-project/opensearch-go/pull/552))
- Adds the `Caches` field to Node stats ([#572](https://github.com/opensearch-project/opensearch-go/pull/572))

### Changed

Expand All @@ -19,6 +20,10 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- Fixes empty request body on retry with compression enabled ([#543](https://github.com/opensearch-project/opensearch-go/pull/543))
- Fixes `Conditions` in `PolicyStateTransition` of ISM plugin ([#556](https://github.com/opensearch-project/opensearch-go/pull/556))
- Fixes integration test response validation when response is null ([#572](https://github.com/opensearch-project/opensearch-go/pull/572))
- Adjust security Role struct for FLS from string to []string ([#572](https://github.com/opensearch-project/opensearch-go/pull/572))
- Fixes wrong response parsing for indices mapping and recovery ([#572](https://github.com/opensearch-project/opensearch-go/pull/572))
- Fixes wrong response parsing for security get requests ([#572](https://github.com/opensearch-project/opensearch-go/pull/572))

### Security

Expand Down
2 changes: 1 addition & 1 deletion internal/test/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func CompareRawJSONwithParsedJSON(t *testing.T, resp any, rawResp *opensearch.Re
operations := make([]jsondiff.Operation, 0)
for _, operation := range patch {
// different opensearch version added more field, only check if we miss some fields
if operation.Type != "add" {
if operation.Type != "add" || (operation.Type == "add" && operation.Path == "") {
operations = append(operations, operation)
}
}
Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_indices-mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c mappingClient) Field(ctx context.Context, req *MappingFieldReq) (*Mappin
data MappingFieldResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
if data.response, err = c.apiClient.do(ctx, req, &data.Indices); err != nil {
return &data, err
}

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_indices.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (c indicesClient) Recovery(ctx context.Context, req *IndicesRecoveryReq) (*
data IndicesRecoveryResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
if data.response, err = c.apiClient.do(ctx, req, &data.Indices); err != nil {
return &data, err
}

Expand Down
15 changes: 14 additions & 1 deletion opensearchapi/api_nodes-stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type NodesStats struct {
SegmentReplicationBackpressure NodesStatsSegmentReplicationBackpressure `json:"segment_replication_backpressure"`
Repositories []json.RawMessage `json:"repositories"`
AdmissionControl NodesStatsAdmissionControl `json:"admission_control"`
Caches NodesStatsCaches `json:"caches"`
}

// NodesStatsIndices is a sub type of NodesStats representing Indices information of the node
Expand Down Expand Up @@ -702,7 +703,7 @@ type NodesStatsSegmentReplicationBackpressure struct {
TotalRejectedRequests int `json:"total_rejected_requests"`
}

// NodesStatsAdmissionControl is a sub of NodesStats
// NodesStatsAdmissionControl is a sub type of NodesStats
type NodesStatsAdmissionControl struct {
GlobalCPUUsage struct {
Transport struct {
Expand All @@ -715,3 +716,15 @@ type NodesStatsAdmissionControl struct {
} `json:"transport"`
} `json:"global_io_usage"`
}

// NodesStatsCaches is a sub type of NodesStats
type NodesStatsCaches struct {
RequestCache struct {
SizeInBytes int `json:"size_in_bytes"`
Evictions int `json:"evictions"`
HitCount int `json:"hit_count"`
MissCount int `json:"miss_count"`
ItemCount int `json:"item_count"`
StoreName string `json:"store_name"`
} `json:"request_cache"`
}
2 changes: 1 addition & 1 deletion plugins/security/api_actiongroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (c actiongroupsClient) Get(ctx context.Context, req *ActionGroupsGetReq) (A
data ActionGroupsGetResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
if data.response, err = c.apiClient.do(ctx, req, &data.Groups); err != nil {
return data, err
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/security/api_internalusers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (c internalusersClient) Get(ctx context.Context, req *InternalUsersGetReq)
data InternalUsersGetResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
if data.response, err = c.apiClient.do(ctx, req, &data.Users); err != nil {
return data, err
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/security/api_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (c rolesClient) Get(ctx context.Context, req *RolesGetReq) (RolesGetResp, e
data RolesGetResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
if data.response, err = c.apiClient.do(ctx, req, &data.Roles); err != nil {
return data, err
}

Expand Down Expand Up @@ -74,7 +74,7 @@ func (c rolesClient) Patch(ctx context.Context, req RolesPatchReq) (RolesPatchRe
type RolesIndexPermission struct {
IndexPatterns []string `json:"index_patterns,omitempty"`
DLS string `json:"dls,omitempty"`
FLS string `json:"fls,omitempty"`
FLS []string `json:"fls,omitempty"`
MaskedFields []string `json:"masked_fields,omitempty"`
AllowedActions []string `json:"allowed_actions,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/security/api_rolesmapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (c rolesmappingClient) Get(ctx context.Context, req *RolesMappingGetReq) (R
data RolesMappingGetResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
if data.response, err = c.apiClient.do(ctx, req, &data.RolesMapping); err != nil {
return data, err
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/security/api_tenants.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (c tenantsClient) Get(ctx context.Context, req *TenantsGetReq) (TenantsGetR
data TenantsGetResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
if data.response, err = c.apiClient.do(ctx, req, &data.Tenants); err != nil {
return data, err
}

Expand Down
Loading