From 3aadfd3a09352e124358de95bbd69d861329b584 Mon Sep 17 00:00:00 2001 From: Sufiyan Baig Date: Mon, 16 Mar 2026 03:13:30 +0000 Subject: [PATCH 1/3] feat(api): harden WebServer schema with validation and defaults This commit improves the API contract by: - Adding Kubebuilder markers for ImageStream and Source URL validation. - Implementing safe defaults for S2I build references (master branch, root context). - Enforcing mandatory readiness probes to ensure deployment stability. - Updating samples to reflect best practices for JBoss Web Server on OpenShift. --- api/v1alpha1/webserver_types.go | 19 ++++++++--- .../crd/bases/web.servers.org_webservers.yaml | 32 +++++++++++++++---- config/samples/v1alpha1_webserver.yaml | 29 +++++++++++++++-- 3 files changed, 65 insertions(+), 15 deletions(-) diff --git a/api/v1alpha1/webserver_types.go b/api/v1alpha1/webserver_types.go index 589655d9..5ff70e97 100644 --- a/api/v1alpha1/webserver_types.go +++ b/api/v1alpha1/webserver_types.go @@ -176,18 +176,23 @@ type PersistentLogs struct { DeleteLogClaims bool `json:"deleteClaimOnDeletion,omitempty"` } +// (Optional) Source code information // (Optional) Source code information type WebSourcesSpec struct { - // URL for the repository of the application sources + // URL for the repository of the application sources. + // Must be a valid Git URL. Example: 'https://github.com/jboss-openshift/tomee-demo.git' + // +kubebuilder:validation:Pattern=`^(http|https|git)://.*$` // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Source Repository URL",order=1 SourceRepositoryURL string `json:"sourceRepositoryUrl"` // Secret for the repository of the application sources // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Source Repository Secret",order=2 SourceRepositorySecret string `json:"sourceRepositorySecret,omitempty"` - // Branch in the source repository + // Branch or tag in the source repository. Defaults to 'master' if not specified. + // +kubebuilder:default:="master" // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Source Repository Reference",order=3 SourceRepositoryRef string `json:"sourceRepositoryRef,omitempty"` - // Subdirectory in the source repository + // Subdirectory within the source repository where the application code resides. Defaults to the root directory ('.'). + // +kubebuilder:default:="." // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Context Directory",order=4 ContextDir string `json:"contextDir,omitempty"` // (Optional) Sources related parameters @@ -227,10 +232,14 @@ type WebhookSecrets struct { } type WebServerHealthCheckSpec struct { - // String for the pod readiness health check logic + // Shell command or script to determine if the JWS instance is ready to accept traffic. + // Example: '/usr/bin/curl -f http://localhost:8080/' + // +kubebuilder:validation:MinLength=1 // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Server Readiness Script",order=1 ServerReadinessScript string `json:"serverReadinessScript"` - // String for the pod liveness health check logic + + // Shell command or script to determine if the container is still healthy. If it fails, the container is restarted. + // Example: '/usr/bin/pgrep -f java' // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Server Liveness Script",order=2 ServerLivenessScript string `json:"serverLivenessScript,omitempty"` } diff --git a/config/crd/bases/web.servers.org_webservers.yaml b/config/crd/bases/web.servers.org_webservers.yaml index e5965fd2..dd132f21 100644 --- a/config/crd/bases/web.servers.org_webservers.yaml +++ b/config/crd/bases/web.servers.org_webservers.yaml @@ -783,10 +783,15 @@ spec: description: Pod health checks information properties: serverLivenessScript: - description: String for the pod liveness health check logic + description: |- + Shell command or script to determine if the container is still healthy. If it fails, the container is restarted. + Example: '/usr/bin/pgrep -f java' type: string serverReadinessScript: - description: String for the pod readiness health check logic + description: |- + Shell command or script to determine if the JWS instance is ready to accept traffic. + Example: '/usr/bin/curl -f http://localhost:8080/' + minLength: 1 type: string required: - serverReadinessScript @@ -807,10 +812,15 @@ spec: description: Pod health checks information properties: serverLivenessScript: - description: String for the pod liveness health check logic + description: |- + Shell command or script to determine if the container is still healthy. If it fails, the container is restarted. + Example: '/usr/bin/pgrep -f java' type: string serverReadinessScript: - description: String for the pod readiness health check logic + description: |- + Shell command or script to determine if the JWS instance is ready to accept traffic. + Example: '/usr/bin/curl -f http://localhost:8080/' + minLength: 1 type: string required: - serverReadinessScript @@ -819,17 +829,25 @@ spec: description: (Optional) Source code information properties: contextDir: - description: Subdirectory in the source repository + default: . + description: Subdirectory within the source repository where + the application code resides. Defaults to the root directory + ('.'). type: string sourceRepositoryRef: - description: Branch in the source repository + default: master + description: Branch or tag in the source repository. Defaults + to 'master' if not specified. type: string sourceRepositorySecret: description: Secret for the repository of the application sources type: string sourceRepositoryUrl: - description: URL for the repository of the application sources + description: |- + URL for the repository of the application sources. + Must be a valid Git URL. Example: 'https://github.com/jboss-openshift/tomee-demo.git' + pattern: ^(http|https|git)://.*$ type: string webSourcesParams: description: (Optional) Sources related parameters diff --git a/config/samples/v1alpha1_webserver.yaml b/config/samples/v1alpha1_webserver.yaml index 1cf9295a..246536bb 100644 --- a/config/samples/v1alpha1_webserver.yaml +++ b/config/samples/v1alpha1_webserver.yaml @@ -1,8 +1,31 @@ apiVersion: web.servers.org/v1alpha1 kind: WebServer metadata: - name: webserver-example + name: jws-imagestream-sample spec: - applicationName: webapp + # Base name for application resources (Deployment, Service, etc.) + applicationName: "jws-app" + + # Instance count. +kubebuilder:validation:Minimum=0 replicas: 1 - useInsightsClient: false + + # Deployment Method: ImageStream (Recommended for OpenShift S2I builds) + webImageStream: + # Target ImageStream. Example: 'jws56-openjdk11-openshift' + imageStreamName: "jws56-openjdk11-openshift" + # Target namespace. Defaults to current namespace if omitted. + imageStreamNamespace: "openshift" + + # Source-to-Image (S2I) configuration + webSources: + # Valid Git URI. Pattern: ^(http|https|git)://.*$ + sourceRepositoryUrl: "https://github.com/jboss-openshift/tomee-demo.git" + # Target branch/tag. Defaults to 'master'. + sourceRepositoryRef: "master" + # Context directory for build. Defaults to '.'. + contextDir: "." + + # Probe configuration to manage pod lifecycle + webServerHealthCheck: + # Required. Command to verify JWS is ready for traffic. + serverReadinessScript: "/usr/bin/curl -f http://localhost:8080/" \ No newline at end of file From 7ffa848f4af972f8ed685a9add393325859cb673 Mon Sep 17 00:00:00 2001 From: Sufiyan Baig Date: Mon, 16 Mar 2026 03:28:21 +0000 Subject: [PATCH 2/3] fix: address linting and sync with main --- api/v1alpha1/webserver_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1alpha1/webserver_types.go b/api/v1alpha1/webserver_types.go index 5ff70e97..af1bee29 100644 --- a/api/v1alpha1/webserver_types.go +++ b/api/v1alpha1/webserver_types.go @@ -179,7 +179,7 @@ type PersistentLogs struct { // (Optional) Source code information // (Optional) Source code information type WebSourcesSpec struct { - // URL for the repository of the application sources. + // URL for the repository of the application sources. // Must be a valid Git URL. Example: 'https://github.com/jboss-openshift/tomee-demo.git' // +kubebuilder:validation:Pattern=`^(http|https|git)://.*$` // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Source Repository URL",order=1 From 5d170adc117c9f3ea785674407e8a091a316fcf0 Mon Sep 17 00:00:00 2001 From: Sufiyan Baig Date: Mon, 16 Mar 2026 03:32:38 +0000 Subject: [PATCH 3/3] fix: trigger CI rerun for infrastructure failure