Skip to content

Commit 7c382e9

Browse files
committed
Merge branch 'wdt-776' into 'main'
Adding new mechanism to skip RCU drop schemas and other RCU-related cleanup See merge request weblogic-cloud/weblogic-deploy-tooling!1514
2 parents b3707be + d81e467 commit 7c382e9

File tree

8 files changed

+91
-47
lines changed

8 files changed

+91
-47
lines changed

core/src/main/java/oracle/weblogic/deploy/create/RCURunner.java

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public class RCURunner {
6262
private static final String COMPONENT_INFO_LOCATION_SWITCH = "-compInfoXMLLocation";
6363
private static final String STORAGE_LOCATION_SWITCH = "-storageXMLLocation";
6464

65-
private static final Pattern SCHEMA_DOES_NOT_EXIST_PATTERN = Pattern.compile("(ORA-01918|RCU-6013|ORA-12899)");
65+
private static final Pattern SCHEMA_DOES_NOT_EXIST_PATTERN = Pattern.compile("(ORA-01918|RCU-6013[^0-9])");
66+
private static final Pattern SCHEMA_ALREADY_EXISTS_PATTERN = Pattern.compile("RCU-6016[^0-9]");
6667

6768
private final File oracleHome;
6869
private final File javaHome;
@@ -236,7 +237,7 @@ public void setXmlLocations(String componentInfoLocation, String storageLocation
236237
* @param rcuSchemaPass the RCU database schema password to use for all RCU schemas
237238
* @throws CreateException if an error occurs with parameter validation or running RCU
238239
*/
239-
public void runRcu(String rcuSysPass, String rcuSchemaPass) throws CreateException {
240+
public void runRcu(String rcuSysPass, String rcuSchemaPass, boolean disableRcuDropSchema) throws CreateException {
240241
final String METHOD = "runRcu";
241242

242243
File rcuBinDir = new File(new File(oracleHome, "oracle_common"), "bin");
@@ -246,45 +247,50 @@ public void runRcu(String rcuSysPass, String rcuSchemaPass) throws CreateExcepti
246247
validateNonEmptyString(rcuSysPass, "rcu_sys_password", true);
247248
validateNonEmptyString(rcuSchemaPass, "rcu_schema_password", true);
248249

249-
Map<String, String> dropEnv = getRcuDropEnv();
250-
String[] scriptArgs = getCommandLineArgs(DROP_REPO_SWITCH);
251-
List<String> scriptStdinLines = getRcuDropStdinLines(rcuSysPass, rcuSchemaPass);
252-
ScriptRunner runner = new ScriptRunner(dropEnv, RCU_DROP_LOG_BASENAME);
253-
int exitCode;
254-
try {
255-
exitCode = runner.executeScript(rcuScript, scriptStdinLines, scriptArgs);
256-
} catch (ScriptRunnerException sre) {
257-
CreateException ce = new CreateException("WLSDPLY-12001", sre, CLASS, sre.getLocalizedMessage());
258-
LOGGER.throwing(CLASS, METHOD, ce);
259-
throw ce;
260-
}
261-
// RCU is stupid and RCU drop exits with exit code 1 if the schemas do not exist...sigh
262-
//
263-
264-
if (exitCode != 0 && !isSchemaNotExistError(runner)) {
265-
CreateException ce = new CreateException("WLSDPLY-12002", CLASS, exitCode, runner.getStdoutFileName());
266-
LOGGER.throwing(CLASS, METHOD, ce);
267-
throw ce;
250+
if (!disableRcuDropSchema) {
251+
Map<String, String> dropEnv = getRcuDropEnv();
252+
String[] scriptArgs = getCommandLineArgs(DROP_REPO_SWITCH);
253+
List<String> scriptStdinLines = getRcuDropStdinLines(rcuSysPass, rcuSchemaPass);
254+
ScriptRunner runner = new ScriptRunner(dropEnv, RCU_DROP_LOG_BASENAME);
255+
int exitCode;
256+
try {
257+
exitCode = runner.executeScript(rcuScript, scriptStdinLines, scriptArgs);
258+
} catch (ScriptRunnerException sre) {
259+
CreateException ce = new CreateException("WLSDPLY-12001", sre, CLASS, sre.getLocalizedMessage());
260+
LOGGER.throwing(CLASS, METHOD, ce);
261+
throw ce;
262+
}
263+
// RCU is stupid and RCU drop exits with exit code 1 if the schemas do not exist...sigh
264+
//
265+
if (exitCode != 0 && !isSchemaNotExistError(runner)) {
266+
CreateException ce = new CreateException("WLSDPLY-12002", CLASS, exitCode, runner.getStdoutFileName());
267+
LOGGER.throwing(CLASS, METHOD, ce);
268+
throw ce;
269+
}
268270
}
269271

270272
Map<String, String> createEnv = getRcuCreateEnv();
271-
scriptArgs = getCommandLineArgs(CREATE_REPO_SWITCH);
272-
scriptStdinLines = getRcuCreateStdinLines(rcuSysPass, rcuSchemaPass);
273-
runner = new ScriptRunner(createEnv, RCU_CREATE_LOG_BASENAME);
273+
String[] scriptArgs = getCommandLineArgs(CREATE_REPO_SWITCH);
274+
List<String> scriptStdinLines = getRcuCreateStdinLines(rcuSysPass, rcuSchemaPass);
275+
ScriptRunner runner = new ScriptRunner(createEnv, RCU_CREATE_LOG_BASENAME);
276+
int exitCode;
274277
try {
275278
exitCode = runner.executeScript(rcuScript, scriptStdinLines, scriptArgs);
276-
if (atpDB && exitCode != 0 && isSchemaNotExistError(runner)) {
277-
exitCode = 0;
278-
}
279279
} catch (ScriptRunnerException sre) {
280280
CreateException ce = new CreateException("WLSDPLY-12003", sre, CLASS, sre.getLocalizedMessage());
281281
LOGGER.throwing(CLASS, METHOD, ce);
282282
throw ce;
283283
}
284284
if (exitCode != 0) {
285-
CreateException ce = new CreateException("WLSDPLY-12002", CLASS, exitCode, runner.getStdoutFileName());
286-
LOGGER.throwing(CLASS, METHOD, ce);
287-
throw ce;
285+
if (disableRcuDropSchema && isSchemaAlreadyExistsError(runner)) {
286+
CreateException ce = new CreateException("WLSDPLY-12015", CLASS, rcuPrefix, runner.getStdoutFileName());
287+
LOGGER.throwing(CLASS, METHOD, ce);
288+
throw ce;
289+
} else {
290+
CreateException ce = new CreateException("WLSDPLY-12002", CLASS, exitCode, runner.getStdoutFileName());
291+
LOGGER.throwing(CLASS, METHOD, ce);
292+
throw ce;
293+
}
288294
}
289295
}
290296

@@ -424,6 +430,19 @@ private static boolean isSchemaNotExistError(ScriptRunner runner) {
424430
return schemaDoesNotExist;
425431
}
426432

433+
private static boolean isSchemaAlreadyExistsError(ScriptRunner runner) {
434+
List<String> stdoutBuffer = runner.getStdoutBuffer();
435+
boolean schemaAlreadyExists = false;
436+
for (String line : stdoutBuffer) {
437+
Matcher matcher = SCHEMA_ALREADY_EXISTS_PATTERN.matcher(line);
438+
if (matcher.find()) {
439+
schemaAlreadyExists = true;
440+
break;
441+
}
442+
}
443+
return schemaAlreadyExists;
444+
}
445+
427446
private static String quoteStringForCommandLine(String text, String textTypeName) throws CreateException {
428447
String result = validateNonEmptyString(text, textTypeName);
429448
return StringUtils.quoteString(result);

core/src/main/python/create.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
from wlsdeploy.aliases import model_constants
2929
from wlsdeploy.aliases.model_constants import DEFAULT_WLS_DOMAIN_NAME
3030
from wlsdeploy.aliases.model_constants import DOMAIN_NAME
31+
from wlsdeploy.aliases.model_constants import PATH_TO_RCU_DB_CONN
32+
from wlsdeploy.aliases.model_constants import PATH_TO_RCU_PREFIX
3133
from wlsdeploy.aliases.model_constants import TOPOLOGY
3234
from wlsdeploy.aliases.wlst_modes import WlstModes
3335
from wlsdeploy.exception import exception_helper
@@ -248,23 +250,21 @@ def validate_rcu_args_and_model(model_context, model, archive_helper, aliases):
248250
has_atpdbinfo = rcu_db_info.has_atpdbinfo()
249251
has_ssldbinfo = rcu_db_info.has_ssldbinfo()
250252

251-
_validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin, model,
252-
model_context)
253+
_validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin, model)
253254
else:
254-
if model_context.get_domain_typedef().required_rcu():
255+
if model_context.get_domain_typedef().requires_rcu():
255256
if not model_context.get_rcu_database() or not model_context.get_rcu_prefix():
256-
__logger.severe('WLSDPLY-12408', model_context.get_domain_type(), CommandLineArgUtil.RCU_DB_SWITCH,
257-
CommandLineArgUtil.RCU_PREFIX_SWITCH, class_name=_class_name, method_name=_method_name)
257+
__logger.severe('WLSDPLY-12408', model_context.get_domain_type(), PATH_TO_RCU_DB_CONN,
258+
PATH_TO_RCU_PREFIX, class_name=_class_name, method_name=_method_name)
258259
ex = exception_helper.create_create_exception('WLSDPLY-12408', model_context.get_domain_type(),
259-
CommandLineArgUtil.RCU_DB_SWITCH,
260-
CommandLineArgUtil.RCU_PREFIX_SWITCH)
260+
PATH_TO_RCU_DB_CONN, PATH_TO_RCU_PREFIX)
261261
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
262262
raise ex
263263

264264
return has_atpdbinfo, has_ssldbinfo
265265

266266

267-
def _validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin, model, model_context):
267+
def _validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin, model):
268268
_method_name = '_validate_atp_wallet_in_archive'
269269
if archive_helper and not is_regular_db:
270270
# 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet
@@ -307,7 +307,7 @@ def _precheck_rcu_connectivity(model_context, creator, rcu_db_info):
307307
_method_name = '_precheck_rcu_connectivity'
308308
domain_typename = model_context.get_domain_typedef().get_domain_type()
309309

