Skip to content

Commit 18fe2a1

Browse files
authored
Support Semeru Cloud Compiler health probe config (#749)
* Add semeru health port flag * Add semeru health port config * Update generation on semeru health port change * Semeru health port to support using 38400 * Fix SCC deployment to use health port * Update bundle manifests
1 parent 318e156 commit 18fe2a1

9 files changed

Lines changed: 207 additions & 17 deletions

api/v1/webspherelibertyapplication_types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,15 @@ type WebSphereLibertyApplicationSemeruCloudCompiler struct {
576576
// 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.
577577
// +operator-sdk:csv:customresourcedefinitions:order=54,type=spec,displayName="Resource Requirements",xDescriptors="urn:alm:descriptor:com.tectonic.ui:resourceRequirements"
578578
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
579+
// The health settings for the Semeru Cloud Compiler.
580+
// +operator-sdk:csv:customresourcedefinitions:order=55,type=spec,displayName="Health"
581+
Health *WebSphereLibertyApplicationSemeruCloudCompilerHealth `json:"health,omitempty"`
582+
}
583+
584+
type WebSphereLibertyApplicationSemeruCloudCompilerHealth struct {
585+
// The health port for the Semeru Cloud Compiler. Defaults to 38600.
586+
// +operator-sdk:csv:customresourcedefinitions:order=60,type=spec,displayName="Port",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number"
587+
Port *int32 `json:"port,omitempty"`
579588
}
580589

581590
// Defines SemeruCompiler status
@@ -1409,6 +1418,19 @@ func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetReplicas() *int32
14091418
return &one
14101419
}
14111420

