Skip to content

Commit 706af02

Browse files
WDT Warn instead of Exception on deleted app not found (#730)
1 parent 4c9ed91 commit 706af02

File tree

1 file changed

+69
-66
lines changed

1 file changed

+69
-66
lines changed

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

Lines changed: 69 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ def __add_shared_libraries(self):
101101

102102
if model_helper.is_delete_name(shared_library_name):
103103

104-
self.__verify_delete_versioned_app(shared_library_name, existing_shared_libraries, type='lib')
104+
if self.__verify_delete_versioned_app(shared_library_name, existing_shared_libraries, type='lib'):
105105

106-
location = LocationContext()
107-
location.append_location(model_constants.LIBRARY)
108-
existing_names = deployer_utils.get_existing_object_list(location, self.aliases)
109-
deployer_utils.delete_named_element(location, shared_library_name, existing_names, self.aliases)
106+
location = LocationContext()
107+
location.append_location(model_constants.LIBRARY)
108+
existing_names = deployer_utils.get_existing_object_list(location, self.aliases)
109+
deployer_utils.delete_named_element(location, shared_library_name, existing_names, self.aliases)
110110
continue
111111

112112
#
@@ -173,12 +173,12 @@ def __add_applications(self):
173173

174174
if model_helper.is_delete_name(application_name):
175175

176-
self.__verify_delete_versioned_app(application_name, existing_applications, type='app')
176+
if self.__verify_delete_versioned_app(application_name, existing_applications, type='app'):
177177

178-
location = LocationContext()
179-
location.append_location(model_constants.APPLICATION)
180-
existing_names = deployer_utils.get_existing_object_list(location, self.aliases)
181-
deployer_utils.delete_named_element(location, application_name, existing_names, self.aliases)
178+
location = LocationContext()
179+
location.append_location(model_constants.APPLICATION)
180+
existing_names = deployer_utils.get_existing_object_list(location, self.aliases)
181+
deployer_utils.delete_named_element(location, application_name, existing_names, self.aliases)
182182
continue
183183

184184
application = \
@@ -535,15 +535,15 @@ def __build_library_deploy_strategy(self, location, model_libs, existing_libs, e
535535

536536
if model_helper.is_delete_name(lib):
537537

538-
self.__verify_delete_versioned_app(lib, existing_libs, 'lib')
538+
if self.__verify_delete_versioned_app(lib, existing_libs, 'lib'):
539539

540-
if lib[1:] in existing_libs:
541-
model_libs.pop(lib)
542-
_add_ref_apps_to_stoplist(stop_app_list, existing_lib_refs, lib[1:])
543-
stop_and_undeploy_app_list.append(lib[1:])
544-
else:
545-
model_libs.pop(lib)
546-
stop_and_undeploy_app_list.append(lib[1:])
540+
if lib[1:] in existing_libs:
541+
model_libs.pop(lib)
542+
_add_ref_apps_to_stoplist(stop_app_list, existing_lib_refs, lib[1:])
543+
stop_and_undeploy_app_list.append(lib[1:])
544+
else:
545+
model_libs.pop(lib)
546+
stop_and_undeploy_app_list.append(lib[1:])
547547
continue
548548

549549
if lib in existing_libs:
@@ -612,12 +612,12 @@ def __build_app_deploy_strategy(self, location, model_apps, existing_apps, exist
612612

613613
if model_helper.is_delete_name(app):
614614

615-
self.__verify_delete_versioned_app(app, existing_apps, 'app')
615+
if self.__verify_delete_versioned_app(app, existing_apps, 'app'):
616616

617-
# remove the !app from the model
618-
self.__remove_app_from_deployment(model_apps, app)
619-
# undeploy the app (without !)
620-
stop_and_undeploy_app_list.append(app[1:])
617+
# remove the !app from the model
618+
self.__remove_app_from_deployment(model_apps, app)
619+
# undeploy the app (without !)
620+
stop_and_undeploy_app_list.append(app[1:])
621621
continue
622622

623623
if app in existing_apps:
@@ -679,17 +679,18 @@ def __verify_delete_versioned_app(self, app, existing_apps, type='app'):
679679
err_key_list = 'WLSDPLY-09331'
680680
err_key = 'WLSDPLY-09333'
681681

682+
found_app = True
682683
if not app[1:] in existing_apps:
684+
found_app = False
683685
tokens = re.split(r'[\#*\@*]', app[1:])
684686
re_expr = tokens[0] + '[\#*\@*]'
685687
r = re.compile(re_expr)
686688
matched_list = filter(r.match, existing_apps)
687689
if len(matched_list) > 0:
688-
ex = exception_helper.create_deploy_exception(err_key_list, app[1:], matched_list)
690+
self.logger.warning(err_key_list, app[1:], matched_list, self._class_name, method_name=_method_name)
689691
else:
690-
ex = exception_helper.create_deploy_exception(err_key, app[1:])
691-
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
692-
raise ex
692+
self.logger.warning(err_key, app[1:],self._class_name, method_name=_method_name)
693+
return found_app
693694

694695
def __get_uses_path_tokens_attribute_names(self, app_location):
695696
location = LocationContext(app_location)
@@ -808,22 +809,23 @@ def __deploy_model_libraries(self, model_libs, lib_location):
808809
location = LocationContext(lib_location)
809810
token_name = self.aliases.get_name_token(location)
810811
for lib_name in deploy_ordered_keys:
811-
lib_dict = model_libs[lib_name]
812-
src_path = dictionary_utils.get_element(lib_dict, SOURCE_PATH)
813-
plan_file = dictionary_utils.get_element(lib_dict, PLAN_PATH)
814-
targets = dictionary_utils.get_element(lib_dict, TARGET)
815-
options = _get_deploy_options(model_libs, lib_name, library_module='true')
816-
for uses_path_tokens_attribute_name in uses_path_tokens_attribute_names:
817-
if uses_path_tokens_attribute_name in lib_dict:
818-
self.__extract_file_from_archive(lib_dict[uses_path_tokens_attribute_name])
819-
820-
location.add_name_token(token_name, lib_name)
821-
resource_group_template_name, resource_group_name, partition_name = \
822-
self.__get_mt_names_from_location(location)
823-
self.__deploy_app_online(lib_name, src_path, targets, plan=plan_file,
824-
partition=partition_name, resource_group=resource_group_name,
825-
resource_group_template=resource_group_template_name, options=options)
826-
location.remove_name_token(token_name)
812+
if not model_helper.is_delete_name(lib_name):
813+
lib_dict = model_libs[lib_name]
814+
src_path = dictionary_utils.get_element(lib_dict, SOURCE_PATH)
815+
plan_file = dictionary_utils.get_element(lib_dict, PLAN_PATH)
816+
targets = dictionary_utils.get_element(lib_dict, TARGET)
817+
options = _get_deploy_options(model_libs, lib_name, library_module='true')
818+
for uses_path_tokens_attribute_name in uses_path_tokens_attribute_names:
819+
if uses_path_tokens_attribute_name in lib_dict:
820+
self.__extract_file_from_archive(lib_dict[uses_path_tokens_attribute_name])
821+
822+
location.add_name_token(token_name, lib_name)
823+
resource_group_template_name, resource_group_name, partition_name = \
824+
self.__get_mt_names_from_location(location)
825+
self.__deploy_app_online(lib_name, src_path, targets, plan=plan_file,
826+
partition=partition_name, resource_group=resource_group_name,
827+
resource_group_template=resource_group_template_name, options=options)
828+
location.remove_name_token(token_name)
827829
return
828830

829831
def __deploy_model_applications(self, model_apps, app_location, deployed_applist):
@@ -833,29 +835,30 @@ def __deploy_model_applications(self, model_apps, app_location, deployed_applist
833835
location = LocationContext(app_location)
834836
token_name = self.aliases.get_name_token(location)
835837
for app_name in deploy_ordered_keys:
836-
app_dict = model_apps[app_name]
837-
src_path = dictionary_utils.get_element(app_dict, SOURCE_PATH)
838-
plan_file = dictionary_utils.get_element(app_dict, PLAN_PATH)
839-
targets = dictionary_utils.get_element(app_dict, TARGET)
840-
options = _get_deploy_options(model_apps, app_name, library_module='false')
841-
842-
# any attribute with 'uses_path_tokens' may be in the archive (such as SourcePath)
843-
for uses_path_tokens_attribute_name in uses_path_tokens_attribute_names:
844-
if uses_path_tokens_attribute_name in app_dict:
845-
path = app_dict[uses_path_tokens_attribute_name]
846-
if deployer_utils.is_path_into_archive(path):
847-
self.__extract_source_path_from_archive(path, APPLICATION, app_name)
848-
849-
location.add_name_token(token_name, app_name)
850-
resource_group_template_name, resource_group_name, partition_name = \
851-
self.__get_mt_names_from_location(location)
852-
853-
new_app_name = self.__deploy_app_online(app_name, src_path, targets, plan=plan_file,
854-
partition=partition_name, resource_group=resource_group_name,
855-
resource_group_template=resource_group_template_name,
856-
options=options)
857-
location.remove_name_token(token_name)
858-
deployed_applist.append(new_app_name)
838+
if not model_helper.is_delete_name(app_name):
839+
app_dict = model_apps[app_name]
840+
src_path = dictionary_utils.get_element(app_dict, SOURCE_PATH)
841+
plan_file = dictionary_utils.get_element(app_dict, PLAN_PATH)
842+
targets = dictionary_utils.get_element(app_dict, TARGET)
843+
options = _get_deploy_options(model_apps, app_name, library_module='false')
844+
845+
# any attribute with 'uses_path_tokens' may be in the archive (such as SourcePath)
846+
for uses_path_tokens_attribute_name in uses_path_tokens_attribute_names:
847+
if uses_path_tokens_attribute_name in app_dict:
848+
path = app_dict[uses_path_tokens_attribute_name]
849+
if deployer_utils.is_path_into_archive(path):
850+
self.__extract_source_path_from_archive(path, APPLICATION, app_name)
851+
852+
location.add_name_token(token_name, app_name)
853+
resource_group_template_name, resource_group_name, partition_name = \
854+
self.__get_mt_names_from_location(location)
855+
856+
new_app_name = self.__deploy_app_online(app_name, src_path, targets, plan=plan_file,
857+
partition=partition_name, resource_group=resource_group_name,
858+
resource_group_template=resource_group_template_name,
859+
options=options)
860+
location.remove_name_token(token_name)
861+
deployed_applist.append(new_app_name)
859862
return
860863

861864
def __get_mt_names_from_location(self, app_location):

0 commit comments

Comments
 (0)