Skip to content

Commit ffeca8b

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-7209: handle the case when network fails to implement NoTransitionException, and null is returned to the caller stack. All caller methods should verify if the return value is null before processing it further.
1 parent 451e2ab commit ffeca8b

5 files changed

Lines changed: 25 additions & 4 deletions

File tree

engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,7 @@ public boolean startNetwork(long networkId, DeployDestination dest, ReservationC
24242424
// implement the network
24252425
s_logger.debug("Starting network " + network + "...");
24262426
Pair<NetworkGuru, NetworkVO> implementedNetwork = implementNetwork(networkId, dest, context);
2427-
if (implementedNetwork.first() == null) {
2427+
if (implementedNetwork== null || implementedNetwork.first() == null) {
24282428
s_logger.warn("Failed to start the network " + network);
24292429
return false;
24302430
} else {
@@ -3083,6 +3083,9 @@ public NicProfile createNicForVm(Network network, NicProfile requested, Reservat
30833083
//2) prepare nic
30843084
if (prepare) {
30853085
Pair<NetworkGuru, NetworkVO> implemented = implementNetwork(nic.getNetworkId(), dest, context);
3086+
if (implemented == null) {
3087+
throw new CloudRuntimeException("Failed to prepare the nic as a part of creating nic " + nic + " for vm "+ vm + " due to network " + network + " implement failure");
3088+
}
30863089
nic = prepareNic(vmProfile, dest, context, nic.getId(), implemented.second());
30873090
s_logger.debug("Nic is prepared successfully for vm " + vm + " in network " + network);
30883091
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# Just here to make the unit test not blow up

server/src/com/cloud/network/IpAddressManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,7 @@ public Ternary<Boolean, List<NetworkOfferingVO>, Network> doInTransaction(Transa
15971597
s_logger.debug("Implementing network " + guestNetwork + " as a part of network provision for persistent network");
15981598
try {
15991599
Pair<? extends NetworkGuru, ? extends Network> implementedNetwork = _networkMgr.implementNetwork(guestNetwork.getId(), dest, context);
1600-
if (implementedNetwork.first() == null) {
1600+
if (implementedNetwork == null || implementedNetwork.first() == null) {
16011601
s_logger.warn("Failed to implement the network " + guestNetwork);
16021602
}
16031603
guestNetwork = implementedNetwork.second();

server/src/com/cloud/network/NetworkServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ && areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))) {
13091309
ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), journal, callerUser, caller);
13101310
s_logger.debug("Implementing network " + network + " as a part of network provision for persistent network");
13111311
Pair<? extends NetworkGuru, ? extends Network> implementedNetwork = _networkMgr.implementNetwork(network.getId(), dest, context);
1312-
if (implementedNetwork.first() == null) {
1312+
if (implementedNetwork == null || implementedNetwork.first() == null) {
13131313
s_logger.warn("Failed to provision the network " + network);
13141314
}
13151315
network = implementedNetwork.second();

server/src/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4559,7 +4559,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
45594559
s_logger.debug("Implementing the network for account" + newNetwork + " as a part of" + " network provision for persistent networks");
45604560
try {
45614561
Pair<? extends NetworkGuru, ? extends Network> implementedNetwork = _networkMgr.implementNetwork(newNetwork.getId(), dest, context);
4562-
if (implementedNetwork.first() == null) {
4562+
if (implementedNetwork == null || implementedNetwork.first() == null) {
45634563
s_logger.warn("Failed to implement the network " + newNetwork);
45644564
}
45654565
newNetwork = implementedNetwork.second();

0 commit comments

Comments
 (0)