@@ -48,12 +48,51 @@ const (
4848 StatusReferenceSemeruInstancesCompleted = "semeruInstancesCompleted"
4949)
5050
51- // Create the Deployment and Service objects for a Semeru Compiler used by a Websphere Liberty Application
52- func (r * ReconcileWebSphereLiberty ) reconcileSemeruCompiler (wlva * wlv1.WebSphereLibertyApplication ) (error , string , bool ) {
53- compilerMeta := metav1.ObjectMeta {
51+ func getCompilerMeta (wlva * wlv1.WebSphereLibertyApplication ) metav1.ObjectMeta {
52+ return metav1.ObjectMeta {
5453 Name : getSemeruCompilerNameWithGeneration (wlva ),
5554 Namespace : wlva .GetNamespace (),
5655 }
56+ }
57+
58+ // Returns true if the semeru health port configuration has changed otherwise false
59+ func (r * ReconcileWebSphereLiberty ) upgradeSemeruHealthPorts (inputMeta metav1.ObjectMeta , wlva * wlv1.WebSphereLibertyApplication ) bool {
60+ var healthPort int32 = 38600
61+ if wlva .GetSemeruCloudCompiler ().GetHealth () != nil {
62+ healthPort = * wlva .GetSemeruCloudCompiler ().GetHealth ().GetPort ()
63+ }
64+ semeruDeployment := & appsv1.Deployment {ObjectMeta : inputMeta }
65+ if r .GetClient ().Get (context .TODO (), types.NamespacedName {Name : semeruDeployment .Name , Namespace : semeruDeployment .Namespace }, semeruDeployment ) == nil {
66+ containsHealthPort := false
67+ for _ , container := range semeruDeployment .Spec .Template .Spec .Containers {
68+ for _ , port := range container .Ports {
69+ if port .ContainerPort == healthPort {
70+ containsHealthPort = true
71+ }
72+ }
73+ if containsHealthPort {
74+ break
75+ }
76+ }
77+ if ! containsHealthPort {
78+ return true
79+ }
80+ }
81+ return false
82+ }
83+
84+ // Create the Deployment and Service objects for a Semeru Compiler used by a Websphere Liberty Application
85+ func (r * ReconcileWebSphereLiberty ) reconcileSemeruCompiler (wlva * wlv1.WebSphereLibertyApplication ) (error , string , bool ) {
86+ compilerMeta := getCompilerMeta (wlva )
87+
88+ // check for any diffs that require generation changes
89+ if r .isSemeruEnabled (wlva ) {
90+ upgradeRequired := r .upgradeSemeruHealthPorts (compilerMeta , wlva )
91+ if upgradeRequired {
92+ createNewSemeruGeneration (wlva ) // update generation
93+ compilerMeta = getCompilerMeta (wlva ) // adjust compilerMeta to reference the new generation
94+ }
95+ }
5796
5897 currentGeneration := getGeneration (wlva )
5998
0 commit comments