Skip to content

Commit 478eae8

Browse files
committed
CLOUDSTACK-3947: Override getSyncObjType and getSyncObjId in CreateLBStickinessPolicyCmd.java to prevent concurrent operations on Loadbalancer in a network
(cherry picked from commit d571b49)
1 parent 6982535 commit 478eae8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.cloudstack.api.APICommand;
2323
import org.apache.cloudstack.api.ApiConstants;
2424
import org.apache.cloudstack.api.ApiErrorCode;
25+
import org.apache.cloudstack.api.BaseAsyncCmd;
2526
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
2627
import org.apache.cloudstack.api.Parameter;
2728
import org.apache.cloudstack.api.ServerApiException;
@@ -30,6 +31,7 @@
3031
import org.apache.log4j.Logger;
3132

3233
import com.cloud.event.EventTypes;
34+
import com.cloud.exception.InvalidParameterValueException;
3335
import com.cloud.exception.NetworkRuleConflictException;
3436
import com.cloud.exception.ResourceAllocationException;
3537
import com.cloud.exception.ResourceUnavailableException;
@@ -156,5 +158,18 @@ public String getEventDescription() {
156158
return "creating a Load Balancer Stickiness policy: " + getLBStickinessPolicyName();
157159
}
158160

161+
@Override
162+
public String getSyncObjType() {
163+
return BaseAsyncCmd.networkSyncObject;
164+
}
165+
166+
@Override
167+
public Long getSyncObjId() {
168+
LoadBalancer lb = _lbService.findById(getLbRuleId());
169+
if (lb == null) {
170+
throw new InvalidParameterValueException("Unable to find load balancer rule " + getLbRuleId() + " to create stickiness rule");
171+
}
172+
return lb.getNetworkId();
173+
}
159174
}
160175

0 commit comments

Comments
 (0)