310-
if model_context.get_domain_typedef().required_rcu() and not model_context.is_run_rcu() and 'STB' in \
310+
if model_context.get_domain_typedef().requires_rcu() and not model_context.is_run_rcu() and 'STB' in \
311311
model_context.get_domain_typedef().get_rcu_schemas():
312312
# how to create rcu_db_info ?
313313
db_conn_props = None
@@ -399,7 +399,7 @@ def main(model_context):
399399

400400
creator.create()
401401

402-
if model_context.get_domain_typedef().required_rcu():
402+
if model_context.get_domain_typedef().requires_rcu():
403403
if has_atp:
404404
atp_helper.fix_jps_config(rcu_db_info, model_context)
405405
elif has_ssl:

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,7 @@
450450
DOMAIN_NAME,
451451
ADMIN_SERVER_NAME
452452
]
453+
454+
# Model Path constants
455+
PATH_TO_RCU_DB_CONN = '%s:/%s/%s' % (DOMAIN_INFO, RCU_DB_INFO, RCU_DB_CONN)
456+
PATH_TO_RCU_PREFIX = '%s:/%s/%s' % (DOMAIN_INFO, RCU_DB_INFO, RCU_PREFIX)

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ def __run_rcu(self):
370370
rcu_storage_location = self.__extract_rcu_xml_file(RCU_STG_INFO, rcu_db_info.get_storage_location())
371371
runner.setXmlLocations(rcu_comp_info_location, rcu_storage_location)
372372

