Skip to content

Commit 97d8ff1

Browse files
authored
Wdt 412 (#616)
* fix missing return code for online update after refactoring * rename function * correct logic * add return code to share.sh * update documentation with new return code * correct side effect after calling setServerGroups * add doc and update script * remove 101, 102 return code, no where is returning it * Add online system tests * remove unused test and increase start server time * Remove fake network channel
1 parent 256ed92 commit 97d8ff1

File tree

15 files changed

+282
-32
lines changed

15 files changed

+282
-32
lines changed

core/src/main/python/update.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,25 @@ def __update_online(model, model_context, aliases):
144144
__release_edit_session_and_disconnect()
145145
raise de
146146

147-
exit_code = 0
148-
147+
# Server or Cluster may be added, this is to make sure they are targeted properly
149148
topology_updater.set_server_groups()
150-
__update_online_domain(model_context)
151-
model_deployer.deploy_applications(model, model_context, aliases, wlst_mode=__wlst_mode)
149+
150+
# Calling set_server_groups has a side effect, it throws itself out of the edit tree.
151+
# If it is not in edit tree then save in
152+
# __check_update_require_domain_restart will fail
153+
# Restart the edit session to compensate
154+
155+
try:
156+
__wlst_helper.edit()
157+
__wlst_helper.start_edit()
158+
except BundleAwareException, ex:
159+
raise ex
160+
161+
exit_code = __check_update_require_domain_restart(model_context)
162+
# if user requested rollback if restart required stops
163+
164+
if exit_code != CommandLineArgUtil.PROG_ROLLBACK_IF_RESTART_EXIT_CODE:
165+
model_deployer.deploy_applications(model, model_context, aliases, wlst_mode=__wlst_mode)
152166

153167
try:
154168
__wlst_helper.disconnect()
@@ -160,7 +174,8 @@ def __update_online(model, model_context, aliases):
160174
return exit_code
161175

162176

163-
def __update_online_domain(model_context):
177+
def __check_update_require_domain_restart(model_context):
178+
exit_code = 0
164179
try:
165180
# First we enable the stdout again and then redirect the stdoout to a string output stream
166181
# call isRestartRequired to get the output, capture the string and then silence wlst output again
@@ -185,6 +200,8 @@ def __update_online_domain(model_context):
185200
__release_edit_session_and_disconnect()
186201
raise ex
187202

203+
return exit_code
204+
188205

189206
def __update_offline(model, model_context, aliases):
190207
"""

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class CommandLineArgUtil(object):
102102
USAGE_ERROR_EXIT_CODE = 99
103103
ARG_VALIDATION_ERROR_EXIT_CODE = 98
104104
PROG_RESTART_REQUIRED = 103
105-
PROG_ROLLBACK_IF_RESTART_EXIT_CODE = 3
105+
PROG_ROLLBACK_IF_RESTART_EXIT_CODE = 104
106106
PROG_ERROR_EXIT_CODE = 2
107107
PROG_WARNING_EXIT_CODE = 1
108108
PROG_OK_EXIT_CODE = 0

installer/src/main/bin/deployApps.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ ECHO [-model_file ^<model_file^>]
7777
ECHO [-variable_file ^<variable_file^>]
7878
ECHO [-domain_type ^<domain_type^>]
7979
ECHO [-wlst_path ^<wlst_path^>]
80+
ECHO [-rollback_if_require_restart]
8081
ECHO [-admin_url ^<admin_url^>
8182
ECHO -admin_user ^<admin_user^>
8283
ECHO ]
@@ -110,6 +111,8 @@ ECHO admin_url - the admin server URL (used for online deploy)
110111
ECHO.
111112
ECHO admin_user - the admin username (used for online deploy)
112113
ECHO.
114+
ECHO rollback_if_require_restart - rollback the changes if the update requires domain restart
115+
ECHO.
113116
ECHO The -use_encryption switch tells the program that one or more of the
114117
ECHO passwords in the model or variables files are encrypted. The program will
115118
ECHO prompt for the decryption passphrase to use to decrypt the passwords.

installer/src/main/bin/deployApps.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ usage() {
3838
echo " [-variable_file <variable_file>]"
3939
echo " [-domain_type <domain_type>]"
4040
echo " [-wlst_path <wlst_path>]"
41+
echo " [-rollback_if_require_restart]"
4142
echo " [-admin_url <admin_url>"
4243
echo " -admin_user <admin_user>"
4344
echo " ]"
@@ -71,6 +72,8 @@ usage() {
7172
echo ""
7273
echo " admin_user - the admin username (used for online deploy)"
7374
echo ""
75+
echo " rollback_if_require_restart - rollback the changes if the update requires domain restart"
76+
echo ""
7477
echo " The -use_encryption switch tells the program that one or more of the"
7578
echo " passwords in the model or variables files are encrypted. The program will"
7679
echo " prompt for the decryption passphrase to use to decrypt the passwords."

installer/src/main/bin/shared.cmd

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,14 @@ GOTO :EOF
300300

301301
SET RETURN_CODE=%1
302302

303-
IF "%RETURN_CODE%" == "103" (
303+
IF "%RETURN_CODE%" == "104" (
304304
ECHO.
305-
ECHO %SCRIPT_NAME% completed successfully but the domain requires a restart for the changes to take effect ^(exit code = %RETURN_CODE%^)
305+
ECHO %SCRIPT_NAME% completed successfully but the domain changes have been rolled back because -rollback_if_require_restart is specified ^(exit code = %RETURN_CODE%^)
306306
EXIT /B %RETURN_CODE%
307307
)
308-
IF "%RETURN_CODE%" == "102" (
309-
ECHO.
310-
ECHO %SCRIPT_NAME% completed successfully but the affected servers require a restart ^(exit code = %RETURN_CODE%^)
311-
EXIT /B %RETURN_CODE%
312-
)
313-
IF "%RETURN_CODE%" == "101" (
308+
IF "%RETURN_CODE%" == "103" (
314309
ECHO.
315-
ECHO %SCRIPT_NAME% was unable to complete due to configuration changes that require a domain restart. Please restart the domain and re-invoke the %SCRIPT_NAME% script with the same arguments ^(exit code = %RETURN_CODE%^)
310+
ECHO %SCRIPT_NAME% completed successfully but the domain requires a restart for the changes to take effect ^(exit code = %RETURN_CODE%^)
316311
EXIT /B %RETURN_CODE%
317312
)
318313
IF "%RETURN_CODE%" == "100" (

installer/src/main/bin/shared.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,12 @@ checkExitCode() {
274274

275275
returnCode=$1
276276

277-
if [ $returnCode -eq 103 ]; then
277+
if [ $returnCode -eq 104 ]; then
278278
echo ""
279-
echo "$scriptName completed successfully but the domain requires a restart for the changes to take effect (exit code = ${RETURN_CODE})"
280-
elif [ $returnCode -eq 102 ]; then
281-
echo ""
282-
echo "$scriptName completed successfully but the affected servers require a restart (exit code = ${RETURN_CODE})"
283-
elif [ $returnCode -eq 101 ]; then
279+
echo "$scriptName completed successfully but the domain changes have been rolled back because -rollback_if_require_restart is specified (exit code = ${RETURN_CODE})"
280+
elif [ $returnCode -eq 103 ]; then
284281
echo ""
285-
echo "$scriptName was unable to complete due to configuration changes that require a domain restart. Please restart the domain and re-invoke the $scriptName script with the same arguments (exit code = ${RETURN_CODE})"
282+
echo "$scriptName completed successfully but the domain requires a restart for the changes to take effect (exit code = ${RETURN_CODE})"
286283
elif [ $returnCode -eq 100 ]; then
287284
usage `basename $0`
288285
elif [ $returnCode -eq 99 ]; then

installer/src/main/bin/updateDomain.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ ECHO [-model_file ^<model_file^>]
7777
ECHO [-variable_file ^<variable_file^>]
7878
ECHO [-domain_type ^<domain_type^>]
7979
ECHO [-wlst_path ^<wlst_path^>]
80+
ECHO [-rollback_if_require_restart]
8081
ECHO [-admin_url ^<admin_url^>
8182
ECHO -admin_user ^<admin_user^>
8283
ECHO ]
@@ -110,6 +111,8 @@ ECHO admin_url - the admin server URL (used for online deploy)
110111
ECHO.
111112
ECHO admin_user - the admin username (used for online deploy)
112113
ECHO.
114+
ECHO rollback_if_require_restart - rollback the changes if the update requires domain restart
115+
ECHO.
113116
ECHO The -use_encryption switch tells the program that one or more of the
114117
ECHO passwords in the model or variables files are encrypted. The program will
115118
ECHO prompt for the decryption passphrase to use to decrypt the passwords.

installer/src/main/bin/updateDomain.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ usage() {
3838
echo " [-variable_file <variable_file>]"
3939
echo " [-domain_type <domain_type>]"
4040
echo " [-wlst_path <wlst_path>]"
41+
echo " [-rollback_if_require_restart]"
4142
echo " [-admin_url <admin_url>"
4243
echo " -admin_user <admin_user>"
4344
echo " ]"
@@ -71,6 +72,8 @@ usage() {
7172
echo ""
7273
echo " admin_user - the admin username (used for online deploy)"
7374
echo ""
75+
echo " rollback_if_require_restart - rollback the changes if the update requires domain restart"
76+
echo ""
7477
echo " The -use_encryption switch tells the program that one or more of the"
7578
echo " passwords in the model or variables files are encrypted. The program will"
7679
echo " prompt for the decryption passphrase to use to decrypt the passwords."

site/deploy.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ As usual, the tool will prompt for the password (it can also be supplied by pipi
2525

2626
When running the tool in WLST online mode, the deploy operation may require server restarts or a domain restart to pick up the changes. The deploy operation can also encounter situations where it cannot complete its operation until the domain is restarted. To communicate these conditions to scripts that may be calling the Deploy Applications Tool, the shell scripts have three special, non-zero exit codes to communicate these states:
2727

28-
- `101` - The domain needs to be restarted and the Deploy Applications Tool needs to be re-invoked with the same arguments.
29-
- `102` - The servers impacted by the deploy operation need to be restarted, in a rolling fashion, starting with the Administration Server, if applicable.
3028
- `103` - The entire domain needs to be restarted.
29+
- `104` - The domain changes have been rolled back because the changes in the model requires a domain restart and -rollback_if_require_restart is specified.
3130

3231
### Using Multiple Models
3332

site/update.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ The Update Domain Tool will not attempt to recreate or add schemas for the RCU d
2020

2121
When running the tool in WLST online mode, the update operation may require server restarts or a domain restart to pick up the changes. The update operation can also encounter situations where it cannot complete its operation until the domain is restarted. To communicate these conditions to scripts that may be calling the Update Domain Tool, the shell scripts have three special, non-zero exit codes to communicate these states:
2222

23-
- `101` - The domain needs to be restarted and the Update Domain Tool needs to be re-invoked with the same arguments.
24-
- `102` - The servers impacted by the update operation need to be restarted, in a rolling fashion, starting with the Administration Server, if applicable.
2523
- `103` - The entire domain needs to be restarted.
24+
- `104` - The domain changes have been rolled back because the changes in the model requires a domain restart and -rollback_if_require_restart is specified.
2625

2726
### Using Multiple Models
2827

0 commit comments

Comments
 (0)