Skip to content

Commit 3a6f4b9

Browse files
fixing edit locking for online dynamic clusters where setServerGroup() is called (#1138)
1 parent 088b5bf commit 3a6f4b9

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

core/src/main/python/update.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,10 @@ def __update_online(model, model_context, aliases):
155155
raise de
156156

157157
# Server or Cluster may be added, this is to make sure they are targeted properly
158-
topology_updater.set_server_groups()
159-
160-
# Calling set_server_groups has a side effect, it throws itself out of the edit tree.
161-
# If it is not in edit tree then save in
162-
# __check_update_require_domain_restart will fail
163-
# Restart the edit session to compensate
164-
165158
try:
166-
__wlst_helper.edit()
167-
__wlst_helper.start_edit()
159+
topology_updater.set_server_groups()
168160
except BundleAwareException, ex:
161+
deployer_utils.release_edit_session_and_disconnect()
169162
raise ex
170163

171164
try:

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def deploy(self):
6262
self.__add_shared_libraries()
6363
self.__add_applications()
6464
else:
65-
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(self.model_context.is_discard_current_edit())
6665
self.__online_deploy_apps_and_libs(self._base_location)
6766

6867
def __add_shared_libraries(self):

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
"""
2-
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2017, 2022, 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

66
import copy
77

88
import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict
9-
from oracle.weblogic.deploy.exception import BundleAwareException
109

1110
import wlsdeploy.util.dictionary_utils as dictionary_utils
1211

@@ -251,11 +250,11 @@ def target_dynamic_server_groups(self, dynamic_cluster_assigns):
251250

252251
if len(dynamic_cluster_assigns) > 0:
253252
# assign server group resources to cluster based on the version of WebLogic server version.
254-
if self.wls_helper.is_dynamic_cluster_server_groups_supported():
253+
if self.wls_helper.is_dynamic_cluster_multiple_server_groups_supported():
255254
bug_map = self.save_dyn_size(dynamic_cluster_assigns)
256255
self.target_server_groups(dynamic_cluster_assigns)
257256
self.restore_dyn_size(bug_map)
258-
elif self.wls_helper.is_dynamic_cluster_server_group_supported():
257+
elif self.wls_helper.is_dynamic_cluster_one_server_group_supported():
259258
bug_map = self.save_dyn_size(dynamic_cluster_assigns)
260259
self.target_dynamic_clusters(dynamic_cluster_assigns)
261260
self.restore_dyn_size(bug_map)
@@ -624,11 +623,7 @@ def __put_back_in_edit(self):
624623
setServerGroups throws you out of edit. Put it back in.
625624
"""
626625
if self.model_context.is_wlst_online():
627-
try:
628-
self.wlst_helper.edit()
629-
self.wlst_helper.start_edit()
630-
except BundleAwareException, ex:
631-
raise ex
626+
self.wlst_helper.edit()
632627

633628
def __locate_dynamic_attribute(self, cluster):
634629

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def is_restart_required(self):
259259

260260
def cancel_edit(self):
261261
"""
262-
Cancel current edit session
262+
Cancel current edit session and discard all unsaved changes
263263
"""
264264
self.__load_global('cancelEdit')('y')
265265

@@ -375,6 +375,10 @@ def set_server_groups(self, server, server_groups, timeout):
375375
"""
376376
Targets the list of server groups to the managed server.
377377
378+
WARNING: The online version of setServerGroups() does change out of the edit MBean
379+
tree when complete. However, since we don't know the mode at this level, leave
380+
it up to the caller to determine if moving back to the edit() tree is needed.
381+
378382
:param server: the name of the managed server
379383
:param server_groups: the list of template-defined server groups to target to the server
380384
:param timeout: the timeout for the setServerGroups command
@@ -384,7 +388,10 @@ def set_server_groups(self, server, server_groups, timeout):
384388
self.__logger.entering(server_groups, server, timeout, class_name=self.__class_name, method_name=_method_name)
385389

386390
try:
387-
self.__load_global('setServerGroups')(server, server_groups, timeout)
391+
# In the WDT context, we never need online setServerGroups to acquire its own edit lock.
392+
# As such, always pass true for skipEdit.
393+
#
394+
self.__load_global('setServerGroups')(serverName=server, serverGroups=server_groups, timeout=timeout, skipEdit=True)
388395
except (self.__load_global('WLSTException'), offlineWLSTException), e:
389396
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00023', server_groups, server,
390397
_format_exception(e), error=e)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ def is_dynamic_clusters_supported(self):
103103
"""
104104
return self.is_weblogic_version_or_above('12.1.2')
105105

106-
def is_dynamic_cluster_server_group_supported(self):
106+
def is_dynamic_cluster_one_server_group_supported(self):
107107
"""
108108
Is the version of WLST one that supports targeting one server group to dynamic cluster?
109109
:return: true if within the versions supporting the above
110110
"""
111111
return self.is_weblogic_version_or_above('12.2.1.1') and not self.is_weblogic_version_or_above('12.2.1.4')
112112

113-
def is_dynamic_cluster_server_groups_supported(self):
113+
def is_dynamic_cluster_multiple_server_groups_supported(self):
114114
"""
115115
Is the version of WLST one that supports targeting one server group to dynamic cluster?
116116
:return: true if within the versions supporting the above

system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ void test14OnlineUpdate1(TestInfo testInfo) throws Exception {
400400
+ " -oracle_home " + mwhome_12213
401401
+ " -domain_home " + domainParentDir + FS + "jrfDomain1"
402402
+ " -model_file " + model
403+
+ " -domain_type JRF"
403404
+ " -admin_url t3://localhost:7001 -admin_user weblogic";
404405
CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out);
405406

@@ -441,6 +442,7 @@ void test15OnlineUpdate2(TestInfo testInfo) throws Exception {
441442
+ " -oracle_home " + mwhome_12213
442443
+ " -domain_home " + domainParentDir + FS + "jrfDomain1"
443444
+ " -model_file " + model
445+
+ " -domain_type JRF"
444446
+ " -admin_url t3://localhost:7001 -admin_user weblogic"
445447
+ " -cancel_changes_if_restart_required";
446448
CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out);

system-test/src/test/resources/simple-topology-onlineUpdate.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

44
topology:
5-
ConsoleEnabled: false
5+
ConsoleEnabled: false
6+
Cluster:
7+
cluster1:
8+
DynamicServers:
9+
DynamicClusterSize: 4
10+
MaxDynamicClusterSize: 4

system-test/src/test/resources/simple-topology2.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ domainInfo:
99
rcu_db_conn_string: '%DB_HOST%:1521/InfraPDB1.us.oracle.com'
1010
topology:
1111
Name: domain1
12-
AdminServerName: 'admin-server'
12+
AdminServerName: admin-server
1313
ProductionModeEnabled: true
1414
Cluster:
1515
cluster1:
@@ -18,20 +18,19 @@ topology:
1818
DynamicServers:
1919
ServerTemplate: template1
2020
CalculatedListenPorts: true
21-
ServerNamePrefix: 'ms-'
21+
ServerNamePrefix: ms-
2222
DynamicClusterSize: 2
2323
MaxDynamicClusterSize: 2
2424
Server:
25-
'admin-server':
25+
admin-server:
2626
ListenPort: 7001
2727
ServerTemplate:
2828
template1:
2929
ListenPort: 8001
3030
appDeployments:
3131
Application:
32-
# Quote needed because of hyphen in string
33-
'simple-app':
34-
SourcePath: 'wlsdeploy/applications/simple-app.war'
32+
simple-app:
33+
SourcePath: wlsdeploy/applications/simple-app.war
3534
Target: cluster1
3635
ModuleType: war
3736
StagingMode: nostage

0 commit comments

Comments
 (0)