зеркало из https://github.com/github/vulcanizer.git
ILM history indices are removed during policy removal
This commit is contained in:
Родитель
9a3750955e
Коммит
b0aeb1f7ef
24
es.go
24
es.go
|
@ -710,6 +710,18 @@ func (c *Client) GetIndices(index string) ([]Index, error) {
|
|||
return indices, nil
|
||||
}
|
||||
|
||||
// Get a subset of indices including hidden ones
|
||||
func (c *Client) GetHiddenIndices(index string) ([]Index, error) {
|
||||
var indices []Index
|
||||
err := handleErrWithStruct(c.buildGetRequest(fmt.Sprintf("_cat/indices/%s?h=health,status,index,pri,rep,store.size,docs.count&expand_wildcards=open,closed,hidden", index)), &indices)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return indices, nil
|
||||
}
|
||||
|
||||
// Get all the aliases in the cluster.
|
||||
//
|
||||
// Use case: You want to see some basic info on all the aliases of the cluster
|
||||
|
@ -1683,5 +1695,17 @@ func (c *Client) RemoveIndexILMPolicy(index string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
ilmHistoryIndices, err := c.GetHiddenIndices(fmt.Sprintf("%s*.ds-ilm-history-*", index))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, ilmHistoryIndex := range ilmHistoryIndices {
|
||||
err = c.DeleteIndex(ilmHistoryIndex.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -2214,12 +2214,17 @@ func TestAllocateStalePrimaryShard(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveIndexILMPolicy(t *testing.T) {
|
||||
testSetup := &ServerSetup{
|
||||
ilmRemoveTestSetup := &ServerSetup{
|
||||
Method: "POST",
|
||||
Path: "/test-index/_ilm/remove",
|
||||
}
|
||||
getIndicesTestSetup := &ServerSetup{
|
||||
Method: "GET",
|
||||
Path: "/_cat/indices/test-index*.ds-ilm-history-*",
|
||||
Response: "[]",
|
||||
}
|
||||
|
||||
host, port, ts := setupTestServers(t, []*ServerSetup{testSetup})
|
||||
host, port, ts := setupTestServers(t, []*ServerSetup{ilmRemoveTestSetup, getIndicesTestSetup})
|
||||
defer ts.Close()
|
||||
client := NewClient(host, port)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче