Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Fix bug where backup operation does not complete successfully (#60)
Browse files Browse the repository at this point in the history
* Fix an infinite loop in the backup operation logic
  • Loading branch information
sdford authored Aug 3, 2017
1 parent d10f2dc commit d9c16f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

group=com.nike
artifactId=cerberus-lifecycle-cli
version=3.1.0
version=3.1.1
16 changes: 11 additions & 5 deletions src/main/java/com/nike/cerberus/client/CerberusAdminClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.SSLException;
import java.io.IOException;
Expand All @@ -46,6 +48,8 @@
*/
public class CerberusAdminClient extends VaultAdminClient {

private final Logger log = LoggerFactory.getLogger(getClass());

protected OkHttpClient httpClient;
protected VaultCredentialsProvider credentialsProvider;
protected UrlResolver vaultUrlResolver;
Expand Down Expand Up @@ -84,7 +88,7 @@ public void restoreMetadata(String jsonPayload) {
}
}

public SdbMetadataResult getSDBMetaData(String offset, String limit) {
public SdbMetadataResult getSDBMetaData(int offset, int limit) {
URL baseUrl = null;
try {
baseUrl = new URL(vaultUrlResolver.resolve());
Expand All @@ -96,8 +100,8 @@ public SdbMetadataResult getSDBMetaData(String offset, String limit) {
.scheme(baseUrl.getProtocol())
.host(baseUrl.getHost())
.addPathSegments("v1/metadata")
.addQueryParameter("limit", limit)
.addQueryParameter("offset", offset)
.addQueryParameter("limit", String.valueOf(limit))
.addQueryParameter("offset", String.valueOf(offset))
.build();

Response response = execute(url, HttpMethod.GET, null);
Expand All @@ -112,11 +116,13 @@ public SdbMetadataResult getSDBMetaData(String offset, String limit) {
public List<SafeDepositBox> getAllSdbMetadata() {
List<SafeDepositBox> sdbMetadataList = new LinkedList<>();
SdbMetadataResult currentResult = null;
String offset = "0";
String limit = "100";
int offset = 0;
int limit = 100;
do {
currentResult = getSDBMetaData(offset, limit);
sdbMetadataList.addAll(currentResult.getSafeDepositBoxMetadata());
offset = currentResult.getNextOffset();
log.info("Retrieved metadata for {} SDBs", currentResult.getSdbCountInResult());
} while (currentResult.hasNext());

return sdbMetadataList;
Expand Down

0 comments on commit d9c16f2

Please sign in to comment.