|
39 | 39 | import org.zstack.network.service.vip.VipVO_; |
40 | 40 | import org.zstack.tag.PatternedSystemTag; |
41 | 41 | import org.zstack.tag.TagManager; |
| 42 | +import org.zstack.core.upgrade.UpgradeGlobalConfig; |
42 | 43 | import org.zstack.utils.*; |
43 | 44 | import org.zstack.utils.function.ForEachFunction; |
44 | 45 | import org.zstack.utils.logging.CLogger; |
@@ -152,10 +153,22 @@ public APIMessage intercept(APIMessage msg) throws ApiMessageInterceptionExcepti |
152 | 153 | validate((APIGetCandidateVmNicsForLoadBalancerServerGroupMsg)msg); |
153 | 154 | } else if (msg instanceof APIChangeLoadBalancerBackendServerMsg) { |
154 | 155 | validate((APIChangeLoadBalancerBackendServerMsg)msg); |
| 156 | + } else if (msg instanceof APIDeleteLoadBalancerMsg) { |
| 157 | + validate((APIDeleteLoadBalancerMsg) msg); |
155 | 158 | } |
156 | 159 | return msg; |
157 | 160 | } |
158 | 161 |
|
| 162 | + private void validate(APIDeleteLoadBalancerMsg msg) { |
| 163 | + if (UpgradeGlobalConfig.GRAYSCALE_UPGRADE.value(Boolean.class)) { |
| 164 | + LoadBalancerVO lb = dbf.findByUuid(msg.getUuid(), LoadBalancerVO.class); |
| 165 | + if (lb != null && lb.getType() == LoadBalancerType.SLB) { |
| 166 | + throw new ApiMessageInterceptionException(argerr( |
| 167 | + "cannot delete the standalone load balancer[uuid:%s] during grayscale upgrade", msg.getUuid())); |
| 168 | + } |
| 169 | + } |
| 170 | + } |
| 171 | + |
159 | 172 | private void validate(APIDeleteAccessControlListMsg msg) { |
160 | 173 | /*List<String> refs = Q.New(LoadBalancerListenerACLRefVO.class).select(LoadBalancerListenerACLRefVO_.listenerUuid) |
161 | 174 | .eq(LoadBalancerListenerACLRefVO_.aclUuid, msg.getUuid()).isNull(LoadBalancerListenerACLRefVO_.serverGroupUuid).listValues(); |
|
0 commit comments