Skip to content

Commit 95011ca

Browse files
Wdt 476 timeouts (#733)
* WDT timeout configuration * Add configurable WDT timeouts
1 parent e54c6fe commit 95011ca

File tree

16 files changed

+269
-43
lines changed

16 files changed

+269
-43
lines changed

core/src/main/python/deploy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ def __deploy_online(model, model_context, aliases):
117117
admin_url = model_context.get_admin_url()
118118
admin_user = model_context.get_admin_user()
119119
admin_pwd = model_context.get_admin_password()
120+
timeout = model_context.get_model_config().get_connect_timeout()
120121

121-
__logger.info("WLSDPLY-09005", admin_url, method_name=_method_name, class_name=_class_name)
122+
__logger.info("WLSDPLY-09005", admin_url, timeout, method_name=_method_name, class_name=_class_name)
122123

123124
try:
124-
__wlst_helper.connect(admin_user, admin_pwd, admin_url)
125+
__wlst_helper.connect(admin_user, admin_pwd, admin_url, timeout)
125126
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(model_context.is_discard_current_edit())
126127
__wlst_helper.edit()
127128
__wlst_helper.start_edit()
@@ -156,7 +157,7 @@ def __deploy_online(model, model_context, aliases):
156157
exit_code = CommandLineArgUtil.PROG_ROLLBACK_IF_RESTART_EXIT_CODE
157158
else:
158159
__wlst_helper.save()
159-
__wlst_helper.activate()
160+
__wlst_helper.activate(model_context.get_model_config().get_activate_timeout())
160161
if restart_required:
161162
exit_code = CommandLineArgUtil.PROG_RESTART_REQUIRED
162163
except BundleAwareException, ex:

core/src/main/python/discover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def __connect_to_domain(model_context, helper):
246246
if __wlst_mode == WlstModes.ONLINE:
247247
try:
248248
helper.connect(model_context.get_admin_user(), model_context.get_admin_password(),
249-
model_context.get_admin_url())
249+
model_context.get_admin_url(), model_context.get_model_config().get_connect_timeout())
250250
except PyWLSTException, wlst_ex:
251251
ex = exception_helper.create_discover_exception('WLSDPLY-06001', model_context.get_admin_url(),
252252
model_context.get_admin_user(),

core/src/main/python/update.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@ def __update_online(model, model_context, aliases):
121121
admin_url = model_context.get_admin_url()
122122
admin_user = model_context.get_admin_user()
123123
admin_pwd = model_context.get_admin_password()
124+
timeout = model_context.get_model_config().get_connect_timeout()
124125

125-
__logger.info("WLSDPLY-09005", admin_url, method_name=_method_name, class_name=_class_name)
126+
__logger.info("WLSDPLY-09005", admin_url, timeout, method_name=_method_name, class_name=_class_name)
126127

127128
try:
128-
__wlst_helper.connect(admin_user, admin_pwd, admin_url)
129+
__wlst_helper.connect(admin_user, admin_pwd, admin_url, timeout)
129130
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(model_context.is_discard_current_edit())
130131
__wlst_helper.edit()
131132
__wlst_helper.start_edit()
@@ -193,7 +194,7 @@ def __check_update_require_domain_restart(model_context):
193194
exit_code = CommandLineArgUtil.PROG_ROLLBACK_IF_RESTART_EXIT_CODE
194195
else:
195196
__wlst_helper.save()
196-
__wlst_helper.activate()
197+
__wlst_helper.activate(model_context.get_model_config().get_activate_timeout())
197198
if restart_required:
198199
exit_code = CommandLineArgUtil.PROG_RESTART_REQUIRED
199200
except BundleAwareException, ex:

core/src/main/python/wlsdeploy/tool/deploy/applications_deployer.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -855,11 +855,13 @@ def __remove_lib_from_deployment(self, model_dict, lib_name):
855855
model_dict.pop(lib_name)
856856
return
857857

858-
def __stop_app(self, application_name, partition_name=None, timeout=None):
858+
def __stop_app(self, application_name, partition_name=None):
859859
_method_name = '__stop_app'
860860

861861
self.logger.info('WLSDPLY-09312', application_name, class_name=self._class_name, method_name=_method_name)
862-
progress = self.wlst_helper.stop_application(application_name, partition=partition_name, timeout=timeout)
862+
progress = self.wlst_helper.stop_application(
863+
application_name, partition=partition_name,
864+
timeout=self.model_context.get_model_config().get_stop_app_timeout())
863865
while progress.isRunning():
864866
continue
865867
if progress.isFailed():
@@ -872,11 +874,12 @@ def __start_app(self, application_name, partition_name=None):
872874
_method_name = '__start_app'
873875

874876
self.logger.info('WLSDPLY-09313', application_name, class_name=self._class_name, method_name=_method_name)
875-
self.wlst_helper.start_application(application_name, partition=partition_name)
877+
self.wlst_helper.start_application(application_name, partition=partition_name,
878+
timeout=self.model_context.get_model_config().get_start_app_timeout())
876879
return
877880

878881
def __undeploy_app(self, application_name, library_module='false', partition_name=None,
879-
resource_group_template=None, timeout=None, targets=None):
882+
resource_group_template=None, targets=None):
880883
_method_name = '__undeploy_app'
881884

