|
8 | 8 |
|
9 | 9 | import org.apache.logging.log4j.LogManager;
|
10 | 10 | import org.apache.logging.log4j.Logger;
|
| 11 | +import org.elasticsearch.ResourceNotFoundException; |
11 | 12 | import org.elasticsearch.action.ActionListener;
|
12 | 13 | import org.elasticsearch.action.support.ActionFilters;
|
13 | 14 | import org.elasticsearch.action.support.master.TransportMasterNodeAction;
|
@@ -65,7 +66,13 @@ protected void masterOperation(final Task task, final GetSnapshotLifecycleAction
|
65 | 66 | final ActionListener<GetSnapshotLifecycleAction.Response> listener) {
|
66 | 67 | SnapshotLifecycleMetadata snapMeta = state.metaData().custom(SnapshotLifecycleMetadata.TYPE);
|
67 | 68 | if (snapMeta == null) {
|
68 |
| - listener.onResponse(new GetSnapshotLifecycleAction.Response(Collections.emptyList())); |
| 69 | + if (request.getLifecycleIds().length == 0) { |
| 70 | + listener.onResponse(new GetSnapshotLifecycleAction.Response(Collections.emptyList())); |
| 71 | + } else { |
| 72 | + listener.onFailure(new ResourceNotFoundException( |
| 73 | + "snapshot lifecycle policy or policies {} not found, no policies are configured", |
| 74 | + Arrays.toString(request.getLifecycleIds()))); |
| 75 | + } |
69 | 76 | } else {
|
70 | 77 | final Map<String, SnapshotLifecyclePolicyItem.SnapshotInProgress> inProgress;
|
71 | 78 | SnapshotsInProgress sip = state.custom(SnapshotsInProgress.TYPE);
|
@@ -100,7 +107,16 @@ protected void masterOperation(final Task task, final GetSnapshotLifecycleAction
|
100 | 107 | new SnapshotLifecyclePolicyItem(policyMeta, inProgress.get(policyMeta.getPolicy().getId()),
|
101 | 108 | slmStats.getMetrics().get(policyMeta.getPolicy().getId())))
|
102 | 109 | .collect(Collectors.toList());
|
103 |
| - listener.onResponse(new GetSnapshotLifecycleAction.Response(lifecycles)); |
| 110 | + if (lifecycles.size() == 0) { |
| 111 | + if (request.getLifecycleIds().length == 0) { |
| 112 | + listener.onResponse(new GetSnapshotLifecycleAction.Response(Collections.emptyList())); |
| 113 | + } else { |
| 114 | + listener.onFailure(new ResourceNotFoundException("snapshot lifecycle policy or policies {} not found", |
| 115 | + Arrays.toString(request.getLifecycleIds()))); |
| 116 | + } |
| 117 | + } else { |
| 118 | + listener.onResponse(new GetSnapshotLifecycleAction.Response(lifecycles)); |
| 119 | + } |
104 | 120 | }
|
105 | 121 | }
|
106 | 122 |
|
|
0 commit comments