DaanHoogland commented on a change in pull request #4616:
URL: https://github.com/apache/cloudstack/pull/4616#discussion_r600815199
##########
File path:
api/src/main/java/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
##########
@@ -110,19 +111,31 @@ public String getEventType() {
@Override
public void execute() {
Account owner = _accountService.getAccount(getEntityOwnerId());
- boolean result = _ravService.removeVpnUser(owner.getId(), userName,
CallContext.current().getCallingAccount());
+ long ownerId = owner.getId();
+ boolean result = _ravService.removeVpnUser(ownerId, userName,
CallContext.current().getCallingAccount());
if (!result) {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed
to remove vpn user");
+ String errorMessage = String.format("Failed to remove VPN
user=[%s]. VPN owner id=[%s].", userName, ownerId);
+ s_logger.error(errorMessage);
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
errorMessage);
}
+ boolean appliedVpnUsers = false;
+
try {
- if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
"Failed to apply vpn user removal");
- }
- }catch (Exception ex) {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed
to remove vpn user due to resource unavailable");
+ appliedVpnUsers = _ravService.applyVpnUsers(ownerId, userName);
+ } catch (ResourceUnavailableException ex) {
+ String errorMessage = String.format("Failed to refresh VPN
user=[%s] due to resource unavailable. VPN owner id=[%s].", userName, ownerId);
+ s_logger.error(errorMessage, ex);
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
errorMessage, ex);
+ }
+
+ if (!appliedVpnUsers) {
+ String errorMessage = String.format("Failed to refresh VPN
user=[%s]. VPN owner id=[%s].", userName, ownerId);
+ s_logger.debug(errorMessage);
Review comment:
```suggestion
if(s_logger.isDebugEnabled()) {
String errorMessage = String.format("Failed to refresh VPN
user=[%s]. VPN owner id=[%s].", userName, ownerId);
s_logger.debug(errorMessage);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]