Skip to content

Commit

Permalink
chart(fix): trim trailing slash in sub path
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Aug 21, 2024
1 parent 114d008 commit 2adc4a2
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 9 deletions.
1 change: 0 additions & 1 deletion .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@main
- name: Set up containerd image store feature
if: matrix.test-strategy != 'test_node_relay'
uses: nick-invision/retry@master
with:
timeout_minutes: 10
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CHART_VERSION_NIGHTLY := $(or $(CHART_VERSION_NIGHTLY),$(CHART_VERSION_NIGHTLY),
NAMESPACE := $(or $(NAMESPACE),$(NAMESPACE),$(NAME))
AUTHORS := $(or $(AUTHORS),$(AUTHORS),SeleniumHQ)
PUSH_IMAGE := $(or $(PUSH_IMAGE),$(PUSH_IMAGE),false)
FROM_IMAGE_ARGS := --build-arg NAMESPACE=$(NAMESPACE) --build-arg VERSION=$(TAG_VERSION) --build-arg AUTHORS=$(AUTHORS)
FROM_IMAGE_ARGS := --build-arg NAMESPACE=$(NAMESPACE) --build-arg VERSION=$(TAG_VERSION) --build-arg AUTHORS=$(AUTHORS) --sbom=true --attest type=provenance,mode=max
BUILD_ARGS := $(BUILD_ARGS)
MAJOR := $(word 1,$(subst ., ,$(TAG_VERSION)))
MINOR := $(word 2,$(subst ., ,$(TAG_VERSION)))
Expand Down Expand Up @@ -75,7 +75,7 @@ gen_certs:
./Base/certs/gen-cert-helper.sh -d ./Base/certs

base: prepare_resources gen_certs
cd ./Base && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION) --build-arg RELEASE=$(BASE_RELEASE) --build-arg AUTHORS=$(AUTHORS) -t $(NAME)/base:$(TAG_VERSION) .
cd ./Base && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION) --build-arg RELEASE=$(BASE_RELEASE) --build-arg AUTHORS=$(AUTHORS) --sbom=true --attest type=provenance,mode=max -t $(NAME)/base:$(TAG_VERSION) .

base_nightly:
BASE_VERSION=$(BASE_VERSION_NIGHTLY) BASE_RELEASE=$(BASE_RELEASE_NIGHTLY) make base
Expand Down
4 changes: 2 additions & 2 deletions charts/selenium-grid/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: selenium-grid
description: A Helm chart for creating a Selenium Grid Server in Kubernetes
type: application
version: 0.34.2
version: 0.34.3
appVersion: 4.23.1-20240820
icon: https://github.com/SeleniumHQ/docker-selenium/raw/trunk/logo.png
dependencies:
Expand All @@ -19,7 +19,7 @@ dependencies:
name: jaeger
condition: tracing.enabled, jaeger.enabled
- repository: https://prometheus-community.github.io/helm-charts
version: 62.0.0
version: 62.1.0
name: kube-prometheus-stack
condition: monitoring.enabled, prometheus-stack.enabled
maintainers:
Expand Down
9 changes: 9 additions & 0 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ Graphql Url of the hub or the router
{{- else -}}
{{- $subPath = default $subPath $.Values.hub.subPath -}}
{{- end -}}
{{- $subPath = include "utils.trimTrailingSlash" $subPath -}}
{{- $subPath }}
{{- end -}}

Expand Down Expand Up @@ -823,6 +824,14 @@ Define terminationGracePeriodSeconds of the node pod.
{{- not (empty $videoVolumes) | ternary $videoVolumes "" -}}
{{- end -}}

{{- define "utils.trimTrailingSlash" -}}
{{- $path := . -}}
{{- if hasSuffix "/" $path -}}
{{- $path = trimSuffix "/" $path -}}
{{- end -}}
{{- $path -}}
{{- end -}}

{{/*
Is used to append default items needed to an array if they are not already present. Args: currentArray, defaultArray, uniqueKey
Usage: {{- $thisArray = include "utils.appendDefaultIfNotExist" (dict "currentArray" $thisArray "defaultArray" $defaultArray "uniqueKey" $uniqueKey }}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/hub-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ spec:
value: {{ .Values.hub.port | quote }}
{{- with .Values.hub.subPath }}
- name: SE_SUB_PATH
value: {{ . | quote }}
value: {{ include "utils.trimTrailingSlash" . | quote }}
{{- end }}
{{- if .Values.hub.disableUI }}
- name: SE_DISABLE_UI
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/router-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
value: {{ .Values.components.sessionQueue.port | quote }}
{{- with .Values.components.subPath }}
- name: SE_SUB_PATH
value: {{ . | quote }}
value: {{ include "utils.trimTrailingSlash" . | quote }}
{{- end }}
{{- if .Values.components.router.disableUI }}
- name: SE_DISABLE_UI
Expand Down
2 changes: 1 addition & 1 deletion tests/charts/templates/render/dummy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ingress:
annotations: # Add you own annotations
nginx.ingress.kubernetes.io/use-regex: "true" # Add new key
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/app-root: &gridAppRoot "/selenium"
nginx.ingress.kubernetes.io/app-root: &gridAppRoot "/selenium/"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600" # Override default key
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" # Override default key
hostname: ""
Expand Down
2 changes: 1 addition & 1 deletion tests/charts/templates/render/dummy_solution.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ selenium-grid:
annotations: # Add you own annotations
nginx.ingress.kubernetes.io/use-regex: "true" # Add new key
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/app-root: &gridAppRoot "/selenium"
nginx.ingress.kubernetes.io/app-root: &gridAppRoot "/selenium/"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600" # Override default key
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" # Override default key
hostname: ""
Expand Down
10 changes: 10 additions & 0 deletions tests/charts/templates/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ def test_sub_path_set_to_grid_env_var(self):
is_present = True
self.assertTrue(is_present, "ENV variable SE_SUB_PATH is not populated")

def test_graphql_url_for_autoscaling_constructed_correctly(self):
resources_name = ['{0}selenium-chrome-node'.format(RELEASE_NAME),]
count = 0
for doc in LIST_OF_DOCUMENTS:
if doc['metadata']['name'] in resources_name and doc['kind'] == 'ScaledObject':
logger.info(f"Assert trigger url is set GraphQL endpoint in resource {doc['metadata']['name']}")
self.assertTrue(doc['spec']['triggers'][0]['metadata']['url'] == 'https://sysadmin:strongPassword@{0}selenium-router.default:4444/selenium/graphql'.format(RELEASE_NAME))
count += 1
self.assertEqual(count, len(resources_name), "GraphQL endpoint is not set correctly")

def test_distributor_new_session_thread_pool_size(self):
resources_name = ['{0}selenium-distributor'.format(RELEASE_NAME)]
is_present = False
Expand Down

0 comments on commit 2adc4a2

Please sign in to comment.