Skip to content

fixing edit locking for online dynamic clusters where setServerGroups() is called #1138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions core/src/main/python/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,10 @@ def __update_online(model, model_context, aliases):
raise de

# Server or Cluster may be added, this is to make sure they are targeted properly
topology_updater.set_server_groups()

# Calling set_server_groups has a side effect, it throws itself out of the edit tree.
# If it is not in edit tree then save in
# __check_update_require_domain_restart will fail
# Restart the edit session to compensate

try:
__wlst_helper.edit()
__wlst_helper.start_edit()
topology_updater.set_server_groups()
except BundleAwareException, ex:
deployer_utils.release_edit_session_and_disconnect()
raise ex

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def deploy(self):
self.__add_shared_libraries()
self.__add_applications()
else:
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(self.model_context.is_discard_current_edit())
self.__online_deploy_apps_and_libs(self._base_location)

def __add_shared_libraries(self):
Expand Down
13 changes: 4 additions & 9 deletions core/src/main/python/wlsdeploy/tool/util/target_helper.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""

import copy

import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict
from oracle.weblogic.deploy.exception import BundleAwareException

import wlsdeploy.util.dictionary_utils as dictionary_utils

Expand Down Expand Up @@ -251,11 +250,11 @@ def target_dynamic_server_groups(self, dynamic_cluster_assigns):

if len(dynamic_cluster_assigns) > 0:
# assign server group resources to cluster based on the version of WebLogic server version.
if self.wls_helper.is_dynamic_cluster_server_groups_supported():
if self.wls_helper.is_dynamic_cluster_multiple_server_groups_supported():
bug_map = self.save_dyn_size(dynamic_cluster_assigns)
self.target_server_groups(dynamic_cluster_assigns)
self.restore_dyn_size(bug_map)
elif self.wls_helper.is_dynamic_cluster_server_group_supported():
elif self.wls_helper.is_dynamic_cluster_one_server_group_supported():
bug_map = self.save_dyn_size(dynamic_cluster_assigns)
self.target_dynamic_clusters(dynamic_cluster_assigns)
self.restore_dyn_size(bug_map)
Expand Down Expand Up @@ -624,11 +623,7 @@ def __put_back_in_edit(self):
setServerGroups throws you out of edit. Put it back in.
"""
if self.model_context.is_wlst_online():
try:
self.wlst_helper.edit()
self.wlst_helper.start_edit()
except BundleAwareException, ex:
raise ex
self.wlst_helper.edit()

def __locate_dynamic_attribute(self, cluster):

Expand Down
11 changes: 9 additions & 2 deletions core/src/main/python/wlsdeploy/tool/util/wlst_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def is_restart_required(self):

def cancel_edit(self):
"""
Cancel current edit session
Cancel current edit session and discard all unsaved changes
"""
self.__load_global('cancelEdit')('y')

Expand Down Expand Up @@ -375,6 +375,10 @@ def set_server_groups(self, server, server_groups, timeout):
"""
Targets the list of server groups to the managed server.

WARNING: The online version of setServerGroups() does change out of the edit MBean
tree when complete. However, since we don't know the mode at this level, leave
it up to the caller to determine if moving back to the edit() tree is needed.

:param server: the name of the managed server
:param server_groups: the list of template-defined server groups to target to the server
:param timeout: the timeout for the setServerGroups command
Expand All @@ -384,7 +388,10 @@ def set_server_groups(self, server, server_groups, timeout):
self.__logger.entering(server_groups, server, timeout, class_name=self.__class_name, method_name=_method_name)

try:
self.__load_global('setServerGroups')(server, server_groups, timeout)
# In the WDT context, we never need online setServerGroups to acquire its own edit lock.
# As such, always pass true for skipEdit.
#
self.__load_global('setServerGroups')(serverName=server, serverGroups=server_groups, timeout=timeout, skipEdit=True)
except (self.__load_global('WLSTException'), offlineWLSTException), e:
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00023', server_groups, server,
_format_exception(e), error=e)
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/python/wlsdeploy/util/weblogic_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ def is_dynamic_clusters_supported(self):
"""
return self.is_weblogic_version_or_above('12.1.2')

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

def is_dynamic_cluster_server_groups_supported(self):
def is_dynamic_cluster_multiple_server_groups_supported(self):
"""
Is the version of WLST one that supports targeting one server group to dynamic cluster?
:return: true if within the versions supporting the above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ void test14OnlineUpdate1(TestInfo testInfo) throws Exception {
+ " -oracle_home " + mwhome_12213
+ " -domain_home " + domainParentDir + FS + "jrfDomain1"
+ " -model_file " + model
+ " -domain_type JRF"
+ " -admin_url t3://localhost:7001 -admin_user weblogic";
CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out);

Expand Down Expand Up @@ -441,6 +442,7 @@ void test15OnlineUpdate2(TestInfo testInfo) throws Exception {
+ " -oracle_home " + mwhome_12213
+ " -domain_home " + domainParentDir + FS + "jrfDomain1"
+ " -model_file " + model
+ " -domain_type JRF"
+ " -admin_url t3://localhost:7001 -admin_user weblogic"
+ " -cancel_changes_if_restart_required";
CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.

topology:
ConsoleEnabled: false
ConsoleEnabled: false
Cluster:
cluster1:
DynamicServers:
DynamicClusterSize: 4
MaxDynamicClusterSize: 4
11 changes: 5 additions & 6 deletions system-test/src/test/resources/simple-topology2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ domainInfo:
rcu_db_conn_string: '%DB_HOST%:1521/InfraPDB1.us.oracle.com'
topology:
Name: domain1
AdminServerName: 'admin-server'
AdminServerName: admin-server
ProductionModeEnabled: true
Cluster:
cluster1:
Expand All @@ -18,20 +18,19 @@ topology:
DynamicServers:
ServerTemplate: template1
CalculatedListenPorts: true
ServerNamePrefix: 'ms-'
ServerNamePrefix: ms-
DynamicClusterSize: 2
MaxDynamicClusterSize: 2
Server:
'admin-server':
admin-server:
ListenPort: 7001
ServerTemplate:
template1:
ListenPort: 8001
appDeployments:
Application:
# Quote needed because of hyphen in string
'simple-app':
SourcePath: 'wlsdeploy/applications/simple-app.war'
simple-app:
SourcePath: wlsdeploy/applications/simple-app.war
Target: cluster1
ModuleType: war
StagingMode: nostage
Expand Down