Skip to content

Commit 930e3c8

Browse files
authored
Cloudstack 4.11.3.0 shapeblue1 (#15)
* Fixed: IP address of Shared Network VR is not persistent when VR is destroyed/recreated * Clean up DHCP/DNS config on VM expunge and on detaching a VM * increase DHCP lease to ~infinite * To handle deletion w/ expunge of VM with interfaces in Isolated and shared networks * client: fix for jetty session timeout * ui: fix migrate host form no host popup * removed the cloud-plugin-network-vsp dependency * Refactored code * Removed unused imports * Refactored the code * Usage event to store zone id while uploading template * refactored code
1 parent d895983 commit 930e3c8

File tree

11 files changed

+42
-33
lines changed

11 files changed

+42
-33
lines changed

client/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,6 @@
207207
<artifactId>cloud-plugin-network-vcs</artifactId>
208208
<version>${project.version}</version>
209209
</dependency>
210-
<dependency>
211-
<groupId>org.apache.cloudstack</groupId>
212-
<artifactId>cloud-plugin-network-vsp</artifactId>
213-
<version>${project.version}</version>
214-
</dependency>
215210
<dependency>
216211
<groupId>org.apache.cloudstack</groupId>
217212
<artifactId>cloud-plugin-hypervisor-xenserver</artifactId>

client/src/org/apache/cloudstack/ServerDaemon.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@
4040
import org.eclipse.jetty.server.handler.MovedContextHandler;
4141
import org.eclipse.jetty.server.handler.RequestLogHandler;
4242
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
43+
import org.eclipse.jetty.server.session.SessionHandler;
4344
import org.eclipse.jetty.util.ssl.SslContextFactory;
4445
import org.eclipse.jetty.util.thread.QueuedThreadPool;
4546
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
4647
import org.eclipse.jetty.webapp.WebAppContext;
4748
import org.slf4j.Logger;
4849
import org.slf4j.LoggerFactory;
4950

51+
import com.cloud.utils.Pair;
5052
import com.cloud.utils.PropertiesUtil;
5153
import com.google.common.base.Strings;
5254

@@ -170,7 +172,8 @@ public void start() throws Exception {
170172
server.addConnector(httpConnector);
171173

172174
// Setup handlers
173-
server.setHandler(createHandlers());
175+
Pair<SessionHandler,HandlerCollection> pair = createHandlers();
176+
server.setHandler(pair.second());
174177

175178
// Extra config options
176179
server.setStopAtShutdown(true);
@@ -198,6 +201,8 @@ public void start() throws Exception {
198201
}
199202

200203
server.start();
204+
// Must set the session timeout after the server has started
205+
pair.first().setMaxInactiveInterval(sessionTimeout * 60);
201206
server.join();
202207
}
203208

@@ -215,11 +220,10 @@ public void destroy() {
215220
/////////////// Private methods ///////////////////
216221
///////////////////////////////////////////////////
217222

218-
private HandlerCollection createHandlers() {
223+
private Pair<SessionHandler,HandlerCollection> createHandlers() {
219224
final WebAppContext webApp = new WebAppContext();
220225
webApp.setContextPath(contextPath);
221226
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
222-
webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60);
223227

224228
// GZIP handler
225229
final GzipHandler gzipHandler = new GzipHandler();
@@ -238,14 +242,14 @@ private HandlerCollection createHandlers() {
238242
final RequestLogHandler log = new RequestLogHandler();
239243
log.setRequestLog(createRequestLog());
240244

241-
// Redirect root context handler
245+
// Redirect root context handler_war
242246
MovedContextHandler rootRedirect = new MovedContextHandler();
243247
rootRedirect.setContextPath("/");
244248
rootRedirect.setNewContextURL(contextPath);
245249
rootRedirect.setPermanent(true);
246250

247251
// Put rootRedirect at the end!
248-
return new HandlerCollection(log, gzipHandler, rootRedirect);
252+
return new Pair<>(webApp.getSessionHandler(), new HandlerCollection(log, gzipHandler, rootRedirect));
249253
}
250254

251255
private RequestLog createRequestLog() {

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,9 +1951,18 @@ protected void removeNic(final VirtualMachineProfile vm, final NicVO nic) {
19511951
}
19521952
}
19531953

1954+
final NetworkVO network = _networksDao.findById(nic.getNetworkId());
1955+
if (network != null && network.getTrafficType() == TrafficType.Guest) {
1956+
final String nicIp = Strings.isNullOrEmpty(nic.getIPv4Address()) ? nic.getIPv6Address() : nic.getIPv4Address();
1957+
if (!Strings.isNullOrEmpty(nicIp)) {
1958+
NicProfile nicProfile = new NicProfile(nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress());
1959+
nicProfile.setId(nic.getId());
1960+
cleanupNicDhcpDnsEntry(network, vm, nicProfile);
1961+
}
1962+
}
1963+
19541964
nic.setState(Nic.State.Deallocating);
19551965
_nicDao.update(nic.getId(), nic);
1956-
final NetworkVO network = _networksDao.findById(nic.getNetworkId());
19571966
final NicProfile profile = new NicProfile(nic, network, null, null, null, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(
19581967
vm.getHypervisorType(), network));
19591968

plugins/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
<module>network-elements/palo-alto</module>
7878
<module>network-elements/netscaler</module>
7979
<module>network-elements/nicira-nvp</module>
80-
<module>network-elements/nuage-vsp</module>
8180
<module>network-elements/bigswitch</module>
8281
<module>network-elements/brocade-vcs</module>
8382
<module>network-elements/stratosphere-ssp</module>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,6 +2302,9 @@ public NicVO getPlaceholderNicForRouter(Network network, Long podId) {
23022302
ipv6 = _ipv6Dao.findByNetworkIdAndIp(network.getId(), nic.getIPv6Address());
23032303
}
23042304
//return nic only when its ip address belong to the pod range (for the Basic zone case)
2305+
if (vlans.isEmpty()) {
2306+
return nic;
2307+
}
23052308
for (Vlan vlan : vlans) {
23062309
if (ip != null && ip.getVlanId() == vlan.getId()) {
23072310
return nic;

server/src/com/cloud/network/element/VirtualRouterElement.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,6 @@ public VirtualRouterProvider getCreatedElement(final long id) {
895895
@Override
896896
public boolean release(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final ReservationContext context) throws ConcurrentOperationException,
897897
ResourceUnavailableException {
898-
removeDhcpEntry(network, nic, vm);
899898
return true;
900899
}
901900

server/src/com/cloud/network/router/CommandSetupHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ private NicVO findDefaultDnsIp(final long userVmId) {
10621062
final NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
10631063

10641064
// check if DNS provider is the domR
1065-
if (!_networkModel.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
1065+
if (defaultNic == null || !_networkModel.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
10661066
return null;
10671067
}
10681068

server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import javax.inject.Inject;
2626
import javax.naming.ConfigurationException;
2727

28+
import com.cloud.api.query.dao.TemplateJoinDao;
29+
import com.cloud.api.query.vo.TemplateJoinVO;
2830
import com.cloud.configuration.Resource;
2931
import com.cloud.event.EventTypes;
3032
import com.cloud.event.UsageEventUtils;
@@ -102,6 +104,8 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto
102104
private AlertManager _alertMgr;
103105
@Inject
104106
private VMTemplateZoneDao _vmTemplateZoneDao;
107+
@Inject
108+
private TemplateJoinDao _templateJoinDao;
105109

106110
private long _nodeId;
107111
private ScheduledExecutorService _executor = null;
@@ -313,7 +317,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
313317

314318
// publish usage events
315319
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_UPLOAD, tmpVolume.getAccountId(),
316-
tmpVolumeDataStore.getDataStoreId(), tmpVolume.getId(), tmpVolume.getName(),
320+
tmpVolume.getDataCenterId(), tmpVolume.getId(), tmpVolume.getName(),
317321
null, null, tmpVolumeDataStore.getPhysicalSize(), tmpVolumeDataStore.getSize(),
318322
Volume.class.getName(), tmpVolume.getUuid());
319323

@@ -402,9 +406,10 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
402406
if (tmpTemplate.getFormat() == Storage.ImageFormat.ISO) {
403407
etype = EventTypes.EVENT_ISO_CREATE;
404408
}
405-
UsageEventUtils.publishUsageEvent(etype, tmpTemplate.getAccountId(), tmpTemplateDataStore.getDataStoreId(), tmpTemplate.getId(), tmpTemplate.getName(), null, null,
406-
tmpTemplateDataStore.getPhysicalSize(), tmpTemplateDataStore.getSize(), VirtualMachineTemplate.class.getName(), tmpTemplate.getUuid());
407-
409+
TemplateJoinVO vo = _templateJoinDao.findById(tmpTemplate.getId());
410+
assert (vo != null) : "Couldn't find the template view for given template ID";
411+
UsageEventUtils.publishUsageEvent(etype, tmpTemplate.getAccountId(), vo.getDataCenterId(), tmpTemplate.getId(), tmpTemplate.getName(), null, null,
412+
tmpTemplateDataStore.getPhysicalSize(), tmpTemplateDataStore.getSize(), VirtualMachineTemplate.class.getName(), tmpTemplate.getUuid());
408413
if (s_logger.isDebugEnabled()) {
409414
s_logger.debug("Template " + tmpTemplate.getUuid() + " uploaded successfully");
410415
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@
302302
import com.cloud.vm.snapshot.VMSnapshotManager;
303303
import com.cloud.vm.snapshot.VMSnapshotVO;
304304
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
305-
import com.google.common.base.Strings;
306305

307306

308307
public class UserVmManagerImpl extends ManagerBase implements UserVmManager, VirtualMachineGuru, UserVmService, Configurable {
@@ -4382,12 +4381,6 @@ public void finalizeStop(VirtualMachineProfile profile, Answer answer) {
43824381
for (final NicVO nic : nics) {
43834382
final NetworkVO network = _networkDao.findById(nic.getNetworkId());
43844383
if (network != null && network.getTrafficType() == TrafficType.Guest) {
4385-
final String nicIp = Strings.isNullOrEmpty(nic.getIPv4Address()) ? nic.getIPv6Address() : nic.getIPv4Address();
4386-
if (!Strings.isNullOrEmpty(nicIp)) {
4387-
NicProfile nicProfile = new NicProfile(nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress());
4388-
nicProfile.setId(nic.getId());
4389-
_networkMgr.cleanupNicDhcpDnsEntry(network, profile, nicProfile);
4390-
}
43914384
if (nic.getBroadcastUri() != null && nic.getBroadcastUri().getScheme().equals("pvlan")) {
43924385
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic");
43934386
setupVmForPvlan(false, vm.getHostId(), nicProfile);

systemvm/debian/opt/cloud/bin/cs/CsDhcp.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,15 @@ def write_hosts(self):
159159

160160
def add(self, entry):
161161
self.add_host(entry['ipv4_address'], entry['host_name'])
162-
# lease time boils down to once a month
163-
# with a splay of 60 hours to prevent storms
164-
lease = randint(700, 760)
162+
# Lease time set to effectively infinite (36000+ days) since we properly control all DHCP/DNS config via CloudStack.
163+
# Infinite time helps avoid some edge cases which could cause DHCPNAK being sent to VMs since
164+
# (RHEL) system lose routes when they receive DHCPNAK.
165+
# When VM is expunged, its active lease and DHCP/DNS config is properly removed from related files in VR,
166+
# so the infinite duration of lease does not cause any issues or garbage.
167+
# There will be soon a PR which also regenerates the /var/lib/misc/dnsmasq.leases (active lease DB file)
168+
# in the new VR (when restarting network with cleanup), which will help around RHEL edge cases (described above)
169+
# for the VMs who are already running in productions systems with 30d lease time.
170+
lease = randint(870000, 870010)
165171

166172
if entry['default_entry']:
167173
self.cloud.add("%s,%s,%s,%sh" % (entry['mac_address'],

0 commit comments

Comments
 (0)