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

Adapt the Cluster Health and Cat Indices APIs to closed indices #39364

Merged
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
}
},
"params": {
"expand_wildcards": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The REST API supports other indices options like ignore_unavailable but those options are overridden in the TransportClusterHealthAction to report a RED status is an index is missing (or just ignore it).

This is why this sole option is documented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think expand_wildcards should be added to _cat/indices too for symmetry and to be able to drill down into cluster health status using same expand_wildcards and index parameters?

"type" : "enum",
"options" : ["open","closed","none","all"],
"default" : "all",
"description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both."
},
"level": {
"type" : "enum",
"options" : ["cluster","indices","shards"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
"Test cat indices output":
"Test cat indices output (no indices)":

- do:
cat.indices: {}

- match:
$body: |
/^$/
---
"Test cat indices output":

- do:
indices.create:
Expand Down Expand Up @@ -47,29 +49,88 @@
(\d\d\d\d\-\d\d\-\d\dT\d\d:\d\d:\d\d.\d\d\dZ) \s*
)
$/
---
"Test cat indices output for closed index (pre 8.0.0)":
- skip:
version: "8.0.0 - "
reason: "closed indices are replicated starting version 8.0"

- do:
indices.create:
index: index-2
body:
settings:
number_of_shards: 3
number_of_replicas: 0

- do:
indices.close:
index: index1
index: index-2
- is_true: acknowledged

- do:
cluster.health:
wait_for_status: green

- do:
cat.indices:
index: index*
index: index-*

- match:
$body: |
/^( \s+
close \s+
index1 \s+
/^( \s+
close \s+
index-2 \s+
([a-zA-Z0-9=/_+]|[\\\-]){22} \s+
\s+
\s+
\s+
\s+
\s+
\s*
\s+
\s+
\s+
\s+
\s+
\s*
)
$/
---
"Test cat indices output for closed index":
- skip:
version: " - 7.99.99"
reason: "closed indices are replicated starting version 8.0"

- do:
indices.create:
index: index-2
body:
settings:
number_of_shards: 3
number_of_replicas: 0

- do:
indices.close:
index: index-2
- is_true: acknowledged

- do:
cluster.health:
wait_for_status: green

- do:
cat.indices:
index: index-*

- match:
$body: |
/^(green \s+
close \s+
index-2 \s+
([a-zA-Z0-9=/_+]|[\\\-]){22} \s+
3 \s+
0 \s+
\s+
\s+
\s+
\s*
)
$/
---
"Test cat indices using health status":

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,150 @@
- is_true: indices
- is_true: indices.test_index.shards

---
"cluster health with closed index (pre 8.0)":
- skip:
version: "8.0.0 - "
reason: "closed indices are replicated starting version 8.0"

- do:
indices.create:
index: index-1
body:
settings:
index:
number_of_replicas: 0

- do:
cluster.health:
wait_for_status: green
- match: { status: green }

- do:
indices.create:
index: index-2
body:
settings:
index:
number_of_replicas: 50

- do:
cluster.health:
wait_for_status: yellow
wait_for_no_relocating_shards: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wait_for_no_initializing-shards? Seems we do so in ClusterHealthIT, so thought this should be the same?

- match: { status: yellow }

- do:
cluster.health:
index: index-*
- match: { status: yellow }

- do:
cluster.health:
index: index-1
- match: { status: green }

- do:
cluster.health:
index: index-2
- match: { status: yellow }

- do:
indices.close:
index: index-2
- is_true: acknowledged

# closing the index-2 turns the cluster health back to green
- do:
cluster.health:
wait_for_status: green
- match: { status: green }

- do:
cluster.health:
index: index-*
- match: { status: green }

- do:
cluster.health:
index: index-1
- match: { status: green }

- do:
cluster.health:
index: index-2
- match: { status: green }

---
"cluster health with closed index":
- skip:
version: " - 7.99.99"
reason: "closed indices are replicated starting version 8.0"

- do:
indices.create:
index: index-1
body:
settings:
index:
number_of_replicas: 0

- do:
cluster.health:
wait_for_status: green
- match: { status: green }

- do:
indices.create:
index: index-2
body:
settings:
index:
number_of_replicas: 50

- do:
cluster.health:
wait_for_status: yellow
wait_for_no_relocating_shards: true
- match: { status: yellow }

- do:
cluster.health:
index: index-*
- match: { status: yellow }

- do:
cluster.health:
index: index-1
- match: { status: green }

- do:
cluster.health:
index: index-2
- match: { status: yellow }

# closing the index-2 does not change the cluster health with replicated closed indices
- do:
indices.close:
index: index-2
- is_true: acknowledged

- do:
cluster.health:
wait_for_status: yellow
- match: { status: yellow }

- do:
cluster.health:
index: index-*
- match: { status: yellow }

- do:
cluster.health:
index: index-1
- match: { status: green }

- do:
cluster.health:
index: index-2
- match: { status: yellow }
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
setup:

- do:
indices.create:
index: index-1
body:
settings:
number_of_shards: 1
number_of_replicas: 0

- do:
indices.create:
index: index-2
body:
settings:
number_of_shards: 2
number_of_replicas: 0

- do:
cluster.health:
wait_for_status: green

- do:
indices.close:
index: index-2

- do:
cluster.health:
wait_for_status: green

---
"cluster health with expand_wildcards":
- skip:
version: " - 7.99.99"
reason: "indices options has been introduced in cluster health request starting version 8.0"

- do:
cluster.health:
index: "index-*"
level: indices
expand_wildcards: open
- match: { status: green }
- match: { active_shards: 1 }
- match: { indices.index-1.status: green }
- match: { indices.index-1.active_shards: 1 }
- is_false: indices.index-2

- do:
cluster.health:
index: "index-*"
level: indices
expand_wildcards: closed
- match: { status: green }
- match: { active_shards: 2 }
- is_false: indices.index-1
- match: { indices.index-2.status: green }
- match: { indices.index-2.active_shards: 2 }

- do:
cluster.health:
index: "index-*"
level: indices
expand_wildcards: all
- match: { status: green }
- match: { active_shards: 3 }
- match: { indices.index-1.status: green }
- match: { indices.index-1.active_shards: 1 }
- match: { indices.index-2.status: green }
- match: { indices.index-2.active_shards: 2 }

- do:
cluster.health:
index: "index-*"
level: indices
expand_wildcards: none
- match: { status: green }
- match: { active_shards: 0 }
- is_false: indices.index-1
- is_false: indices.index-2
Loading