Skip to content

Commit 0a10128

Browse files
author
Likitha Shetty
committed
CLOUDSTACK-3715. Socket timeout error is observed in VMware setup if a VMware task (RelocateVM_Task, CloneVM_Task etc.) takes more than 10 minutes. Making this value configurable to allow admins to modify the timeout if required. It defaults to the current value i.e. 10 minutes.
1 parent 966db3c commit 0a10128

7 files changed

Lines changed: 39 additions & 3 deletions

File tree

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,7 @@ List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, l
6969

7070
public String getRootDiskController();
7171

72+
public int getVcenterSessionTimeout();
73+
7274
boolean isLegacyZone(long dcId);
7375
}

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
174174
int _additionalPortRangeStart;
175175
int _additionalPortRangeSize;
176176
int _routerExtraPublicNics = 2;
177+
int _vCenterSessionTimeout = 600000; // Timeout in milliseconds
177178

178179
String _reserveCpu = "false";
179180

@@ -276,6 +277,9 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
276277

277278
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
278279

280+
_vCenterSessionTimeout = NumbersUtil.parseInt(_configDao.getValue(Config.VmwareVcenterSessionTimeout.key()), 600) * 1000;
281+
s_logger.info("VmwareManagerImpl config - vmware.vcenter.session.timeout: " + _vCenterSessionTimeout);
282+
279283
_reserveCpu = _configDao.getValue(Config.VmwareReserveCpu.key());
280284
if(_reserveCpu == null || _reserveCpu.isEmpty()) {
281285
_reserveCpu = "false";
@@ -980,6 +984,11 @@ public String getRootDiskController() {
980984
return _rootDiskController;
981985
}
982986

987+
@Override
988+
public int getVcenterSessionTimeout() {
989+
return _vCenterSessionTimeout;
990+
}
991+
983992
@Override
984993
public List<Class<?>> getCommands() {
985994
List<Class<?>> cmdList = new ArrayList<Class<?>>();

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public static VmwareContext create(String vCenterAddress, String vCenterUserName
6363
s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
6464

6565
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
66+
vimClient.setVcenterSessionTimeout(s_vmwareMgr.getVcenterSessionTimeout());
6667
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
6768

6869
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);

‎plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageContextFactory.java‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,48 @@
1616
// under the License.
1717
package com.cloud.storage.resource;
1818

19+
import javax.annotation.PostConstruct;
20+
import javax.inject.Inject;
21+
1922
import org.apache.log4j.Logger;
2023

24+
import com.cloud.configuration.Config;
25+
import com.cloud.configuration.dao.ConfigurationDao;
2126
import com.cloud.hypervisor.vmware.util.VmwareClient;
2227
import com.cloud.hypervisor.vmware.util.VmwareContext;
2328
import com.cloud.hypervisor.vmware.util.VmwareContextPool;
29+
import com.cloud.utils.NumbersUtil;
2430

2531
public class VmwareSecondaryStorageContextFactory {
2632
private static final Logger s_logger = Logger.getLogger(VmwareSecondaryStorageContextFactory.class);
2733

2834
private static volatile int s_seq = 1;
2935

3036
private static VmwareContextPool s_pool;
37+
private static ConfigurationDao s_configDao;
38+
39+
@Inject ConfigurationDao _configDao;
3140

3241
public static void initFactoryEnvironment() {
3342
System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
3443
s_pool = new VmwareContextPool();
3544
}
3645

46+
@PostConstruct
47+
void init() {
48+
s_configDao = _configDao;
49+
}
50+
3751
public static VmwareContext create(String vCenterAddress, String vCenterUserName, String vCenterPassword) throws Exception {
3852
assert(vCenterAddress != null);
3953
assert(vCenterUserName != null);
4054
assert(vCenterPassword != null);
4155

4256
String serviceUrl = "https://" + vCenterAddress + "/sdk/vimService";
57+
int vCenterSessionTimeout = NumbersUtil.parseInt(s_configDao.getValue(Config.VmwareVcenterSessionTimeout.key()), 600) * 1000;
4358
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
44-
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
59+
vimClient.setVcenterSessionTimeout(vCenterSessionTimeout);
60+
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
4561
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
4662
assert(context != null);
4763

‎server/src/com/cloud/configuration/Config.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ public enum Config {
306306
VmwareRecycleHungWorker("Advanced", ManagementServer.class, Boolean.class, "vmware.recycle.hung.wokervm", "false", "Specify whether or not to recycle hung worker VMs", null),
307307
VmwareHungWorkerTimeout("Advanced", ManagementServer.class, Long.class, "vmware.hung.wokervm.timeout", "7200", "Worker VM timeout in seconds", null),
308308
VmwareEnableNestedVirtualization("Advanced", ManagementServer.class, Boolean.class, "vmware.nested.virtualization", "false", "When set to true this will enable nested virtualization when this is supported by the hypervisor", null),
309+
VmwareVcenterSessionTimeout("Advanced", ManagementServer.class, Long.class, "vmware.vcenter.session.timeout", "600", "VMware client timeout in seconds", null),
309310

310311
// Midonet
311312
MidoNetAPIServerAddress("Network", ManagementServer.class, String.class, "midonet.apiserver.address", "http://localhost:8081", "Specify the address at which the Midonet API server can be contacted (if using Midonet)", null),

‎vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ private static void trustAllHttpsCertificates() throws Exception {
111111
private VimPortType vimPort;
112112
private String serviceCookie;
113113
private final String SVC_INST_NAME = "ServiceInstance";
114+
private int vCenterSessionTimeout = 600000; // Timeout in milliseconds
114115

115116
private boolean isConnected = false;
116117

@@ -134,8 +135,8 @@ public void connect(String url, String userName, String password) throws Excepti
134135
ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
135136
ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
136137

137-
ctxt.put("com.sun.xml.internal.ws.request.timeout", 600000);
138-
ctxt.put("com.sun.xml.internal.ws.connect.timeout", 600000);
138+
ctxt.put("com.sun.xml.internal.ws.request.timeout", vCenterSessionTimeout);
139+
ctxt.put("com.sun.xml.internal.ws.connect.timeout", vCenterSessionTimeout);
139140

140141
ServiceContent serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF);
141142

@@ -699,4 +700,9 @@ public ManagedObjectReference getMoRefProp(ManagedObjectReference objMor, String
699700
}
700701
return propmor;
701702
}
703+
704+
public void setVcenterSessionTimeout(int vCenterSessionTimeout) {
705+
this.vCenterSessionTimeout = vCenterSessionTimeout;
706+
}
707+
702708
}

‎vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareContextFactory.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public static VmwareContext create(String vCenterAddress, String vCenterUserName
4848
s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
4949

5050
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
51+
vimClient.setVcenterSessionTimeout(600000); // Timeout in milliseconds
5152
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
5253

5354
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);

0 commit comments

Comments
 (0)