1421+
// GetHealth returns the Semeru Cloud Compiler Health configuration
1422+
func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetHealth() *WebSphereLibertyApplicationSemeruCloudCompilerHealth {
1423+
return scc.Health
1424+
}
1425+
1426+
func (scch *WebSphereLibertyApplicationSemeruCloudCompilerHealth) GetPort() *int32 {
1427+
if scch.Port != nil {
1428+
return scch.Port
1429+
}
1430+
defaultPort := int32(38600)
1431+
return &defaultPort
1432+
}
1433+
14121434
// GetTopologySpreadConstraints returns the pod topology spread constraints configuration
14131435
func (cr *WebSphereLibertyApplication) GetTopologySpreadConstraints() common.BaseComponentTopologySpreadConstraints {
14141436
if cr.Spec.TopologySpreadConstraints == nil {

api/v1/zz_generated.deepcopy.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,14 @@ spec:
617617
path: semeruCloudCompiler.resources
618618
x-descriptors:
619619
- urn:alm:descriptor:com.tectonic.ui:resourceRequirements
620+
- description: The health settings for the Semeru Cloud Compiler.
621+
displayName: Health
622+
path: semeruCloudCompiler.health
623+
- description: The health port for the Semeru Cloud Compiler. Defaults to 38600.
624+
displayName: Port
625+
path: semeruCloudCompiler.health.port
626+
x-descriptors:
627+
- urn:alm:descriptor:com.tectonic.ui:number
620628
- description: 'Product edition. Defaults to IBM WebSphere Application Server.
621629
Other options: IBM WebSphere Application Server Liberty Core, IBM WebSphere
622630
Application Server Network Deployment'

bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5249,6 +5249,15 @@ spec:
52495249
enable:
52505250
description: Enable the Semeru Cloud Compiler. Defaults to false.
52515251
type: boolean
5252+
health:
5253+
description: The health settings for the Semeru Cloud Compiler.
5254+
properties:
5255+
port:
5256+
description: The health port for the Semeru Cloud Compiler.
5257+
Defaults to 38600.
5258+
format: int32
5259+
type: integer
5260+
type: object
52525261
replicas:
52535262
description: Number of desired pods for the Semeru Cloud Compiler.
52545263
Defaults to 1.

config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5245,6 +5245,15 @@ spec:
52455245
enable:
52465246
description: Enable the Semeru Cloud Compiler. Defaults to false.
52475247
type: boolean
5248+
health:
5249+
description: The health settings for the Semeru Cloud Compiler.
5250+
properties:
5251+
port:
5252+
description: The health port for the Semeru Cloud Compiler.
5253+
Defaults to 38600.
5254+
format: int32
5255+
type: integer
5256+
type: object
52485257
replicas:
52495258
description: Number of desired pods for the Semeru Cloud Compiler.
52505259
Defaults to 1.

config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,14 @@ spec:
553553
path: semeruCloudCompiler.resources
554554
x-descriptors:
555555
- urn:alm:descriptor:com.tectonic.ui:resourceRequirements
556+
- description: The health settings for the Semeru Cloud Compiler.
557+
displayName: Health
558+
path: semeruCloudCompiler.health
559+
- description: The health port for the Semeru Cloud Compiler. Defaults to 38600.
560+
displayName: Port
561+
path: semeruCloudCompiler.health.port
562+
x-descriptors:
563+
- urn:alm:descriptor:com.tectonic.ui:number
556564
- description: 'Product edition. Defaults to IBM WebSphere Application Server.
557565
Other options: IBM WebSphere Application Server Liberty Core, IBM WebSphere
558566
Application Server Network Deployment'

internal/controller/semeru_compiler.go

Lines changed: 108 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,65 @@ const (
4646
SemeruGenerationLabelNameSuffix = "/semeru-compiler-generation"
4747
StatusReferenceSemeruGeneration = "semeruGeneration"
4848
StatusReferenceSemeruInstancesCompleted = "semeruInstancesCompleted"
49+
SemeruContainerName = "compiler"
4950
)
5051

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{
52+
func getCompilerMeta(wlva *wlv1.WebSphereLibertyApplication) metav1.ObjectMeta {
53+
return metav1.ObjectMeta{
5454
Name: getSemeruCompilerNameWithGeneration(wlva),
5555
Namespace: wlva.GetNamespace(),
5656
}
57+
}
58+
59+
func getSemeruDeploymentContainer(deploy *appsv1.Deployment) (corev1.Container, error) {
60+
for _, container := range deploy.Spec.Template.Spec.Containers {
61+
if container.Name == SemeruContainerName {
62+
return container, nil
63+
}
64+
}
65+
return corev1.Container{}, fmt.Errorf("could not find the Semeru Deployment container")
66+
}
67+
68+
// Returns true if the semeru health port configuration has changed otherwise false
69+
func (r *ReconcileWebSphereLiberty) upgradeSemeruHealthPorts(inputMeta metav1.ObjectMeta, wlva *wlv1.WebSphereLibertyApplication) bool {
70+
var healthPort int32 = 38600
71+
if wlva.GetSemeruCloudCompiler().GetHealth() != nil {
72+
healthPort = *wlva.GetSemeruCloudCompiler().GetHealth().GetPort()
73+
}
74+
semeruDeployment := &appsv1.Deployment{ObjectMeta: inputMeta}
75+
if r.GetClient().Get(context.TODO(), types.NamespacedName{Name: semeruDeployment.Name, Namespace: semeruDeployment.Namespace}, semeruDeployment) == nil {
76+
container, err := getSemeruDeploymentContainer(semeruDeployment)
77+
if err != nil {
78+
return false
79+
}
80+
if healthPort == 38400 && len(container.Ports) > 1 {
81+
return true
82+
}
83+
containsHealthPort := false
84+
for _, port := range container.Ports {
85+
if port.ContainerPort == healthPort {
86+
containsHealthPort = true
87+
}
88+
}
89+
if !containsHealthPort {
90+
return true
91+
}
92+
}
93+
return false
94+
}
95+
96+
// Create the Deployment and Service objects for a Semeru Compiler used by a Websphere Liberty Application
97+
func (r *ReconcileWebSphereLiberty) reconcileSemeruCompiler(wlva *wlv1.WebSphereLibertyApplication) (error, string, bool) {
98+
compilerMeta := getCompilerMeta(wlva)
99+
100+
// check for any diffs that require generation changes
101+
if r.isSemeruEnabled(wlva) {
102+
upgradeRequired := r.upgradeSemeruHealthPorts(compilerMeta, wlva)
103+
if upgradeRequired {
104+
createNewSemeruGeneration(wlva) // update generation
105+
compilerMeta = getCompilerMeta(wlva) // adjust compilerMeta to reference the new generation
106+
}
107+
}
57108

58109
currentGeneration := getGeneration(wlva)
59110

@@ -255,6 +306,8 @@ func (r *ReconcileWebSphereLiberty) deleteCompletedSemeruInstances(wlva *wlv1.We
255306
}
256307

257308
func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphereLibertyApplication, deploy *appsv1.Deployment) {
309+
var port int32 = 38400
310+
var healthPort int32 = 38600
258311
deploy.Labels = getLabels(wlva)
259312
deploy.Spec.Strategy.Type = appsv1.RecreateDeploymentStrategyType
260313

@@ -276,11 +329,20 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
276329
limitsMemory := getQuantityFromLimitsOrDefault(instanceResources, corev1.ResourceMemory, "1200Mi")
277330
limitsCPU := getQuantityFromLimitsOrDefault(instanceResources, corev1.ResourceCPU, "2000m")
278331

332+
if semeruCloudCompiler.GetHealth() != nil {
333+
healthPort = *semeruCloudCompiler.GetHealth().GetPort()
334+
}
335+
var portIntOrStr intstr.IntOrString
336+
if healthPort == port {
337+
portIntOrStr = intstr.FromInt32(port)
338+
} else {
339+
portIntOrStr = intstr.FromString(fmt.Sprintf("%d-tcp", healthPort))
340+
}
279341
// Liveness probe
280342
livenessProbe := corev1.Probe{
281343
ProbeHandler: corev1.ProbeHandler{
282344
TCPSocket: &corev1.TCPSocketAction{
283-
Port: intstr.FromInt(38400),
345+
Port: portIntOrStr,
284346
},
285347
},
286348
InitialDelaySeconds: 10,
@@ -291,7 +353,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
291353
readinessProbe := corev1.Probe{
292354
ProbeHandler: corev1.ProbeHandler{
293355
TCPSocket: &corev1.TCPSocketAction{
294-
Port: intstr.FromInt(38400),
356+
Port: portIntOrStr,
295357
},
296358
},
297359
InitialDelaySeconds: 5,
@@ -301,6 +363,22 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
301363
semeruPodMatchLabels := map[string]string{
302364
"app.kubernetes.io/instance": getSemeruCompilerNameWithGeneration(wlva),
303365
}
366+
containerPorts := make([]corev1.ContainerPort, 0)
367+
containerPorts = append(containerPorts, corev1.ContainerPort{
368+
ContainerPort: port,
369+
Protocol: corev1.ProtocolTCP,
370+
})
371+
372+
healthProbesFlag := ""
373+
if healthPort != port {
374+
healthProbesFlag = " -XX:+JITServerHealthProbes" + fmt.Sprintf(" -XX:JITServerHealthProbePort=%d", healthPort)
375+
containerPorts[0].Name = fmt.Sprintf("%d-tcp", port)
376+
containerPorts = append(containerPorts, corev1.ContainerPort{
377+
Name: fmt.Sprintf("%d-tcp", healthPort),
378+
ContainerPort: healthPort,
379+
Protocol: corev1.ProtocolTCP,
380+
})
381+
}
304382
deploy.Spec.Template = corev1.PodTemplateSpec{
305383
ObjectMeta: metav1.ObjectMeta{
306384
Labels: getLabels(wlva),
@@ -333,16 +411,11 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
333411
},
334412
Containers: []corev1.Container{
335413
{
336-
Name: "compiler",
414+
Name: SemeruContainerName,
337415
Image: wlva.Status.GetImageReference(),
338416
ImagePullPolicy: *wlva.GetPullPolicy(),
339417
Command: []string{"jitserver"},
340-
Ports: []corev1.ContainerPort{
341-
{
342-
ContainerPort: 38400,
343-
Protocol: corev1.ProtocolTCP,
344-
},
345-
},
418+
Ports: containerPorts,
346419
Resources: corev1.ResourceRequirements{
347420
Requests: corev1.ResourceList{
348421
corev1.ResourceMemory: requestsMemory,
@@ -356,6 +429,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
356429
Env: []corev1.EnvVar{
357430
{Name: "OPENJ9_JAVA_OPTIONS", Value: "-XX:+JITServerLogConnections" +
358431
" -XX:+JITServerShareROMClasses" +
432+
healthProbesFlag +
359433
" -XX:JITServerSSLKey=/etc/x509/certs/tls.key" +
360434
" -XX:JITServerSSLCert=/etc/x509/certs/tls.crt"},
361435
},
@@ -413,16 +487,34 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
413487

414488
func reconcileSemeruService(svc *corev1.Service, wlva *wlv1.WebSphereLibertyApplication) {
415489
var port int32 = 38400
490+
var healthPort int32 = 38600
416491
var timeout int32 = 86400
417492
svc.Labels = getLabels(wlva)
418493
svc.Spec.Selector = getSelectors(wlva)
419494
utils.CustomizeServiceAnnotations(svc, wlva.GetDisableTopologyRouting())
420-
if len(svc.Spec.Ports) == 0 {
495+
numPorts := len(svc.Spec.Ports)
496+
if numPorts == 0 {
421497
svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{})
422498
}
499+
423500
svc.Spec.Ports[0].Protocol = corev1.ProtocolTCP
424501
svc.Spec.Ports[0].Port = port
425502
svc.Spec.Ports[0].TargetPort = intstr.FromInt(int(port))
503+
if wlva.GetSemeruCloudCompiler().GetHealth() != nil {
504+
healthPort = *wlva.GetSemeruCloudCompiler().GetHealth().GetPort()
505+
}
506+
if healthPort != port {
507+
numPorts = len(svc.Spec.Ports)
508+
if numPorts == 1 {
509+
svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{})
510+
}
511+
svc.Spec.Ports[0].Name = fmt.Sprintf("%d-tcp", port)
512+
svc.Spec.Ports[0].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", port))
513+
svc.Spec.Ports[1].Name = fmt.Sprintf("%d-tcp", healthPort)
514+
svc.Spec.Ports[1].Protocol = corev1.ProtocolTCP
515+
svc.Spec.Ports[1].Port = healthPort
516+
svc.Spec.Ports[1].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", healthPort))
517+
}
426518
svc.Spec.SessionAffinity = corev1.ServiceAffinityClientIP
427519
svc.Spec.SessionAffinityConfig = &corev1.SessionAffinityConfig{
428520
ClientIP: &corev1.ClientIPConfig{
@@ -585,14 +677,13 @@ func (r *ReconcileWebSphereLiberty) getSemeruJavaOptions(instance *wlv1.WebSpher
585677
certificateLocation = "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
586678
}
587679
jitServerAddress := instance.Status.SemeruCompiler.ServiceHostname
588-
jitSeverOptions := fmt.Sprintf("-XX:+UseJITServer -XX:+JITServerLogConnections -XX:JITServerAddress=%v -XX:JITServerSSLRootCerts=%v",
589-
jitServerAddress, certificateLocation)
680+
jitServerOptions := fmt.Sprintf("-XX:+UseJITServer -XX:+JITServerLogConnections -XX:JITServerAddress=%v -XX:JITServerSSLRootCerts=%v", jitServerAddress, certificateLocation)
590681

591682
args := []string{
592683
"/bin/bash",
593684
"-c",
594-
"export OPENJ9_JAVA_OPTIONS=\"$OPENJ9_JAVA_OPTIONS " + jitSeverOptions +
595-
"\" && export OPENJ9_RESTORE_JAVA_OPTIONS=\"$OPENJ9_RESTORE_JAVA_OPTIONS " + jitSeverOptions +
685+
"export OPENJ9_JAVA_OPTIONS=\"$OPENJ9_JAVA_OPTIONS " + jitServerOptions +
686+
"\" && export OPENJ9_RESTORE_JAVA_OPTIONS=\"$OPENJ9_RESTORE_JAVA_OPTIONS " + jitServerOptions +
596687
"\" && server run",
597688
}
598689
return args

internal/deploy/kubectl/websphereliberty-app-crd.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5248,6 +5248,15 @@ spec:
52485248
enable:
52495249
description: Enable the Semeru Cloud Compiler. Defaults to false.
52505250
type: boolean
5251+
health:
5252+
description: The health settings for the Semeru Cloud Compiler.
5253+
properties:
5254+
port:
5255+
description: The health port for the Semeru Cloud Compiler.
5256+
Defaults to 38600.
5257+
format: int32
5258+
type: integer
5259+
type: object
52515260
replicas:
52525261
description: Number of desired pods for the Semeru Cloud Compiler.
52535262
Defaults to 1.

internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5248,6 +5248,15 @@ spec:
52485248
enable:
52495249
description: Enable the Semeru Cloud Compiler. Defaults to false.
52505250
type: boolean
5251+
health:
5252+
description: The health settings for the Semeru Cloud Compiler.
5253+
properties:
5254+
port:
5255+
description: The health port for the Semeru Cloud Compiler.
5256+
Defaults to 38600.
5257+
format: int32
5258+
type: integer
5259+
type: object
52515260
replicas:
52525261
description: Number of desired pods for the Semeru Cloud Compiler.
52535262
Defaults to 1.

0 commit comments

Comments
 (0)