882885
type_name = APPLICATION
@@ -891,15 +894,17 @@ def __undeploy_app(self, application_name, library_module='false', partition_nam
891894
method_name=_method_name)
892895

893896
self.wlst_helper.undeploy_application(application_name, libraryModule=library_module, partition=partition_name,
894-
resourceGroupTemplate=resource_group_template, timeout=timeout,
897+
resourceGroupTemplate=resource_group_template,
898+
timeout=self.model_context.get_model_config().get_undeploy_timeout(),
895899
targets=targets)
896900
return
897901

898902
def __redeploy_app(self, application_name):
899903
_method_name = '__redeploy_app'
900904

901905
self.logger.info('WLSDPLY-09315', application_name, class_name=self._class_name, method_name=_method_name)
902-
self.wlst_helper.redeploy_application(application_name)
906+
self.wlst_helper.redeploy_application(application_name,
907+
timeout=self.model_context.get_model_config().get_redeploy_timeout())
903908
return
904909

905910
def __deploy_model_libraries(self, model_libs, lib_location):
@@ -1026,6 +1031,7 @@ def __deploy_app_online(self, application_name, source_path, targets, plan=None,
10261031
if options is not None:
10271032
for key, value in options.iteritems():
10281033
kwargs[key] = value
1034+
kwargs['timeout'] = self.model_context.get_model_config().get_deploy_timeout()
10291035

10301036
self.logger.fine('WLSDPLY-09320', application_name, kwargs,
10311037
class_name=self._class_name, method_name=_method_name)

core/src/main/python/wlsdeploy/tool/util/target_helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def target_server_groups(self, server_assigns):
227227
server_name = self.wlst_helper.get_quoted_name_for_wlst(server)
228228
self.logger.info('WLSDPLY-12224', str(server_groups), server_name,
229229
class_name=self.__class_name, method_name=_method_name)
230-
self.wlst_helper.set_server_groups(server_name, server_groups)
230+
self.wlst_helper.set_server_groups(server_name, server_groups,
231+
self.model_context.get_model_config().get_set_server_grps_timeout())
231232

232233
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
233234

core/src/main/python/wlsdeploy/tool/util/wlst_helper.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,19 +369,20 @@ def modify_bootstrap_credentials(self, jps_configfile, username, password):
369369
raise pwe
370370
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)
371371

372-
def set_server_groups(self, server, server_groups):
372+
def set_server_groups(self, server, server_groups, timeout):
373373
"""
374374
Targets the list of server groups to the managed server.
375375
376376
:param server: the name of the managed server
377377
:param server_groups: the list of template-defined server groups to target to the server
378+
:param timeout: the timeout for the setServerGroups command
378379
:raises: Exception for the specified tool type: if a WLST error occurs
379380
"""
380381
_method_name = 'set_server_groups'
381-
self.__logger.entering(server_groups, server, class_name=self.__class_name, method_name=_method_name)
382+
self.__logger.entering(server_groups, server, timeout, class_name=self.__class_name, method_name=_method_name)
382383

383384
try:
384-
self.__load_global('setServerGroups')(server, server_groups)
385+
self.__load_global('setServerGroups')(server, server_groups, timeout)
385386
except (self.__load_global('WLSTException'), offlineWLSTException), e:
386387
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00023', server_groups, server,
387388
_format_exception(e), error=e)
@@ -763,21 +764,22 @@ def close_domain(self):
763764
raise pwe
764765
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)
765766

766-
def connect(self, username, password, url):
767+
def connect(self, username, password, url, timeout):
767768
"""
768769
Connect WLST to a WebLogic Server instance at the provided url with the provided credentials.
769770
:param username: WebLogic user name
770771
:param password: WebLogic password
771772
:param url: WebLogic Server URL
773+
:param timeout: Connect timeout
772774
:raises: Exception for the specified tool type: if a WLST error occurs
773775
"""
774776
_method_name = 'connect'
775-
self.__logger.entering(username, url, class_name=self.__class_name, method_name=_method_name)
777+
self.__logger.entering(username, url, timeout, class_name=self.__class_name, method_name=_method_name)
776778

