-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Deal with Storage Manager tech debt #13598
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
Open
DaanHoogland
wants to merge
1
commit into
main
Choose a base branch
from
ghi12316-storageManagerTechDebt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ | |
|
|
||
| import java.util.Collection; | ||
| import java.util.HashMap; | ||
| import java.util.Iterator; | ||
| import java.util.Map; | ||
|
|
||
|
|
||
|
|
@@ -31,7 +30,6 @@ | |
| import org.apache.cloudstack.api.response.ImageStoreResponse; | ||
| import org.apache.cloudstack.api.response.ZoneResponse; | ||
|
|
||
| import com.cloud.exception.DiscoveryException; | ||
| import com.cloud.storage.ImageStore; | ||
| import com.cloud.user.Account; | ||
|
|
||
|
|
@@ -79,11 +77,10 @@ public Long getZoneId() { | |
| public Map<String, String> getDetails() { | ||
| Map<String, String> detailsMap = null; | ||
| if (details != null && !details.isEmpty()) { | ||
| detailsMap = new HashMap<String, String>(); | ||
| detailsMap = new HashMap<>(); | ||
| Collection<?> props = details.values(); | ||
| Iterator<?> iter = props.iterator(); | ||
| while (iter.hasNext()) { | ||
| HashMap<String, String> detail = (HashMap<String, String>)iter.next(); | ||
| for (Object prop : props) { | ||
| HashMap<String, String> detail = (HashMap<String, String>) prop; | ||
| String key = detail.get("key"); | ||
| String value = detail.get("value"); | ||
| detailsMap.put(key, value); | ||
|
|
@@ -123,20 +120,15 @@ public long getEntityOwnerId() { | |
|
|
||
| @Override | ||
| public void execute(){ | ||
| try{ | ||
| ImageStore result = _storageService.discoverImageStore(getName(), getUrl(), getProviderName(), getZoneId(), getDetails()); | ||
| ImageStoreResponse storeResponse = null; | ||
| if (result != null) { | ||
| storeResponse = _responseGenerator.createImageStoreResponse(result); | ||
| storeResponse.setResponseName(getCommandName()); | ||
| storeResponse.setObjectName("imagestore"); | ||
| setResponseObject(storeResponse); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage"); | ||
| } | ||
| } catch (DiscoveryException ex) { | ||
| logger.warn("Exception: ", ex); | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); | ||
| ImageStore result = _storageService.discoverImageStore(getName(), getUrl(), getProviderName(), getZoneId(), getDetails()); | ||
| ImageStoreResponse storeResponse; | ||
| if (result != null) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| storeResponse = _responseGenerator.createImageStoreResponse(result); | ||
| storeResponse.setResponseName(getCommandName()); | ||
| storeResponse.setObjectName("imagestore"); | ||
| setResponseObject(storeResponse); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage"); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,15 +48,14 @@ | |
| import org.apache.cloudstack.api.response.ImageStoreResponse; | ||
|
|
||
| import com.cloud.exception.ConcurrentOperationException; | ||
| import com.cloud.exception.DiscoveryException; | ||
| import com.cloud.exception.InsufficientCapacityException; | ||
| import com.cloud.exception.NetworkRuleConflictException; | ||
| import com.cloud.exception.ResourceAllocationException; | ||
| import com.cloud.exception.ResourceUnavailableException; | ||
| import com.cloud.storage.ImageStore; | ||
|
|
||
| @APICommand(name = "addImageStoreS3", description = "Adds S3 Image Store", responseObject = ImageStoreResponse.class, since = "4.7.0", | ||
| requestHasSensitiveInfo = true, responseHasSensitiveInfo = false) | ||
| @APICommand(name = "addImageStoreS3", description = "Adds S3 Image Store", responseObject = ImageStoreResponse.class, | ||
| since = "4.7.0", responseHasSensitiveInfo = false) | ||
|
Comment on lines
+57
to
+58
|
||
| public final class AddImageStoreS3CMD extends BaseCmd implements ClientOptions { | ||
|
|
||
| private static final String s_name = "addImageStoreS3Response"; | ||
|
|
@@ -73,32 +72,32 @@ public final class AddImageStoreS3CMD extends BaseCmd implements ClientOptions { | |
| @Parameter(name = S3_BUCKET_NAME, type = STRING, required = true, description = "Name of the storage bucket") | ||
| private String bucketName; | ||
|
|
||
| @Parameter(name = S3_SIGNER, type = STRING, required = false, description = "Signer Algorithm to use, either S3SignerType or AWSS3V4SignerType") | ||
| @Parameter(name = S3_SIGNER, type = STRING, description = "Signer Algorithm to use, either S3SignerType or AWSS3V4SignerType") | ||
| private String signer; | ||
|
|
||
| @Parameter(name = S3_HTTPS_FLAG, type = BOOLEAN, required = false, description = "Use HTTPS instead of HTTP") | ||
| @Parameter(name = S3_HTTPS_FLAG, type = BOOLEAN, description = "Use HTTPS instead of HTTP") | ||
| private Boolean httpsFlag; | ||
|
|
||
| @Parameter(name = S3_CONNECTION_TIMEOUT, type = INTEGER, required = false, description = "Connection timeout (milliseconds)") | ||
| @Parameter(name = S3_CONNECTION_TIMEOUT, type = INTEGER, description = "Connection timeout (milliseconds)") | ||
| private Integer connectionTimeout; | ||
|
|
||
| @Parameter(name = S3_MAX_ERROR_RETRY, type = INTEGER, required = false, description = "Maximum number of times to retry on error") | ||
| @Parameter(name = S3_MAX_ERROR_RETRY, type = INTEGER, description = "Maximum number of times to retry on error") | ||
| private Integer maxErrorRetry; | ||
|
|
||
| @Parameter(name = S3_SOCKET_TIMEOUT, type = INTEGER, required = false, description = "Socket timeout (milliseconds)") | ||
| @Parameter(name = S3_SOCKET_TIMEOUT, type = INTEGER, description = "Socket timeout (milliseconds)") | ||
| private Integer socketTimeout; | ||
|
|
||
| @Parameter(name = S3_CONNECTION_TTL, type = INTEGER, required = false, description = "Connection TTL (milliseconds)") | ||
| @Parameter(name = S3_CONNECTION_TTL, type = INTEGER, description = "Connection TTL (milliseconds)") | ||
| private Integer connectionTtl; | ||
|
|
||
| @Parameter(name = S3_USE_TCP_KEEPALIVE, type = BOOLEAN, required = false, description = "Whether TCP keep-alive is used") | ||
| @Parameter(name = S3_USE_TCP_KEEPALIVE, type = BOOLEAN, description = "Whether TCP keep-alive is used") | ||
| private Boolean useTCPKeepAlive; | ||
|
|
||
| @Override | ||
| public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, | ||
| ResourceAllocationException, NetworkRuleConflictException { | ||
|
|
||
| Map<String, String> dm = new HashMap(); | ||
| Map<String, String> dm = new HashMap<>(); | ||
|
|
||
| dm.put(ApiConstants.S3_ACCESS_KEY, getAccessKey()); | ||
| dm.put(ApiConstants.SECRET_KEY, getSecretKey()); | ||
|
|
@@ -127,20 +126,15 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE | |
| dm.put(ApiConstants.S3_USE_TCP_KEEPALIVE, getUseTCPKeepAlive().toString()); | ||
| } | ||
|
|
||
| try{ | ||
| ImageStore result = _storageService.discoverImageStore(null, null, "S3", null, dm); | ||
| ImageStoreResponse storeResponse; | ||
| if (result != null) { | ||
| storeResponse = _responseGenerator.createImageStoreResponse(result); | ||
| storeResponse.setResponseName(getCommandName()); | ||
| storeResponse.setObjectName("imagestore"); | ||
| setResponseObject(storeResponse); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3 Image Store."); | ||
| } | ||
| } catch (DiscoveryException ex) { | ||
| logger.warn("Exception: ", ex); | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); | ||
| ImageStore result = _storageService.discoverImageStore(null, null, "S3", null, dm); | ||
| ImageStoreResponse storeResponse; | ||
| if (result != null) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| storeResponse = _responseGenerator.createImageStoreResponse(result); | ||
| storeResponse.setResponseName(getCommandName()); | ||
| storeResponse.setObjectName("imagestore"); | ||
| setResponseObject(storeResponse); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3 Image Store."); | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DaanHoogland can we invert the logic to reduce identation?