373-
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
373+
disable_rcu_drop_schema = self.model_context.get_model_config().get_disable_rcu_drop_schema() == 'true'
374+
runner.runRcu(rcu_sys_pass, rcu_schema_pass, disable_rcu_drop_schema)
374375
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
375376

376377
def _set_rcu_ssl_args_properties(self, ssl_conn_properties, rcu_db_info, keystore, keystore_type, truststore,
@@ -1182,7 +1183,7 @@ def __configure_fmw_infra_database(self):
11821183
self.logger.entering(class_name=self.__class_name, method_name=_method_name)
11831184

11841185
# only continue with RCU configuration for domain type that requires RCU.
1185-
if not self._domain_typedef.required_rcu():
1186+
if not self._domain_typedef.requires_rcu():
11861187
self.logger.finer('WLSDPLY-12249', class_name=self.__class_name, method_name=_method_name)
11871188
return
11881189

core/src/main/python/wlsdeploy/tool/create/domain_typedef.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def get_rcu_schemas(self):
233233
# resolution for create.py argument processing.
234234
return list(self._domain_typedef['rcuSchemas'])
235235

236-
def required_rcu(self):
236+
def requires_rcu(self):
237237
"""
238238
Test whether it requires RCU components.
239239
:return: true if it requires rcu components

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
WLST_EDIT_LOCK_EXCLUSIVE_DEFAULT = 'false'
4646
YAML_FILE_MAX_CODE_POINTS_PROP = 'yaml.max.file.size'
4747
YAML_FILE_MAX_CODE_POINTS_DEFAULT = '0'
48-
USE_DEPRECATION_EXIT_CODE_PROP="use.deprecation.exit.code"
49-
USE_DEPRECATION_EXIT_CODE_DEFAULT="false"
48+
USE_DEPRECATION_EXIT_CODE_PROP='use.deprecation.exit.code'
49+
USE_DEPRECATION_EXIT_CODE_DEFAULT='false'
50+
DISABLE_RCU_DROP_SCHEMA_PROP='disable.rcu.drop.schema'
51+
DISABLE_RCU_DROP_SCHEMA_DEFAULT='false'
5052

5153
# System Property overrides for WLST timeout properties
5254
SYS_PROP_PREFIX = 'wdt.config.'
@@ -165,13 +167,22 @@ def get_use_deprecation_exit_code(self):
165167
"""
166168
return self._get_from_dict(USE_DEPRECATION_EXIT_CODE_PROP, USE_DEPRECATION_EXIT_CODE_DEFAULT)
167169

170+
def get_disable_rcu_drop_schema(self):
171+
"""
172+
Returns the value to determine whether to disable RCU from dropping schemas if they exist.
173+
:return: the string 'true' or 'false' (default)
174+
"""
175+
return self._get_from_dict(DISABLE_RCU_DROP_SCHEMA_PROP, DISABLE_RCU_DROP_SCHEMA_DEFAULT)
176+
168177
def _get_from_dict(self, name, default_value=None):
169178
_method_name = '_get_from_dict'
170179
_logger.entering(name, default_value, class_name=_class_name, method_name=_method_name)
180+
171181
result = default_value
172182
if name in self.__config_dict:
173183
result = self.__config_dict[name]
174184
result = System.getProperty(SYS_PROP_PREFIX + name, result)
185+
175186
_logger.exiting(result=result, class_name=_class_name, method_name=_method_name)
176187
return result
177188

@@ -204,7 +215,7 @@ def _load_properties_file():
204215

205216
# Return an empty dict so that failing to load the tool.properties file does
206217
# not prevent the code above from working using the default values. The WLST
207-
# unit tests are depending on this behavior until they are refactored to all
218+
# unit tests depend on this behavior until they are refactored to all
208219
# copy the tool.properties file into the target/unit_tests/config directory
209220
# and setting the WDT_CUSTOM_CONFIG environment variable to point to it.
210221
#

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,7 @@ WLSDPLY-12011={0} failed to validate the {1} value because it was either empty o
13471347
WLSDPLY-12012={0} failed to run the post create domain script {1}: {2}
13481348
WLSDPLY-12013={0} received exit code {1} from the post create domain script {2}, see the post create domain script stdout file at {3} for more information about what happened
13491349
WLSDPLY-12014=Post create domain script {0} failed with exit code {1}, see the post create domain script stdout file at {2} for more information about what happened
1350+
WLSDPLY-12015={0} failed to create the RCU schemas because the schemas with RCU prefix {1} already exists and RCU drop schema was disabled. See the RCU stdout file at {2} for more information about what happened
13501351

13511352
# creator.py
13521353
WLSDPLY-12100=Creating {0} with the name {1}
@@ -1526,7 +1527,7 @@ WLSDPLY-12404=Failed to read the RCU SYS password input from the user: {0}
15261527
WLSDPLY-12405=Please enter the RCU Schema password
15271528
WLSDPLY-12406=Failed to read the RCU Schema password input from the user: {0}
15281529
WLSDPLY-12407={0} invoked with {1} argument but was missing the {2} argument
1529-
WLSDPLY-12408=Domain type {0} definition has RCU schemas defined so the {1} and {2} arguments are required
1530+
WLSDPLY-12408=Domain type {0} definition has RCU schemas defined so the {1} and {2} model attributes are required
15301531
WLSDPLY-12409={0} failed to create the domain: {1}
15311532
WLSDPLY-12410={0} failed to deploy the resources and applications to the domain: {1}
15321533
WLSDPLY-12411=The model file specified ATP database info without oracle.net.tns_admin directory but the archive does \

installer/src/main/lib/tool.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ yaml.max.file.size=0
2121
# no warnings/errors will exit with a non-zero exit code.
2222
#
2323
use.deprecation.exit.code=false
24+
#
25+
# If set to true and using -run_rcu argument to createDomain,
26+
# the RCU execution will skip trying to drop any existing
27+
# schemas with the same RCU prefix. If one or more of the
28+
# schemas already exist, RCU create and load schemas execution
29+
# will fail, causing createDomain itself to fail.
30+
#
31+
disable.rcu.drop.schema=false

0 commit comments

Comments
 (0)