777779
try:
778-
self.__load_global('connect')(username=username, password=password, url=url)
780+
self.__load_global('connect')(username=username, password=password, url=url, timeout=timeout)
779781
except self.__load_global('WLSTException'), e:
780-
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00047', username, url,
782+
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00047', username, url, timeout,
781783
self.__get_exception_mode(e), _format_exception(e), error=e)
782784
self.__logger.throwing(class_name=self.__class_name, method_name=_method_name, error=pwe)
783785
raise pwe
@@ -886,15 +888,16 @@ def save(self):
886888
raise pwe
887889
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)
888890

889-
def activate(self):
891+
def activate(self, timeout):
890892
"""
891893
Activate changes saved during the current edit session but not yet deployed.
894+
:param timeout: Timeout for the activate command
892895
:raises: Exception for the specified tool type: if a WLST error occurs
893896
"""
894897
_method_name = 'activate'
895-
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)
898+
self.__logger.entering(timeout, class_name=self.__class_name, method_name=_method_name)
896899
try:
897-
self.__load_global('activate')()
900+
self.__load_global('activate')(timeout)
898901
except self.__load_global('WLSTException'), e:
899902
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00053',
900903
_format_exception(e), error=e)

core/src/main/python/wlsdeploy/util/cla_helper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@
2626
from wlsdeploy.util import getcreds
2727
from wlsdeploy.util import model_helper
2828
from wlsdeploy.util import model_translator, path_utils
29+
from wlsdeploy.util import path_utils
30+
2931
from wlsdeploy.util import tool_exit
3032
from wlsdeploy.util import variables
3133
from wlsdeploy.util.cla_utils import CommandLineArgUtil
3234
from wlsdeploy.util.model_translator import FileToPython
3335

36+
3437
__logger = PlatformLogger('wlsdeploy.util')
3538
_class_name = 'cla_helper'
3639

core/src/main/python/wlsdeploy/util/cla_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
Module that handles command-line argument parsing and common validation.
@@ -88,6 +88,7 @@ class CommandLineArgUtil(object):
8888

8989
TARGET_SWITCH = '-target'
9090

