Skip to content

Commit 3e4aaa0

Browse files
committed
Fix domain upgrade from 12214 to 1412 logic causing regular online update failure.
1 parent e19d8bc commit 3e4aaa0

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

operator/src/main/resources/scripts/mii-domain-upgrade.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import traceback
1212
from xml.dom.minidom import parse
13+
from java.lang import Boolean
1314

1415

1516
tmp_callerframerecord = inspect.stack()[0] # 0 represents this line # 1 represents line at caller
@@ -21,7 +22,10 @@
2122
from weblogic.management.configuration import LegalHelper
2223

2324
def checkIfSecureModeEnabledForDomain(domain, domain_version):
24-
trace("Checking secure mode")
25+
26+
# Caller only invoke this if the current pod version is greater than or 14.1.2.0 and existing domain
27+
28+
trace("Checking secure mode in existing domain")
2529
secureModeEnabled = False
2630
cd('/SecurityConfiguration/' + domain.getName())
2731
childs = ls(returnType='c', returnMap='true')
@@ -36,10 +40,22 @@ def checkIfSecureModeEnabledForDomain(domain, domain_version):
3640
#
3741
secureModeEnabled = domain.isProductionModeEnabled() and not LegalHelper.versionEarlierThan(domain_version, "14.1.2.0")
3842

43+
if isinstance(secureModeEnabled, str) or isinstance(secureModeEnabled, unicode):
44+
result = Boolean.valueOf(secureModeEnabled)
45+
else:
46+
result = secureModeEnabled
47+
3948
trace("Writing secure mode status as " + str(secureModeEnabled))
4049
fh = open('/tmp/mii_domain_upgrade.txt', 'w')
41-
fh.write(str(secureModeEnabled))
50+
if result:
51+
fh.write("True")
52+
else:
53+
fh.write("False")
4254
fh.close()
55+
if LegalHelper.versionEarlierThan(domain_version, "14.1.2.0"):
56+
fh = open('/tmp/mii_domain_before14120.txt', 'w')
57+
fh.write("True")
58+
fh.close()
4359

4460
trace("Checking existing domain at " + str(sys.argv[1]))
4561
try:

operator/src/main/resources/scripts/modelInImage.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,13 @@ createWLDomain() {
395395
# something changed in the wdt artifacts or wls version changed
396396
# create domain again
397397

398-
SECUREMODE_INJECTED=0
398+
DISABLE_SM_FOR_12214_NONSM_UPG=0
399399
if [ -f ${PRIMORDIAL_DOMAIN_ZIPPED} ] ; then
400400
checkSecureModeForUpgrade
401401
fi
402402

403403
if [ ${WDT_ARTIFACTS_CHANGED} -ne 0 ] || [ ${jdk_changed} -eq 1 ] \
404-
|| [ ${SECRETS_AND_ENV_CHANGED} -ne 0 ] || [ ${SECUREMODE_INJECTED} -eq 1 ] ; then
404+
|| [ ${SECRETS_AND_ENV_CHANGED} -ne 0 ] || [ ${DISABLE_SM_FOR_12214_NONSM_UPG} -eq 1 ] ; then
405405

406406
trace "Need to create domain ${WDT_DOMAIN_TYPE}"
407407
createModelDomain
@@ -816,12 +816,16 @@ checkSecureModeForUpgrade() {
816816
local MII_PASSPHRASE=$(cat ${RUNTIME_ENCRYPTION_SECRET_PASSWORD})
817817
encrypt_decrypt_domain_secret "decrypt" /tmp/miiupgdomain${DOMAIN_HOME} ${MII_PASSPHRASE}
818818
cd /tmp/miiupgdomain && base64 -d ${WLSDOMAIN_CONFIG_ZIPPED} > ${LOCAL_WLSDOMAIN_CONFIG_ZIP}.tmp && tar -pxzf ${LOCAL_WLSDOMAIN_CONFIG_ZIP}.tmp
819+
# reading existing domain to determine what the secure mode should be whether it is set or by default.
819820
# a file is written to a /tmp/mii_domain_upgrade.txt containing the status of SecureModeEnabled.
820821
${SCRIPTPATH}/wlst.sh ${SCRIPTPATH}/mii-domain-upgrade.py /tmp/miiupgdomain$DOMAIN_HOME || exitOrLoop
821822
# cd to an existing dir since we are deleting the /tmp/miiupgdomain
822823
cd /
823824
if [ -f /tmp/mii_domain_upgrade.txt ] && [ $(grep -i False /tmp/mii_domain_upgrade.txt | wc -l ) -gt 0 ] ; then
824-
SECUREMODE_INJECTED=1
825+
if [ -f /tmp/mii_domain_before14120.txt ] && [ $(grep -i True /tmp/mii_domain_before14120.txt | wc -l ) -gt 0 ] ; then
826+
# Set this so that the upgrade image only scenario 12.2.1.4 to 14.1.2 will recreate the domain
827+
DISABLE_SM_FOR_12214_NONSM_UPG=1
828+
fi
825829
fi
826830
rm -fr /tmp/miiupgdomain
827831
fi

operator/src/main/resources/scripts/model_wdt_mii_filter.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def customizeCoherenceMemberConfig(server, listen_address):
398398

399399
def upgradeServerIfNeeded(model):
400400
# The marker file is created earlier when the introspector checking if
401-
# the secure mode is enabled in the config.xml. This will compare with the incoming model
401+
# the secure mode should be false in the config.xml. This will compare with the incoming model
402402
# if secure mode is not set (or set to secure in option), then inject the secure mode
403403
# to false. This is done to maintain compatibility from 12.2.1* to 14.1.2 and the file
404404
# is only created when the deploy version is newer than or equals to 14.1.2
@@ -410,24 +410,34 @@ def upgradeServerIfNeeded(model):
410410
found = False
411411
if result == 'False':
412412
# check if model has anything set
413+
# if domainInfo already set to secure or in dev mode then do not set it, prod mode will not be secure
414+
# regardless of others
415+
# if the model disabled `ProductionModeEnabled` specifically now, do nothing
416+
417+
if 'domainInfo' in model and 'ServerStartMode' in model['domainInfo']:
418+
return
419+
413420
if 'topology' in model:
421+
414422
topology = model['topology']
423+
if 'ProductionModeEnabled' not in topology:
424+
return
425+
426+
if 'ProductionModeEnabled' in topology:
427+
value = topology['ProductionModeEnabled']
428+
if isinstance(value, str) or isinstance(value, unicode):
429+
prod_enabled = Boolean.valueOf(value)
430+
else:
431+
prod_enabled = value
432+
if not prod_enabled:
433+
return
415434

416435
if 'SecurityConfiguration' in topology:
417436
if 'SecureMode' in topology['SecurityConfiguration']:
418437
if 'SecureModeEnabled' in topology['SecurityConfiguration']['SecureMode']:
419438
found = True
420439

421440
if not found:
422-
# if domainInfo already set to secure or in dev mode then do not set it.
423-
if 'ServerStartMode' in model['domainInfo']:
424-
mode = model['domainInfo']['ServerStartMode']
425-
if mode == 'secure' or mode == 'dev':
426-
return
427-
# if the model disabled `ProductionModeEnabled` specifically now, do nothing
428-
if 'ProductionModeEnabled' in topology and topology['ProductionModeEnabled'] == False:
429-
return
430-
431441
if not 'SecurityConfiguration' in topology:
432442
topology['SecurityConfiguration'] = {}
433443
if not 'SecureMode' in topology['SecurityConfiguration']:

0 commit comments

Comments
 (0)