@@ -405,13 +405,6 @@ def __get_existing_apps(self, base_location):
405
405
absolute_planpath = attributes_map ['AbsolutePlanPath' ]
406
406
config_targets = self .__get_config_targets ()
407
407
408
- # AppRuntimeStateRuntime/AppRuntimeStateRuntime always return the app even if not targeted
409
- # skip as if it is not there
410
- if len (config_targets ) == 0 :
411
- continue
412
- # There are case in application where absolute source path is not set but sourepath is
413
- # if source path is not absolute then we need to add the domain path
414
-
415
408
if absolute_planpath is None :
416
409
absolute_planpath = attributes_map ['PlanPath' ]
417
410
@@ -607,6 +600,14 @@ def __build_library_deploy_strategy(self, location, model_libs, existing_lib_ref
607
600
if lib_dict ['SourcePath' ] is None and existing_src_path is not None :
608
601
lib_dict ['SourcePath' ] = existing_src_path
609
602
603
+ def __shouldCheckForTargetChange (self , src_path , model_src_path ):
604
+ # If the existing running app's source path (always absolute from runtime mbean) = the model's source path.
605
+ # or if the model sourcepath + domain home is exactly equal to the running's app source path.
606
+ # return True otherwise return False
607
+ if not os .path .isabs (model_src_path ):
608
+ return self .model_context .get_domain_home () + '/' + model_src_path == src_path
609
+ else :
610
+ return FileUtils .getCanonicalPath (src_path ) == FileUtils .getCanonicalPath (model_src_path )
610
611
611
612
def __build_app_deploy_strategy (self , location , model_apps , existing_app_refs , stop_and_undeploy_app_list ):
612
613
"""
@@ -666,8 +667,8 @@ def __build_app_deploy_strategy(self, location, model_apps, existing_app_refs, s
666
667
existing_plan_hash = self .__get_file_hash (plan_path )
667
668
if model_src_hash == existing_src_hash :
668
669
if model_plan_hash == existing_plan_hash :
669
- if not ( os . path . isabs (src_path ) and os . path . isabs ( model_src_path ) and
670
- FileUtils . getCanonicalPath ( src_path ) == FileUtils . getCanonicalPath ( model_src_path )):
670
+ if self . __shouldCheckForTargetChange (src_path , model_src_path ):
671
+
671
672
# If model hashes match existing hashes, the application did not change.
672
673
# Unless targets were added, there's no need to redeploy.
673
674
# If it is an absolute path, there is nothing to compare so assume redeploy
@@ -678,8 +679,16 @@ def __build_app_deploy_strategy(self, location, model_apps, existing_app_refs, s
678
679
existing_app_targets = dictionary_utils .get_element (existing_app_ref , 'target' )
679
680
existing_app_targets_set = Set (existing_app_targets )
680
681
681
- if existing_app_targets_set .issuperset (model_targets_set ):
682
- self .__remove_app_from_deployment (model_apps , app )
682
+ if existing_app_targets_set == model_targets_set and len (existing_app_targets_set ) > 0 :
683
+ # redeploy the app if everything is the same
684
+ self .logger .info ('WLSDPLY-09336' , src_path ,
685
+ class_name = self ._class_name , method_name = _method_name )
686
+ if versioned_name not in stop_and_undeploy_app_list :
687
+ stop_and_undeploy_app_list .append (versioned_name )
688
+ elif len (existing_app_targets_set ) == 0 and len (model_targets_set ) == 0 :
689
+ self .__remove_app_from_deployment (model_apps , app , "emptyset" )
690
+ elif existing_app_targets_set .issuperset (model_targets_set ):
691
+ self .__remove_app_from_deployment (model_apps , app , "superset" )
683
692
else :
684
693
# Adjust the targets to only the new targets so that existing apps on
685
694
# already targeted servers are not impacted.
@@ -692,8 +701,7 @@ def __build_app_deploy_strategy(self, location, model_apps, existing_app_refs, s
692
701
if app_dict ['SourcePath' ] is None and src_path is not None :
693
702
app_dict ['SourcePath' ] = src_path
694
703
else :
695
- self .logger .info ('WLSDPLY-09336' , src_path ,
696
- class_name = self ._class_name , method_name = _method_name )
704
+ # same hash but different path, so redeploy it
697
705
if versioned_name not in stop_and_undeploy_app_list :
698
706
stop_and_undeploy_app_list .append (versioned_name )
699
707
else :
@@ -833,9 +841,17 @@ def __handle_builtin_libraries(self, targets_not_changed, model_libs, lib,
833
841
adjusted_targets = ',' .join (adjusted_set )
834
842
model_libs [lib ][TARGET ] = adjusted_targets
835
843
836
- def __remove_app_from_deployment (self , model_dict , app_name ):
837
- self .logger .info ('WLSDPLY-09337' , app_name ,
838
- class_name = self ._class_name , method_name = 'remove_app_from_deployment' )
844
+ def __remove_app_from_deployment (self , model_dict , app_name , reason = "delete" ):
845
+ if "superset" == reason :
846
+ self .logger .info ('WLSDPLY-09338' , app_name ,
847
+ class_name = self ._class_name , method_name = 'remove_app_from_deployment' )
848
+ elif "emptyset" == reason :
849
+ self .logger .info ('WLSDPLY-09339' , app_name ,
850
+ class_name = self ._class_name , method_name = 'remove_app_from_deployment' )
851
+ else :
852
+ self .logger .info ('WLSDPLY-09337' , app_name ,
853
+ class_name = self ._class_name , method_name = 'remove_app_from_deployment' )
854
+
839
855
model_dict .pop (app_name )
840
856
841
857
def __remove_lib_from_deployment (self , model_dict , lib_name ):
0 commit comments