Skip to content

Commit 6c59e4f

Browse files
committed
[API] Adds snapshot.repository_verify_integrity
1 parent 754827a commit 6c59e4f

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# This code was automatically generated from the Elasticsearch Specification
19+
# See https://github.com/elastic/elasticsearch-specification
20+
# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash.
21+
module Elasticsearch
22+
module API
23+
module Snapshot
24+
module Actions
25+
# Verify the repository integrity.
26+
# Verify the integrity of the contents of a snapshot repository.
27+
# This API enables you to perform a comprehensive check of the contents of a repository, looking for any anomalies in its data or metadata which might prevent you from restoring snapshots from the repository or which might cause future snapshot create or delete operations to fail.
28+
# If you suspect the integrity of the contents of one of your snapshot repositories, cease all write activity to this repository immediately, set its `read_only` option to `true`, and use this API to verify its integrity.
29+
# Until you do so:
30+
# * It may not be possible to restore some snapshots from this repository.
31+
# * Searchable snapshots may report errors when searched or may have unassigned shards.
32+
# * Taking snapshots into this repository may fail or may appear to succeed but have created a snapshot which cannot be restored.
33+
# * Deleting snapshots from this repository may fail or may appear to succeed but leave the underlying data on disk.
34+
# * Continuing to write to the repository while it is in an invalid state may causing additional damage to its contents.
35+
# If the API finds any problems with the integrity of the contents of your repository, Elasticsearch will not be able to repair the damage.
36+
# The only way to bring the repository back into a fully working state after its contents have been damaged is by restoring its contents from a repository backup which was taken before the damage occurred.
37+
# You must also identify what caused the damage and take action to prevent it from happening again.
38+
# If you cannot restore a repository backup, register a new repository and use this for all future snapshot operations.
39+
# In some cases it may be possible to recover some of the contents of a damaged repository, either by restoring as many of its snapshots as needed and taking new snapshots of the restored data, or by using the reindex API to copy data from any searchable snapshots mounted from the damaged repository.
40+
# Avoid all operations which write to the repository while the verify repository integrity API is running.
41+
# If something changes the repository contents while an integrity verification is running then Elasticsearch may incorrectly report having detected some anomalies in its contents due to the concurrent writes.
42+
# It may also incorrectly fail to report some anomalies that the concurrent writes prevented it from detecting.
43+
# NOTE: This API is intended for exploratory use by humans. You should expect the request parameters and the response format to vary in future versions.
44+
# NOTE: This API may not work correctly in a mixed-version cluster.
45+
# The default values for the parameters of this API are designed to limit the impact of the integrity verification on other activities in your cluster.
46+
# For instance, by default it will only use at most half of the `snapshot_meta` threads to verify the integrity of each snapshot, allowing other snapshot operations to use the other half of this thread pool.
47+
# If you modify these parameters to speed up the verification process, you risk disrupting other snapshot-related operations in your cluster.
48+
# For large repositories, consider setting up a separate single-node Elasticsearch cluster just for running the integrity verification API.
49+
# The response exposes implementation details of the analysis which may change from version to version.
50+
# The response body format is therefore not considered stable and may be different in newer versions.
51+
# This functionality is Experimental and may be changed or removed
52+
# completely in a future release. Elastic will take a best effort approach
53+
# to fix any issues, but experimental features are not subject to the
54+
# support SLA of official GA features.
55+
#
56+
# @option arguments [String, Array<String>] :repository The name of the snapshot repository. (*Required*)
57+
# @option arguments [Integer] :blob_thread_pool_concurrency If `verify_blob_contents` is `true`, this parameter specifies how many blobs to verify at once. Server default: 1.
58+
# @option arguments [Integer] :index_snapshot_verification_concurrency The maximum number of index snapshots to verify concurrently within each index verification. Server default: 1.
59+
# @option arguments [Integer] :index_verification_concurrency The number of indices to verify concurrently.
60+
# The default behavior is to use the entire `snapshot_meta` thread pool. Server default: 0.
61+
# @option arguments [String] :max_bytes_per_sec If `verify_blob_contents` is `true`, this parameter specifies the maximum amount of data that Elasticsearch will read from the repository every second. Server default: 10mb.
62+
# @option arguments [Integer] :max_failed_shard_snapshots The number of shard snapshot failures to track during integrity verification, in order to avoid excessive resource usage.
63+
# If your repository contains more than this number of shard snapshot failures, the verification will fail. Server default: 10000.
64+
# @option arguments [Integer] :meta_thread_pool_concurrency The maximum number of snapshot metadata operations to run concurrently.
65+
# The default behavior is to use at most half of the `snapshot_meta` thread pool at once. Server default: 0.
66+
# @option arguments [Integer] :snapshot_verification_concurrency The number of snapshots to verify concurrently.
67+
# The default behavior is to use at most half of the `snapshot_meta` thread pool at once. Server default: 0.
68+
# @option arguments [Boolean] :verify_blob_contents Indicates whether to verify the checksum of every data blob in the repository.
69+
# If this feature is enabled, Elasticsearch will read the entire repository contents, which may be extremely slow and expensive.
70+
# @option arguments [Boolean] :error_trace When set to `true` Elasticsearch will include the full stack trace of errors
71+
# when they occur.
72+
# @option arguments [String] :filter_path Comma-separated list of filters in dot notation which reduce the response
73+
# returned by Elasticsearch.
74+
# @option arguments [Boolean] :human When set to `true` will return statistics in a format suitable for humans.
75+
# For example `"exists_time": "1h"` for humans and
76+
# `"eixsts_time_in_millis": 3600000` for computers. When disabled the human
77+
# readable values will be omitted. This makes sense for responses being consumed
78+
# only by machines.
79+
# @option arguments [Boolean] :pretty If set to `true` the returned JSON will be "pretty-formatted". Only use
80+
# this option for debugging only.
81+
# @option arguments [Hash] :headers Custom HTTP headers
82+
#
83+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-repository-verify-integrity
84+
#
85+
def repository_verify_integrity(arguments = {})
86+
request_opts = { endpoint: arguments[:endpoint] || 'snapshot.repository_verify_integrity' }
87+
88+
defined_params = [:repository].each_with_object({}) do |variable, set_variables|
89+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
90+
end
91+
request_opts[:defined_params] = defined_params unless defined_params.empty?
92+
93+
raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
94+
95+
arguments = arguments.clone
96+
headers = arguments.delete(:headers) || {}
97+
98+
body = nil
99+
100+
_repository = arguments.delete(:repository)
101+
102+
method = Elasticsearch::API::HTTP_POST
103+
path = "_snapshot/#{Utils.listify(_repository)}/_verify_integrity"
104+
params = Utils.process_params(arguments)
105+
106+
Elasticsearch::API::Response.new(
107+
perform_request(method, path, params, body, headers, request_opts)
108+
)
109+
end
110+
end
111+
end
112+
end
113+
end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
describe 'client.snapshot#repository_verify_integrity' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_snapshot/foo/_verify_integrity',
25+
{},
26+
nil,
27+
{},
28+
{ defined_params: { repository: 'foo' },
29+
endpoint: 'snapshot.repository_verify_integrity' }
30+
]
31+
end
32+
33+
it 'performs the request' do
34+
expect(client_double.snapshot.repository_verify_integrity(repository: 'foo')).to be_a Elasticsearch::API::Response
35+
end
36+
end

0 commit comments

Comments
 (0)