Skip to content

Commit

Permalink
Add missing failure fields in opensearchapi structs (#510)
Browse files Browse the repository at this point in the history
* opensearchapi: add FailuresCause struct to be reused by other structs

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: add FailuresShard to be reused by other structs

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: add miss failures fields/structs

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: add missing node field to ResponseShardsFailure struct

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: fix bulk error reason can be nil

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: fix cat possible nil fields

Signed-off-by: Jakob Hahn <[email protected]>

* add changelog

Signed-off-by: Jakob Hahn <[email protected]>

---------

Signed-off-by: Jakob Hahn <[email protected]>
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]>
  • Loading branch information
Jakob3xD and dblock authored Apr 10, 2024
1 parent 38b48ff commit 3e5f0de
Show file tree
Hide file tree
Showing 25 changed files with 213 additions and 158 deletions.
21 changes: 11 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Added
- Adds GlobalIOUsage struct for nodes stats ([#506](https://github.com/opensearch-project/opensearch-go/pull/506))
- Adds the `Explanation` field containing the document explain details to the `SearchHit` struct. ([#504](https://github.com/opensearch-project/opensearch-go/pull/504))
- Adds the `Fields` field containing the document fields to the `SearchHit` struct. ([#508](https://github.com/opensearch-project/opensearch-go/pull/508))
- Adds new error types ([#512](https://github.com/opensearch-project/opensearch-go/pull/506))
- Adds handling of non json errors to ParseError ([#512](https://github.com/opensearch-project/opensearch-go/pull/506))
- Adds the `Failures` field to opensearchapi structs ([#510](https://github.com/opensearch-project/opensearch-go/pull/510))

### Changed
- Use docker compose v2 instead of v1 ([#506](https://github.com/opensearch-project/opensearch-go/pull/506))
- Uses docker compose v2 instead of v1 ([#506](https://github.com/opensearch-project/opensearch-go/pull/506))
- Updates go version to 1.21 ([#509](https://github.com/opensearch-project/opensearch-go/pull/509))
- Moved Error structs from opensearchapi to opensearch package ([#512](https://github.com/opensearch-project/opensearch-go/pull/506))
- Move parseError function from opensearchapi to opensearch package as ParseError ([#512](https://github.com/opensearch-project/opensearch-go/pull/506))
- Change ParseError function to do type assertion to determine error type ([#512](https://github.com/opensearch-project/opensearch-go/pull/506))
- Removed unused structs and functions from opensearch ([#517](https://github.com/opensearch-project/opensearch-go/pull/517))
- Adjust and extent opensearch tests for better coverage ([#517](https://github.com/opensearch-project/opensearch-go/pull/517))
- Bump codecov action version to v4 ([#517](https://github.com/opensearch-project/opensearch-go/pull/517))
- Moves Error structs from opensearchapi to opensearch package ([#512](https://github.com/opensearch-project/opensearch-go/pull/506))
- Moves parseError function from opensearchapi to opensearch package as ParseError ([#512](https://github.com/opensearch-project/opensearch-go/pull/506))
- Changes ParseError function to do type assertion to determine error type ([#512](https://github.com/opensearch-project/opensearch-go/pull/506))
- Removes unused structs and functions from opensearch ([#517](https://github.com/opensearch-project/opensearch-go/pull/517))
- Adjusts and extent opensearch tests for better coverage ([#517](https://github.com/opensearch-project/opensearch-go/pull/517))
- Bumps codecov action version to v4 ([#517](https://github.com/opensearch-project/opensearch-go/pull/517))
- Changes bulk error/reason field and some cat response fields to pointer as they can be nil ([#510](https://github.com/opensearch-project/opensearch-go/pull/510))

### Deprecated

### Removed

### Fixed
- Fix search request missing a slash when no indices are given ([#470](https://github.com/opensearch-project/opensearch-go/pull/469))
- Fix opensearchtransport check for nil response body ([#517](https://github.com/opensearch-project/opensearch-go/pull/517))
- Fixes search request missing a slash when no indices are given ([#470](https://github.com/opensearch-project/opensearch-go/pull/469))
- Fixes opensearchtransport check for nil response body ([#517](https://github.com/opensearch-project/opensearch-go/pull/517))

### Security

Expand Down
4 changes: 2 additions & 2 deletions opensearchapi/api_bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ type BulkRespItem struct {
End int `json:"end"`
} `json:"position,omitempty"`
Cause *struct {
Type string `json:"type"`
Reason string `json:"reason"`
Type string `json:"type"`
Reason *string `json:"reason"`
} `json:"caused_by"`
} `json:"caused_by,omitempty"`
} `json:"error,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_cat-nodeattrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type CatNodeAttrsResp struct {
type CatNodeAttrsItemResp struct {
Node string `json:"node"`
ID string `json:"id"`
PID int `json:"pid,string"`
PID *int `json:"pid,string"`
Host string `json:"host"`
IP string `json:"ip"`
Port int `json:"port,string"`
Expand Down
198 changes: 99 additions & 99 deletions opensearchapi/api_cat-nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,105 +37,105 @@ type CatNodesResp struct {

// CatNodesItemResp represents one index of the CatNodesResp
type CatNodesItemResp struct {
ID string `json:"id"`
PID string `json:"pid"`
IP string `json:"ip"`
Port int `json:"port,string"`
HTTPAddress string `json:"http_address"`
Version string `json:"version"`
Type string `json:"type"`
Build string `json:"build"`
JDK string `json:"jdk"`
DiskTotal string `json:"disk.total"`
DiskUsed string `json:"disk.used"`
DiskAvail string `json:"disk.avail"`
DiskUsedPercent string `json:"disk.used_percent"`
HeapCurrent string `json:"heap.current"`
HeapPercent int `json:"heap.percent,string"`
HeapMax string `json:"heap.max"`
RAMCurrent string `json:"ram.current"`
RAMPercent int `json:"ram.percent,string"`
RAMMax string `json:"ram.max"`
FileDescCurrent int `json:"file_desc.current,string"`
FileDescPercent int `json:"file_desc.percent,string"`
FileDescMax int `json:"file_desc.max,string"`
CPU int `json:"cpu,string"`
Load1M string `json:"load_1m"`
Load5M string `json:"load_5m"`
Load15M string `json:"load_15m"`
Uptime string `json:"uptime"`
Role string `json:"node.role"`
Roles string `json:"node.roles"`
Master string `json:"master"`
ClusterManager string `json:"cluster_manager"`
Name string `json:"name"`
CompletionSize string `json:"completion.size"`
FieldDataMemorySize string `json:"fielddata.memory_size"`
FileldDataEvictions int `json:"fielddata.evictions,string"`
QueryCacheMemorySize string `json:"query_cache.memory_size"`
QueryCacheEvictions int `json:"query_cache.evictions,string"`
QueryCacheHitCount int `json:"query_cache.hit_count,string"`
QueryCacheMissCount int `json:"query_cache.miss_count,string"`
RequestCacheMemorySize string `json:"request_cache.memory_size"`
RequestCacheEvictions int `json:"request_cache.evictions,string"`
RequestCacheHitCount int `json:"request_cache.hit_count,string"`
RequestCacheMissCount int `json:"request_cache.miss_count,string"`
FlushTotal int `json:"flush.total,string"`
FlushTotalTime string `json:"flush.total_time"`
GetCurrent int `json:"get.current,string"`
GetTime string `json:"get.time"`
GetTotal int `json:"get.total,string"`
GetExistsTime string `json:"get.exists_time"`
GetExistsTotal int `json:"get.exists_total,string"`
GetMissingTime string `json:"get.missing_time"`
GetMissingTotal int `json:"get.missing_total,string"`
IndexingDeleteCurrent int `json:"indexing.delete_current,string"`
IndexingDeleteTime string `json:"indexing.delete_time"`
IndexingDeleteTotal int `json:"indexing.delete_total,string"`
IndexingIndexCurrent int `json:"indexing.index_current,string"`
IndexingIndexTime string `json:"indexing.index_time"`
IndexingIndexTotal int `json:"indexing.index_total,string"`
IndexingIndexFailed int `json:"indexing.index_failed,string"`
MergesCurrent int `json:"merges.current,string"`
MergesCurrentDoc int `json:"merges.current_docs,string"`
MergesCurrentSize string `json:"merges.current_size"`
MergesTotal int `json:"merges.total,string"`
MergesTotalDocs int `json:"merges.total_docs,string"`
MergesTotalSize string `json:"merges.total_size"`
MergesTotalTime string `json:"merges.total_time"`
RefreshTotal int `json:"refresh.total,string"`
RefreshTime string `json:"refresh.time"`
RefreshExternalTotal int `json:"refresh.external_total,string"`
RefreshExternalTime string `json:"refresh.external_time"`
RefreshListeners int `json:"refresh.listeners,string"`
ScriptCompilations int `json:"script.compilations,string"`
ScriptCacheEvictions int `json:"script.cache_evictions,string"`
ScriptCompilationLimitTriggered int `json:"script.compilation_limit_triggered,string"`
SearchFetchCurrent int `json:"search.fetch_current,string"`
SearchFetchTime string `json:"search.fetch_time"`
SearchFetchTotal int `json:"search.fetch_total,string"`
SearchOpenContexts int `json:"search.open_contexts,string"`
SearchQueryCurrent int `json:"search.query_current,string"`
SearchQueryTime string `json:"search.query_time"`
SearchQueryTotal int `json:"search.query_total,string"`
SearchConcurrentQueryCurrent int `json:"search.concurrent_query_current,string"`
SearchConcurrentQueryTime string `json:"search.concurrent_query_time"`
SearchConcurrentQueryTotal int `json:"search.concurrent_query_total,string"`
SearchConcurrentAvgSliceCount string `json:"search.concurrent_avg_slice_count"`
SearchScrollCurrent int `json:"search.scroll_current,string"`
SearchScrollTime string `json:"search.scroll_time"`
SearchScrollTotal int `json:"search.scroll_total,string"`
SearchPointInTimeCurrent int `json:"search.point_in_time_current,string"`
SearchPointInTimeTime string `json:"search.point_in_time_time"`
SearchPointInTimeTotal int `json:"search.point_in_time_total,string"`
SegmentsCount int `json:"segments.count,string"`
SegmentsMemory string `json:"segments.memory"`
SegmentsIndexWriteMemory string `json:"segments.index_writer_memory"`
SegmentsVersionMapMemory string `json:"segments.version_map_memory"`
SegmentsFixedBitsetMemory string `json:"segments.fixed_bitset_memory"`
SuggestCurrent int `json:"suggest.current,string"`
SuggestTime string `json:"suggest.time"`
SuggestTotal int `json:"suggest.total,string"`
ID string `json:"id"`
PID *string `json:"pid"`
IP string `json:"ip"`
Port int `json:"port,string"`
HTTPAddress string `json:"http_address"`
Version string `json:"version"`
Type *string `json:"type"`
Build *string `json:"build"`
JDK *string `json:"jdk"`
DiskTotal *string `json:"disk.total"`
DiskUsed *string `json:"disk.used"`
DiskAvail *string `json:"disk.avail"`
DiskUsedPercent *string `json:"disk.used_percent"`
HeapCurrent *string `json:"heap.current"`
HeapPercent *int `json:"heap.percent,string"`
HeapMax *string `json:"heap.max"`
RAMCurrent *string `json:"ram.current"`
RAMPercent *int `json:"ram.percent,string"`
RAMMax *string `json:"ram.max"`
FileDescCurrent *int `json:"file_desc.current,string"`
FileDescPercent *int `json:"file_desc.percent,string"`
FileDescMax *int `json:"file_desc.max,string"`
CPU *int `json:"cpu,string"`
Load1M *string `json:"load_1m"`
Load5M *string `json:"load_5m"`
Load15M *string `json:"load_15m"`
Uptime *string `json:"uptime"`
Role string `json:"node.role"`
Roles string `json:"node.roles"`
Master string `json:"master"`
ClusterManager string `json:"cluster_manager"`
Name string `json:"name"`
CompletionSize *string `json:"completion.size"`
FieldDataMemorySize *string `json:"fielddata.memory_size"`
FileldDataEvictions *int `json:"fielddata.evictions,string"`
QueryCacheMemorySize *string `json:"query_cache.memory_size"`
QueryCacheEvictions *int `json:"query_cache.evictions,string"`
QueryCacheHitCount *int `json:"query_cache.hit_count,string"`
QueryCacheMissCount *int `json:"query_cache.miss_count,string"`
RequestCacheMemorySize *string `json:"request_cache.memory_size"`
RequestCacheEvictions *int `json:"request_cache.evictions,string"`
RequestCacheHitCount *int `json:"request_cache.hit_count,string"`
RequestCacheMissCount *int `json:"request_cache.miss_count,string"`
FlushTotal *int `json:"flush.total,string"`
FlushTotalTime *string `json:"flush.total_time"`
GetCurrent *int `json:"get.current,string"`
GetTime *string `json:"get.time"`
GetTotal *int `json:"get.total,string"`
GetExistsTime *string `json:"get.exists_time"`
GetExistsTotal *int `json:"get.exists_total,string"`
GetMissingTime *string `json:"get.missing_time"`
GetMissingTotal *int `json:"get.missing_total,string"`
IndexingDeleteCurrent *int `json:"indexing.delete_current,string"`
IndexingDeleteTime *string `json:"indexing.delete_time"`
IndexingDeleteTotal *int `json:"indexing.delete_total,string"`
IndexingIndexCurrent *int `json:"indexing.index_current,string"`
IndexingIndexTime *string `json:"indexing.index_time"`
IndexingIndexTotal *int `json:"indexing.index_total,string"`
IndexingIndexFailed *int `json:"indexing.index_failed,string"`
MergesCurrent *int `json:"merges.current,string"`
MergesCurrentDoc *int `json:"merges.current_docs,string"`
MergesCurrentSize *string `json:"merges.current_size"`
MergesTotal *int `json:"merges.total,string"`
MergesTotalDocs *int `json:"merges.total_docs,string"`
MergesTotalSize *string `json:"merges.total_size"`
MergesTotalTime *string `json:"merges.total_time"`
RefreshTotal *int `json:"refresh.total,string"`
RefreshTime *string `json:"refresh.time"`
RefreshExternalTotal *int `json:"refresh.external_total,string"`
RefreshExternalTime *string `json:"refresh.external_time"`
RefreshListeners *int `json:"refresh.listeners,string"`
ScriptCompilations *int `json:"script.compilations,string"`
ScriptCacheEvictions *int `json:"script.cache_evictions,string"`
ScriptCompilationLimitTriggered *int `json:"script.compilation_limit_triggered,string"`
SearchFetchCurrent *int `json:"search.fetch_current,string"`
SearchFetchTime *string `json:"search.fetch_time"`
SearchFetchTotal *int `json:"search.fetch_total,string"`
SearchOpenContexts *int `json:"search.open_contexts,string"`
SearchQueryCurrent *int `json:"search.query_current,string"`
SearchQueryTime *string `json:"search.query_time"`
SearchQueryTotal *int `json:"search.query_total,string"`
SearchConcurrentQueryCurrent *int `json:"search.concurrent_query_current,string"`
SearchConcurrentQueryTime *string `json:"search.concurrent_query_time"`
SearchConcurrentQueryTotal *int `json:"search.concurrent_query_total,string"`
SearchConcurrentAvgSliceCount *string `json:"search.concurrent_avg_slice_count"`
SearchScrollCurrent *int `json:"search.scroll_current,string"`
SearchScrollTime *string `json:"search.scroll_time"`
SearchScrollTotal *int `json:"search.scroll_total,string"`
SearchPointInTimeCurrent *int `json:"search.point_in_time_current,string"`
SearchPointInTimeTime *string `json:"search.point_in_time_time"`
SearchPointInTimeTotal *int `json:"search.point_in_time_total,string"`
SegmentsCount *int `json:"segments.count,string"`
SegmentsMemory *string `json:"segments.memory"`
SegmentsIndexWriteMemory *string `json:"segments.index_writer_memory"`
SegmentsVersionMapMemory *string `json:"segments.version_map_memory"`
SegmentsFixedBitsetMemory *string `json:"segments.fixed_bitset_memory"`
SuggestCurrent *int `json:"suggest.current,string"`
SuggestTime *string `json:"suggest.time"`
SuggestTotal *int `json:"suggest.total,string"`
}

// Inspect returns the Inspect type containing the raw *opensearch.Reponse
Expand Down
7 changes: 4 additions & 3 deletions opensearchapi/api_cluster-stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ func (r ClusterStatsReq) GetRequest() (*http.Request, error) {
// ClusterStatsResp represents the returned struct of the ClusterStatsReq response
type ClusterStatsResp struct {
NodesInfo struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
Failures []FailuresCause `json:"failures"`
} `json:"_nodes"`
ClusterName string `json:"cluster_name"`
ClusterUUID string `json:"cluster_uuid"`
Expand Down
6 changes: 6 additions & 0 deletions opensearchapi/api_datastream-stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ type DataStreamStatsResp struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
Failures []struct {
Shard int `json:"shard"`
Index string `json:"index"`
Status string `json:"status"`
Reason FailuresCause `json:"reason"`
} `json:"failures"`
} `json:"_shards"`
DataStreamCount int `json:"data_stream_count"`
BackingIndices int `json:"backing_indices"`
Expand Down
3 changes: 2 additions & 1 deletion opensearchapi/api_document-delete_by_query_rethrottle.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ type DocumentDeleteByQueryRethrottleResp struct {
} `json:"resource_stats"`
} `json:"tasks"`
} `json:"nodes"`
response *opensearch.Response
NodeFailures []FailuresCause `json:"node_failures"`
response *opensearch.Response
}

// DocumentDeleteByQueryRethrottleResourceInfo is a sub type of DocumentDeleteByQueryRethrottleResp containing resource stats
Expand Down
Loading

0 comments on commit 3e5f0de

Please sign in to comment.