91+
9192
# arguments that are true if specified, false if not
9293
BOOLEAN_SWITCHES = [
9394
ATTRIBUTES_ONLY_SWITCH,
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
"""
2+
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
3+
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
"""
5+
6+
from java.io import IOException
7+
from java.lang import Long
8+
from java.lang import NumberFormatException
9+
10+
from wlsdeploy.exception import exception_helper
11+
from wlsdeploy.logging.platform_logger import PlatformLogger
12+
from wlsdeploy.util import path_utils
13+
from wlsdeploy.util import string_utils
14+
15+
TOOL_PROPERTIES_FILE_NAME = 'tool.properties'
16+
17+
_logger = PlatformLogger('wlsdeploy.config')
18+
_class_name = 'ModelConfig'
19+
20+
# Tool Properties for configuration and default values if properties not loaded
21+
22+
# WLST TIMEOUT PROPERTIES
23+
CONNECT_TIMEOUT_PROP = 'connect.timeout'
24+
CONNECT_TIMEOUT_DEFAULT = '120000'
25+
ACTIVATE_TIMEOUT_PROP = 'activate.timeout'
26+
ACTIVATE_TIMEOUT_DEFAULT = '180000'
27+
DEPLOY_TIMEOUT_PROP = 'deploy.timeout'
28+
DEPLOY_TIMEOUT_DEFAULT = '180000'
29+
REDEPLOY_TIMEOUT_PROP = 'redeploy.timeout'
30+
REDEPLOY_TIMEOUT_DEFAULT = '180000'
31+
UNDEPLOY_TIMEOUT_PROP = 'undeploy.timeout'
32+
UNDEPLOY_TIMEOUT_DEFAULT = '180000'
33+
START_APP_TIMEOUT_PROP = 'start.application.timeout'
34+
START_APP_TIMEOUT_DEFAULT = '180000'
35+
STOP_APP_TIMEOUT_PROP = 'stop.application.timeout'
36+
STOP_APP_TIMEOUT_DEFAULT = '180000'
37+
SET_SERVER_GRPS_TIMEOUT_PROP = 'set.server.groups.timeout'
38+
SET_SERVER_GRPS_TIMEOUT_DEFAULT = '30000'
39+
40+
41+
class ModelConfiguration(object):
42+
"""
43+
This class encapsulates the tool properties used in configuring and tuning
44+
"""
45+
46+
def __init__(self, program_name):
47+
"""
48+
Load the properties from the tools.properties file and save the resulting dictionary
49+
:return:
50+
"""
51+
self._program_name = program_name
52+
self.__config_dict = _load_properties_file()
53+
54+
def get_connect_timeout(self):
55+
"""
56+
Return the connect timeout from tool properties.
57+
:return: connect timeout
58+
"""
59+
return self._get_from_dict(CONNECT_TIMEOUT_PROP, CONNECT_TIMEOUT_DEFAULT)
60+
61+
def get_activate_timeout(self):
62+
"""
63+
Return the activate timeout from tool properties.
64+
:return: activate timeout
65+
"""
66+
return self._get_from_dict_as_long(ACTIVATE_TIMEOUT_PROP, ACTIVATE_TIMEOUT_DEFAULT)
67+
68+
def get_deploy_timeout(self):
69+
"""
70+
Return the deploy timeout from tool properties.
71+
:return: deploy timeout
72+
"""
73+
return self._get_from_dict_as_long(DEPLOY_TIMEOUT_PROP, DEPLOY_TIMEOUT_DEFAULT)
74+
75+
def get_redeploy_timeout(self):
76+
"""
77+
Return the redeploy timeout from tool properties
78+
:return: redeploy timeout
79+
"""
80+
return self._get_from_dict_as_long(REDEPLOY_TIMEOUT_PROP, REDEPLOY_TIMEOUT_DEFAULT)
81+
82+
def get_undeploy_timeout(self):
83+
"""
84+
Return undeploy timeout from tool properties.
85+
:return: undeploy timeout
86+
"""
87+
return self._get_from_dict_as_long(UNDEPLOY_TIMEOUT_PROP, UNDEPLOY_TIMEOUT_DEFAULT)
88+
89+
def get_stop_app_timeout(self):
90+
"""
91+
Return stop application timeout from tool properties.
92+
:return: stop application timeout
93+
"""
94+
return self._get_from_dict_as_long(STOP_APP_TIMEOUT_PROP, STOP_APP_TIMEOUT_DEFAULT)
95+
96+
def get_start_app_timeout(self):
97+
"""
98+
Return start application timeout from tool properties.
99+
:return: start application timeout
100+
"""
101+
return self._get_from_dict_as_long(START_APP_TIMEOUT_PROP, START_APP_TIMEOUT_DEFAULT)
102+
103+
def get_set_server_grps_timeout(self):
104+
"""
105+
Return timeout value for setServerGroups from tool properties
106+
:return: set server groups timeout
107+
"""
108+
return self._get_from_dict_as_long(SET_SERVER_GRPS_TIMEOUT_PROP, SET_SERVER_GRPS_TIMEOUT_DEFAULT)
109+
110+
def _get_from_dict(self, name, default_value=None):
111+
_method_name = '_get_from_dict'
112+
_logger.entering(name, default_value, class_name=_class_name, method_name=_method_name)
113+
result = default_value
114+
if name in self.__config_dict:
115+
result = self.__config_dict[name]
116+
_logger.exiting(result=result, class_name=_class_name, method_name=_method_name)
117+
return result
118+
119+
def _get_from_dict_as_long(self, name, default_value=None):
120+
_method_name = '_get_from_dict_as_long'
121+
result = self._get_from_dict(name, default_value)
122+
try:
123+
result = Long(result).longValue()
124+
except NumberFormatException, nfe:
125+
_logger.warning('WLSDPLY-01571', result, name, self._program_name, default_value, nfe.getLocalizedMessage(),
126+
class_name=_class_name, method_name=_method_name)
127+
result = Long(default_value).longValue()
128+
return result
129+
130+
131+
def _load_properties_file():
132+
"""
133+
Load the properties from the WLSDEPLOY properties file into dictionary
134+
:return: tool config properties in dict format
135+
"""
136+
_method_name = 'load_properties_file'
137+
_logger.entering(class_name=_class_name, method_name=_method_name)
138+
wlsdeploy_path = path_utils.find_config_path(TOOL_PROPERTIES_FILE_NAME)
139+
result = None
140+
try:
141+
result = string_utils.load_properties(wlsdeploy_path)
142+
except IOException, ioe:
143+
_logger.warning('WLSDPLY-01570', wlsdeploy_path, ioe.getMessage(),
144+
class_name=_class_name, method_name=_method_name)
145+
_logger.exiting(class_name=_class_name, method_name=_method_name)
146+
return result

0 commit comments

Comments
 (0)