From d0fa452cef8744a94b02eba69b153eb34eadd15f Mon Sep 17 00:00:00 2001 From: kabicin <37311900+kabicin@users.noreply.github.com> Date: Mon, 21 Apr 2025 13:36:12 -0400 Subject: [PATCH 1/5] Add semeru health port flag --- api/v1/webspherelibertyapplication_types.go | 11 ++++ ...bsphere-liberty.clusterserviceversion.yaml | 5 ++ ....ibm.com_webspherelibertyapplications.yaml | 5 ++ ....ibm.com_webspherelibertyapplications.yaml | 5 ++ ...bsphere-liberty.clusterserviceversion.yaml | 5 ++ internal/controller/semeru_compiler.go | 59 +++++++++++++++---- .../kubectl/websphereliberty-app-crd.yaml | 5 ++ .../daily/base/websphere-liberty-crd.yaml | 5 ++ 8 files changed, 87 insertions(+), 13 deletions(-) diff --git a/api/v1/webspherelibertyapplication_types.go b/api/v1/webspherelibertyapplication_types.go index b11c3910..d7fbb4c3 100644 --- a/api/v1/webspherelibertyapplication_types.go +++ b/api/v1/webspherelibertyapplication_types.go @@ -520,6 +520,9 @@ type WebSphereLibertyApplicationSemeruCloudCompiler struct { // Resource requests and limits for the Semeru Cloud Compiler. The CPU defaults to 100m with a limit of 2000m. The memory defaults to 800Mi, with a limit of 1200Mi. // +operator-sdk:csv:customresourcedefinitions:order=54,type=spec,displayName="Resource Requirements",xDescriptors="urn:alm:descriptor:com.tectonic.ui:resourceRequirements" Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + // The health port for the Semeru Cloud Compiler. Defaults to 38600. + // +operator-sdk:csv:customresourcedefinitions:order=55,type=spec,displayName="Port",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number" + Port *int32 `json:"port,omitempty"` } // Defines SemeruCompiler status @@ -1287,6 +1290,14 @@ func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetReplicas() *int32 return &one } +func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetPort() *int32 { + if scc.Port != nil { + return scc.Port + } + defaultPort := int32(38600) + return &defaultPort +} + // GetTopologySpreadConstraints returns the pod topology spread constraints configuration func (cr *WebSphereLibertyApplication) GetTopologySpreadConstraints() common.BaseComponentTopologySpreadConstraints { if cr.Spec.TopologySpreadConstraints == nil { diff --git a/bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml b/bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml index c3e4e1fc..07d06450 100644 --- a/bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml +++ b/bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml @@ -577,6 +577,11 @@ spec: path: semeruCloudCompiler.resources x-descriptors: - urn:alm:descriptor:com.tectonic.ui:resourceRequirements + - description: The health port for the Semeru Cloud Compiler. Defaults to 38600. + displayName: Port + path: semeruCloudCompiler.port + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: 'Product edition. Defaults to IBM WebSphere Application Server. Other options: IBM WebSphere Application Server Liberty Core, IBM WebSphere Application Server Network Deployment' diff --git a/bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml b/bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml index 74c4ea52..0db99e87 100644 --- a/bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml +++ b/bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml @@ -4173,6 +4173,11 @@ spec: enable: description: Enable the Semeru Cloud Compiler. Defaults to false. type: boolean + port: + description: The health port for the Semeru Cloud Compiler. Defaults + to 38600. + format: int32 + type: integer replicas: description: Number of desired pods for the Semeru Cloud Compiler. Defaults to 1. diff --git a/config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml b/config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml index 5a2d7bfb..f4ef8bd3 100644 --- a/config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml +++ b/config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml @@ -4169,6 +4169,11 @@ spec: enable: description: Enable the Semeru Cloud Compiler. Defaults to false. type: boolean + port: + description: The health port for the Semeru Cloud Compiler. Defaults + to 38600. + format: int32 + type: integer replicas: description: Number of desired pods for the Semeru Cloud Compiler. Defaults to 1. diff --git a/config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml b/config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml index 5ce88edc..e293ea14 100644 --- a/config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml +++ b/config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml @@ -519,6 +519,11 @@ spec: path: semeruCloudCompiler.resources x-descriptors: - urn:alm:descriptor:com.tectonic.ui:resourceRequirements + - description: The health port for the Semeru Cloud Compiler. Defaults to 38600. + displayName: Port + path: semeruCloudCompiler.port + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: 'Product edition. Defaults to IBM WebSphere Application Server. Other options: IBM WebSphere Application Server Liberty Core, IBM WebSphere Application Server Network Deployment' diff --git a/internal/controller/semeru_compiler.go b/internal/controller/semeru_compiler.go index 795c0590..02a2036e 100644 --- a/internal/controller/semeru_compiler.go +++ b/internal/controller/semeru_compiler.go @@ -255,6 +255,7 @@ func (r *ReconcileWebSphereLiberty) deleteCompletedSemeruInstances(wlva *wlv1.We } func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphereLibertyApplication, deploy *appsv1.Deployment) { + var port int32 = 38400 deploy.Labels = getLabels(wlva) deploy.Spec.Strategy.Type = appsv1.RecreateDeploymentStrategyType @@ -276,11 +277,18 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe limitsMemory := getQuantityFromLimitsOrDefault(instanceResources, corev1.ResourceMemory, "1200Mi") limitsCPU := getQuantityFromLimitsOrDefault(instanceResources, corev1.ResourceCPU, "2000m") + portNumber := *semeruCloudCompiler.GetPort() + var portIntOrStr intstr.IntOrString + if portNumber == port { + portIntOrStr = intstr.FromInt32(port) + } else { + portIntOrStr = intstr.FromString(fmt.Sprintf("%d-tcp", port)) + } // Liveness probe livenessProbe := corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ TCPSocket: &corev1.TCPSocketAction{ - Port: intstr.FromInt(38400), + Port: portIntOrStr, }, }, InitialDelaySeconds: 10, @@ -291,7 +299,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe readinessProbe := corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ TCPSocket: &corev1.TCPSocketAction{ - Port: intstr.FromInt(38400), + Port: portIntOrStr, }, }, InitialDelaySeconds: 5, @@ -301,6 +309,22 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe semeruPodMatchLabels := map[string]string{ "app.kubernetes.io/instance": getSemeruCompilerNameWithGeneration(wlva), } + containerPorts := make([]corev1.ContainerPort, 0) + containerPorts = append(containerPorts, corev1.ContainerPort{ + ContainerPort: port, + Protocol: corev1.ProtocolTCP, + }) + + healthProbesFlag := "" + if portNumber != port { + healthProbesFlag = " -XX:+JITServerHealthProbes" + fmt.Sprintf(" -XX:JITServerHealthProbePort=%d", portNumber) + containerPorts[0].Name = fmt.Sprintf("%d-tcp", port) + containerPorts = append(containerPorts, corev1.ContainerPort{ + Name: fmt.Sprintf("%d-tcp", portNumber), + ContainerPort: portNumber, + Protocol: corev1.ProtocolTCP, + }) + } deploy.Spec.Template = corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: getLabels(wlva), @@ -337,12 +361,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe Image: wlva.Status.GetImageReference(), ImagePullPolicy: *wlva.GetPullPolicy(), Command: []string{"jitserver"}, - Ports: []corev1.ContainerPort{ - { - ContainerPort: 38400, - Protocol: corev1.ProtocolTCP, - }, - }, + Ports: containerPorts, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceMemory: requestsMemory, @@ -356,6 +375,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe Env: []corev1.EnvVar{ {Name: "OPENJ9_JAVA_OPTIONS", Value: "-XX:+JITServerLogConnections" + " -XX:+JITServerShareROMClasses" + + healthProbesFlag + " -XX:JITServerSSLKey=/etc/x509/certs/tls.key" + " -XX:JITServerSSLCert=/etc/x509/certs/tls.crt"}, }, @@ -417,12 +437,26 @@ func reconcileSemeruService(svc *corev1.Service, wlva *wlv1.WebSphereLibertyAppl svc.Labels = getLabels(wlva) svc.Spec.Selector = getSelectors(wlva) utils.CustomizeServiceAnnotations(svc) - if len(svc.Spec.Ports) == 0 { + numPorts := len(svc.Spec.Ports) + if numPorts == 0 { svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{}) } svc.Spec.Ports[0].Protocol = corev1.ProtocolTCP svc.Spec.Ports[0].Port = port svc.Spec.Ports[0].TargetPort = intstr.FromInt(int(port)) + portNumber := *wlva.GetSemeruCloudCompiler().GetPort() + if portNumber != port { + numPorts = len(svc.Spec.Ports) + if numPorts == 1 { + svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{}) + } + svc.Spec.Ports[0].Name = fmt.Sprintf("%d-tcp", port) + svc.Spec.Ports[0].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", port)) + svc.Spec.Ports[1].Name = fmt.Sprintf("%d-tcp", portNumber) + svc.Spec.Ports[1].Protocol = corev1.ProtocolTCP + svc.Spec.Ports[1].Port = portNumber + svc.Spec.Ports[1].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", portNumber)) + } svc.Spec.SessionAffinity = corev1.ServiceAffinityClientIP svc.Spec.SessionAffinityConfig = &corev1.SessionAffinityConfig{ ClientIP: &corev1.ClientIPConfig{ @@ -585,14 +619,13 @@ func (r *ReconcileWebSphereLiberty) getSemeruJavaOptions(instance *wlv1.WebSpher certificateLocation = "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt" } jitServerAddress := instance.Status.SemeruCompiler.ServiceHostname - jitSeverOptions := fmt.Sprintf("-XX:+UseJITServer -XX:+JITServerLogConnections -XX:JITServerAddress=%v -XX:JITServerSSLRootCerts=%v", - jitServerAddress, certificateLocation) + jitServerOptions := fmt.Sprintf("-XX:+UseJITServer -XX:+JITServerLogConnections -XX:JITServerAddress=%v -XX:JITServerSSLRootCerts=%v", jitServerAddress, certificateLocation) args := []string{ "/bin/bash", "-c", - "export OPENJ9_JAVA_OPTIONS=\"$OPENJ9_JAVA_OPTIONS " + jitSeverOptions + - "\" && export OPENJ9_RESTORE_JAVA_OPTIONS=\"$OPENJ9_RESTORE_JAVA_OPTIONS " + jitSeverOptions + + "export OPENJ9_JAVA_OPTIONS=\"$OPENJ9_JAVA_OPTIONS " + jitServerOptions + + "\" && export OPENJ9_RESTORE_JAVA_OPTIONS=\"$OPENJ9_RESTORE_JAVA_OPTIONS " + jitServerOptions + "\" && server run", } return args diff --git a/internal/deploy/kubectl/websphereliberty-app-crd.yaml b/internal/deploy/kubectl/websphereliberty-app-crd.yaml index 5700c256..7706adf4 100644 --- a/internal/deploy/kubectl/websphereliberty-app-crd.yaml +++ b/internal/deploy/kubectl/websphereliberty-app-crd.yaml @@ -4172,6 +4172,11 @@ spec: enable: description: Enable the Semeru Cloud Compiler. Defaults to false. type: boolean + port: + description: The health port for the Semeru Cloud Compiler. Defaults + to 38600. + format: int32 + type: integer replicas: description: Number of desired pods for the Semeru Cloud Compiler. Defaults to 1. diff --git a/internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml b/internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml index 5700c256..7706adf4 100644 --- a/internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml +++ b/internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml @@ -4172,6 +4172,11 @@ spec: enable: description: Enable the Semeru Cloud Compiler. Defaults to false. type: boolean + port: + description: The health port for the Semeru Cloud Compiler. Defaults + to 38600. + format: int32 + type: integer replicas: description: Number of desired pods for the Semeru Cloud Compiler. Defaults to 1. From c20ce79df18051321bb8563f3a7419ef59ff13d8 Mon Sep 17 00:00:00 2001 From: kabicin <37311900+kabicin@users.noreply.github.com> Date: Wed, 23 Apr 2025 14:02:48 -0400 Subject: [PATCH 2/5] Add semeru health port config --- api/v1/webspherelibertyapplication_types.go | 19 +++++++-- ...bsphere-liberty.clusterserviceversion.yaml | 39 ++++++++++--------- ....ibm.com_webspherelibertyapplications.yaml | 14 ++++--- ....ibm.com_webspherelibertyapplications.yaml | 14 ++++--- ...bsphere-liberty.clusterserviceversion.yaml | 39 ++++++++++--------- internal/controller/semeru_compiler.go | 29 ++++++++------ .../kubectl/websphereliberty-app-crd.yaml | 14 ++++--- .../daily/base/websphere-liberty-crd.yaml | 14 ++++--- 8 files changed, 111 insertions(+), 71 deletions(-) diff --git a/api/v1/webspherelibertyapplication_types.go b/api/v1/webspherelibertyapplication_types.go index d7fbb4c3..d2311e00 100644 --- a/api/v1/webspherelibertyapplication_types.go +++ b/api/v1/webspherelibertyapplication_types.go @@ -520,8 +520,14 @@ type WebSphereLibertyApplicationSemeruCloudCompiler struct { // Resource requests and limits for the Semeru Cloud Compiler. The CPU defaults to 100m with a limit of 2000m. The memory defaults to 800Mi, with a limit of 1200Mi. // +operator-sdk:csv:customresourcedefinitions:order=54,type=spec,displayName="Resource Requirements",xDescriptors="urn:alm:descriptor:com.tectonic.ui:resourceRequirements" Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + // The health settings for the Semeru Cloud Compiler. + // +operator-sdk:csv:customresourcedefinitions:order=55,type=spec,displayName="Health" + Health *WebSphereLibertyApplicationSemeruCloudCompilerHealth `json:"health,omitempty"` +} + +type WebSphereLibertyApplicationSemeruCloudCompilerHealth struct { // The health port for the Semeru Cloud Compiler. Defaults to 38600. - // +operator-sdk:csv:customresourcedefinitions:order=55,type=spec,displayName="Port",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number" + // +operator-sdk:csv:customresourcedefinitions:order=60,type=spec,displayName="Port",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number" Port *int32 `json:"port,omitempty"` } @@ -1290,9 +1296,14 @@ func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetReplicas() *int32 return &one } -func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetPort() *int32 { - if scc.Port != nil { - return scc.Port +// GetHealth returns the Semeru Cloud Compiler Health configuration +func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetHealth() *WebSphereLibertyApplicationSemeruCloudCompilerHealth { + return scc.Health +} + +func (scch *WebSphereLibertyApplicationSemeruCloudCompilerHealth) GetPort() *int32 { + if scch.Port != nil { + return scch.Port } defaultPort := int32(38600) return &defaultPort diff --git a/bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml b/bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml index 07d06450..9f09630b 100644 --- a/bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml +++ b/bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml @@ -538,48 +538,51 @@ spec: be removed from service endpoints if the probe fails. displayName: Readiness Probe path: probes.readiness + - description: Enable the Semeru Cloud Compiler. Defaults to false. + displayName: Enable + path: semeruCloudCompiler.enable + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - description: Probe to determine successful initialization. If specified, other probes are not executed until this completes successfully. displayName: Startup Probe path: probes.startup + - description: Number of desired pods for the Semeru Cloud Compiler. Defaults + to 1. + displayName: Replicas + path: semeruCloudCompiler.replicas + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:podCount - description: Disable the creation of the network policy. Defaults to false. displayName: Disable path: networkPolicy.disable x-descriptors: - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - - description: Enable the Semeru Cloud Compiler. Defaults to false. - displayName: Enable - path: semeruCloudCompiler.enable + - description: Resource requests and limits for the Semeru Cloud Compiler. The + CPU defaults to 100m with a limit of 2000m. The memory defaults to 800Mi, + with a limit of 1200Mi. + displayName: Resource Requirements + path: semeruCloudCompiler.resources x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:booleanSwitch + - urn:alm:descriptor:com.tectonic.ui:resourceRequirements - description: Specify the labels of namespaces that incoming traffic is allowed from. displayName: Namespace Labels path: networkPolicy.namespaceLabels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - - description: Number of desired pods for the Semeru Cloud Compiler. Defaults - to 1. - displayName: Replicas - path: semeruCloudCompiler.replicas - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:podCount + - description: The health settings for the Semeru Cloud Compiler. + displayName: Health + path: semeruCloudCompiler.health - description: Specify the labels of pod(s) that incoming traffic is allowed from. displayName: From Labels path: networkPolicy.fromLabels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - - description: Resource requests and limits for the Semeru Cloud Compiler. The - CPU defaults to 100m with a limit of 2000m. The memory defaults to 800Mi, - with a limit of 1200Mi. - displayName: Resource Requirements - path: semeruCloudCompiler.resources - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:resourceRequirements - description: The health port for the Semeru Cloud Compiler. Defaults to 38600. displayName: Port - path: semeruCloudCompiler.port + path: semeruCloudCompiler.health.port x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number - description: 'Product edition. Defaults to IBM WebSphere Application Server. diff --git a/bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml b/bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml index 0db99e87..7fa87366 100644 --- a/bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml +++ b/bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml @@ -4173,11 +4173,15 @@ spec: enable: description: Enable the Semeru Cloud Compiler. Defaults to false. type: boolean - port: - description: The health port for the Semeru Cloud Compiler. Defaults - to 38600. - format: int32 - type: integer + health: + description: The health settings for the Semeru Cloud Compiler. + properties: + port: + description: The health port for the Semeru Cloud Compiler. + Defaults to 38600. + format: int32 + type: integer + type: object replicas: description: Number of desired pods for the Semeru Cloud Compiler. Defaults to 1. diff --git a/config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml b/config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml index f4ef8bd3..19186837 100644 --- a/config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml +++ b/config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml @@ -4169,11 +4169,15 @@ spec: enable: description: Enable the Semeru Cloud Compiler. Defaults to false. type: boolean - port: - description: The health port for the Semeru Cloud Compiler. Defaults - to 38600. - format: int32 - type: integer + health: + description: The health settings for the Semeru Cloud Compiler. + properties: + port: + description: The health port for the Semeru Cloud Compiler. + Defaults to 38600. + format: int32 + type: integer + type: object replicas: description: Number of desired pods for the Semeru Cloud Compiler. Defaults to 1. diff --git a/config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml b/config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml index e293ea14..94d5f3d8 100644 --- a/config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml +++ b/config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml @@ -480,48 +480,51 @@ spec: be removed from service endpoints if the probe fails. displayName: Readiness Probe path: probes.readiness + - description: Enable the Semeru Cloud Compiler. Defaults to false. + displayName: Enable + path: semeruCloudCompiler.enable + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - description: Probe to determine successful initialization. If specified, other probes are not executed until this completes successfully. displayName: Startup Probe path: probes.startup + - description: Number of desired pods for the Semeru Cloud Compiler. Defaults + to 1. + displayName: Replicas + path: semeruCloudCompiler.replicas + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:podCount - description: Disable the creation of the network policy. Defaults to false. displayName: Disable path: networkPolicy.disable x-descriptors: - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - - description: Enable the Semeru Cloud Compiler. Defaults to false. - displayName: Enable - path: semeruCloudCompiler.enable + - description: Resource requests and limits for the Semeru Cloud Compiler. The + CPU defaults to 100m with a limit of 2000m. The memory defaults to 800Mi, + with a limit of 1200Mi. + displayName: Resource Requirements + path: semeruCloudCompiler.resources x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:booleanSwitch + - urn:alm:descriptor:com.tectonic.ui:resourceRequirements - description: Specify the labels of namespaces that incoming traffic is allowed from. displayName: Namespace Labels path: networkPolicy.namespaceLabels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - - description: Number of desired pods for the Semeru Cloud Compiler. Defaults - to 1. - displayName: Replicas - path: semeruCloudCompiler.replicas - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:podCount + - description: The health settings for the Semeru Cloud Compiler. + displayName: Health + path: semeruCloudCompiler.health - description: Specify the labels of pod(s) that incoming traffic is allowed from. displayName: From Labels path: networkPolicy.fromLabels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - - description: Resource requests and limits for the Semeru Cloud Compiler. The - CPU defaults to 100m with a limit of 2000m. The memory defaults to 800Mi, - with a limit of 1200Mi. - displayName: Resource Requirements - path: semeruCloudCompiler.resources - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:resourceRequirements - description: The health port for the Semeru Cloud Compiler. Defaults to 38600. displayName: Port - path: semeruCloudCompiler.port + path: semeruCloudCompiler.health.port x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number - description: 'Product edition. Defaults to IBM WebSphere Application Server. diff --git a/internal/controller/semeru_compiler.go b/internal/controller/semeru_compiler.go index 02a2036e..b1a47b0e 100644 --- a/internal/controller/semeru_compiler.go +++ b/internal/controller/semeru_compiler.go @@ -256,6 +256,7 @@ func (r *ReconcileWebSphereLiberty) deleteCompletedSemeruInstances(wlva *wlv1.We func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphereLibertyApplication, deploy *appsv1.Deployment) { var port int32 = 38400 + var healthPort int32 = 38600 deploy.Labels = getLabels(wlva) deploy.Spec.Strategy.Type = appsv1.RecreateDeploymentStrategyType @@ -277,9 +278,11 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe limitsMemory := getQuantityFromLimitsOrDefault(instanceResources, corev1.ResourceMemory, "1200Mi") limitsCPU := getQuantityFromLimitsOrDefault(instanceResources, corev1.ResourceCPU, "2000m") - portNumber := *semeruCloudCompiler.GetPort() + if semeruCloudCompiler.GetHealth() != nil { + healthPort = *semeruCloudCompiler.GetHealth().GetPort() + } var portIntOrStr intstr.IntOrString - if portNumber == port { + if healthPort == port { portIntOrStr = intstr.FromInt32(port) } else { portIntOrStr = intstr.FromString(fmt.Sprintf("%d-tcp", port)) @@ -316,12 +319,12 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe }) healthProbesFlag := "" - if portNumber != port { - healthProbesFlag = " -XX:+JITServerHealthProbes" + fmt.Sprintf(" -XX:JITServerHealthProbePort=%d", portNumber) + if healthPort != port { + healthProbesFlag = " -XX:+JITServerHealthProbes" + fmt.Sprintf(" -XX:JITServerHealthProbePort=%d", healthPort) containerPorts[0].Name = fmt.Sprintf("%d-tcp", port) containerPorts = append(containerPorts, corev1.ContainerPort{ - Name: fmt.Sprintf("%d-tcp", portNumber), - ContainerPort: portNumber, + Name: fmt.Sprintf("%d-tcp", healthPort), + ContainerPort: healthPort, Protocol: corev1.ProtocolTCP, }) } @@ -433,6 +436,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe func reconcileSemeruService(svc *corev1.Service, wlva *wlv1.WebSphereLibertyApplication) { var port int32 = 38400 + var healthPort int32 = 38600 var timeout int32 = 86400 svc.Labels = getLabels(wlva) svc.Spec.Selector = getSelectors(wlva) @@ -441,21 +445,24 @@ func reconcileSemeruService(svc *corev1.Service, wlva *wlv1.WebSphereLibertyAppl if numPorts == 0 { svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{}) } + svc.Spec.Ports[0].Protocol = corev1.ProtocolTCP svc.Spec.Ports[0].Port = port svc.Spec.Ports[0].TargetPort = intstr.FromInt(int(port)) - portNumber := *wlva.GetSemeruCloudCompiler().GetPort() - if portNumber != port { + if wlva.GetSemeruCloudCompiler().GetHealth() != nil { + healthPort = *wlva.GetSemeruCloudCompiler().GetHealth().GetPort() + } + if healthPort != port { numPorts = len(svc.Spec.Ports) if numPorts == 1 { svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{}) } svc.Spec.Ports[0].Name = fmt.Sprintf("%d-tcp", port) svc.Spec.Ports[0].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", port)) - svc.Spec.Ports[1].Name = fmt.Sprintf("%d-tcp", portNumber) + svc.Spec.Ports[1].Name = fmt.Sprintf("%d-tcp", healthPort) svc.Spec.Ports[1].Protocol = corev1.ProtocolTCP - svc.Spec.Ports[1].Port = portNumber - svc.Spec.Ports[1].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", portNumber)) + svc.Spec.Ports[1].Port = healthPort + svc.Spec.Ports[1].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", healthPort)) } svc.Spec.SessionAffinity = corev1.ServiceAffinityClientIP svc.Spec.SessionAffinityConfig = &corev1.SessionAffinityConfig{ diff --git a/internal/deploy/kubectl/websphereliberty-app-crd.yaml b/internal/deploy/kubectl/websphereliberty-app-crd.yaml index 7706adf4..ec3a6354 100644 --- a/internal/deploy/kubectl/websphereliberty-app-crd.yaml +++ b/internal/deploy/kubectl/websphereliberty-app-crd.yaml @@ -4172,11 +4172,15 @@ spec: enable: description: Enable the Semeru Cloud Compiler. Defaults to false. type: boolean - port: - description: The health port for the Semeru Cloud Compiler. Defaults - to 38600. - format: int32 - type: integer + health: + description: The health settings for the Semeru Cloud Compiler. + properties: + port: + description: The health port for the Semeru Cloud Compiler. + Defaults to 38600. + format: int32 + type: integer + type: object replicas: description: Number of desired pods for the Semeru Cloud Compiler. Defaults to 1. diff --git a/internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml b/internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml index 7706adf4..ec3a6354 100644 --- a/internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml +++ b/internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml @@ -4172,11 +4172,15 @@ spec: enable: description: Enable the Semeru Cloud Compiler. Defaults to false. type: boolean - port: - description: The health port for the Semeru Cloud Compiler. Defaults - to 38600. - format: int32 - type: integer + health: + description: The health settings for the Semeru Cloud Compiler. + properties: + port: + description: The health port for the Semeru Cloud Compiler. + Defaults to 38600. + format: int32 + type: integer + type: object replicas: description: Number of desired pods for the Semeru Cloud Compiler. Defaults to 1. From 66c5d4d7306f2f68df89ad56e95f7d7894234b6e Mon Sep 17 00:00:00 2001 From: kabicin <37311900+kabicin@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:22:39 -0400 Subject: [PATCH 3/5] Update generation on semeru health port change --- internal/controller/semeru_compiler.go | 45 ++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/internal/controller/semeru_compiler.go b/internal/controller/semeru_compiler.go index b1a47b0e..485391d7 100644 --- a/internal/controller/semeru_compiler.go +++ b/internal/controller/semeru_compiler.go @@ -48,12 +48,51 @@ const ( StatusReferenceSemeruInstancesCompleted = "semeruInstancesCompleted" ) -// Create the Deployment and Service objects for a Semeru Compiler used by a Websphere Liberty Application -func (r *ReconcileWebSphereLiberty) reconcileSemeruCompiler(wlva *wlv1.WebSphereLibertyApplication) (error, string, bool) { - compilerMeta := metav1.ObjectMeta{ +func getCompilerMeta(wlva *wlv1.WebSphereLibertyApplication) metav1.ObjectMeta { + return metav1.ObjectMeta{ Name: getSemeruCompilerNameWithGeneration(wlva), Namespace: wlva.GetNamespace(), } +} + +// Returns true if the semeru health port configuration has changed otherwise false +func (r *ReconcileWebSphereLiberty) upgradeSemeruHealthPorts(inputMeta metav1.ObjectMeta, wlva *wlv1.WebSphereLibertyApplication) bool { + var healthPort int32 = 38600 + if wlva.GetSemeruCloudCompiler().GetHealth() != nil { + healthPort = *wlva.GetSemeruCloudCompiler().GetHealth().GetPort() + } + semeruDeployment := &appsv1.Deployment{ObjectMeta: inputMeta} + if r.GetClient().Get(context.TODO(), types.NamespacedName{Name: semeruDeployment.Name, Namespace: semeruDeployment.Namespace}, semeruDeployment) == nil { + containsHealthPort := false + for _, container := range semeruDeployment.Spec.Template.Spec.Containers { + for _, port := range container.Ports { + if port.ContainerPort == healthPort { + containsHealthPort = true + } + } + if containsHealthPort { + break + } + } + if !containsHealthPort { + return true + } + } + return false +} + +// Create the Deployment and Service objects for a Semeru Compiler used by a Websphere Liberty Application +func (r *ReconcileWebSphereLiberty) reconcileSemeruCompiler(wlva *wlv1.WebSphereLibertyApplication) (error, string, bool) { + compilerMeta := getCompilerMeta(wlva) + + // check for any diffs that require generation changes + if r.isSemeruEnabled(wlva) { + upgradeRequired := r.upgradeSemeruHealthPorts(compilerMeta, wlva) + if upgradeRequired { + createNewSemeruGeneration(wlva) // update generation + compilerMeta = getCompilerMeta(wlva) // adjust compilerMeta to reference the new generation + } + } currentGeneration := getGeneration(wlva) From 1f027d7b68c78b7ed6ccfffb5a6bb154ebad7cdd Mon Sep 17 00:00:00 2001 From: kabicin <37311900+kabicin@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:34:33 -0400 Subject: [PATCH 4/5] Semeru health port to support using 38400 --- internal/controller/semeru_compiler.go | 30 ++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/internal/controller/semeru_compiler.go b/internal/controller/semeru_compiler.go index 485391d7..f84cf479 100644 --- a/internal/controller/semeru_compiler.go +++ b/internal/controller/semeru_compiler.go @@ -46,6 +46,7 @@ const ( SemeruGenerationLabelNameSuffix = "/semeru-compiler-generation" StatusReferenceSemeruGeneration = "semeruGeneration" StatusReferenceSemeruInstancesCompleted = "semeruInstancesCompleted" + SemeruContainerName = "compiler" ) func getCompilerMeta(wlva *wlv1.WebSphereLibertyApplication) metav1.ObjectMeta { @@ -55,6 +56,15 @@ func getCompilerMeta(wlva *wlv1.WebSphereLibertyApplication) metav1.ObjectMeta { } } +func getSemeruDeploymentContainer(deploy *appsv1.Deployment) (corev1.Container, error) { + for _, container := range deploy.Spec.Template.Spec.Containers { + if container.Name == SemeruContainerName { + return container, nil + } + } + return corev1.Container{}, fmt.Errorf("could not find the Semeru Deployment container") +} + // Returns true if the semeru health port configuration has changed otherwise false func (r *ReconcileWebSphereLiberty) upgradeSemeruHealthPorts(inputMeta metav1.ObjectMeta, wlva *wlv1.WebSphereLibertyApplication) bool { var healthPort int32 = 38600 @@ -63,15 +73,17 @@ func (r *ReconcileWebSphereLiberty) upgradeSemeruHealthPorts(inputMeta metav1.Ob } semeruDeployment := &appsv1.Deployment{ObjectMeta: inputMeta} if r.GetClient().Get(context.TODO(), types.NamespacedName{Name: semeruDeployment.Name, Namespace: semeruDeployment.Namespace}, semeruDeployment) == nil { + container, err := getSemeruDeploymentContainer(semeruDeployment) + if err != nil { + return false + } + if healthPort == 38400 && len(container.Ports) > 1 { + return true + } containsHealthPort := false - for _, container := range semeruDeployment.Spec.Template.Spec.Containers { - for _, port := range container.Ports { - if port.ContainerPort == healthPort { - containsHealthPort = true - } - } - if containsHealthPort { - break + for _, port := range container.Ports { + if port.ContainerPort == healthPort { + containsHealthPort = true } } if !containsHealthPort { @@ -399,7 +411,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe }, Containers: []corev1.Container{ { - Name: "compiler", + Name: SemeruContainerName, Image: wlva.Status.GetImageReference(), ImagePullPolicy: *wlva.GetPullPolicy(), Command: []string{"jitserver"}, From 38f065967748518888a36ee05749e54533e6ee39 Mon Sep 17 00:00:00 2001 From: kabicin <37311900+kabicin@users.noreply.github.com> Date: Mon, 28 Apr 2025 13:28:41 -0400 Subject: [PATCH 5/5] Fix SCC deployment to use health port --- internal/controller/semeru_compiler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/controller/semeru_compiler.go b/internal/controller/semeru_compiler.go index f84cf479..d8e19cae 100644 --- a/internal/controller/semeru_compiler.go +++ b/internal/controller/semeru_compiler.go @@ -336,7 +336,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe if healthPort == port { portIntOrStr = intstr.FromInt32(port) } else { - portIntOrStr = intstr.FromString(fmt.Sprintf("%d-tcp", port)) + portIntOrStr = intstr.FromString(fmt.Sprintf("%d-tcp", healthPort)) } // Liveness probe livenessProbe := corev1.Probe{