You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks for contributing to the Docker-Selenium project! A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
chart(add): Set pod/container name to node stereotypes
Motivation and Context
se:containerName is added by default to Node stereotypes via env var SE_NODE_CONTAINER_NAME
This is useful in few scenarios as below:
In Kubernetes deployment, we can track the node is running in which pod name by setting metadata.name to the env var. For example:
Script Robustness The script uses curl to fetch the latest Helm version without error handling. If the curl or grep command fails, it might set an empty or incorrect HELM_VERSION, which could lead to further issues in the script execution. Consider adding error handling after the curl command to ensure that a valid version is fetched and processed.
Environment Variable Injection The addition of SE_NODE_CONTAINER_NAME environment variable is hardcoded to use metadata.name. This might not be flexible for different deployment scenarios where a different container naming convention is needed. Consider making this configurable through values in the Helm chart.
Code Duplication The SE_NODE_STEREOTYPE JSON string is manually constructed in multiple places (NodeBase/generate_config and Standalone/generate_config). This could lead to inconsistencies and maintenance issues. Consider centralizing the construction of this JSON in a shared utility function or script.
Add error handling for the curl command fetching the latest Helm version
To ensure the script is robust against potential failures when fetching the latest Helm version, it's advisable to check the success of the curl command before proceeding. This can be achieved by checking the exit status of the curl command. If the command fails, the script should handle this gracefully, possibly by reverting to a default version of Helm or by exiting with an error message.
Why: This suggestion adds robust error handling for the curl command, ensuring the script can handle failures gracefully. This is crucial for maintaining script reliability.
9
Best practice
Use jq to dynamically generate the JSON string for SE_NODE_STEREOTYPE
The JSON string for SE_NODE_STEREOTYPE should properly handle JSON encoding to avoid issues with special characters in variable values. Using a tool like jq can help create a valid JSON string dynamically.
Why: Using jq ensures proper JSON encoding and handling of special characters, which is a best practice for generating JSON strings dynamically.
8
Implement jq for JSON string creation in SE_NODE_STEREOTYPE to ensure proper encoding
Similar to the suggestion for NodeBase/generate_config, using jq for generating JSON ensures proper encoding and handling of special characters in the SE_NODE_STEREOTYPE variable.
Why: Similar to the previous suggestion, using jq ensures proper JSON encoding and handling of special characters, improving the reliability of the script.
8
Enhancement
Add a conditional check for metadata.name before setting SE_NODE_CONTAINER_NAME
It is recommended to use a conditional check to ensure that the metadata.name field is available before using it to set the SE_NODE_CONTAINER_NAME. This can prevent potential runtime errors in environments where metadata might not be fully available or in expected format.
+{{- if .node.metadata.name }}
- name: SE_NODE_CONTAINER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
+{{- end }}
Apply this suggestion
Suggestion importance[1-10]: 7
Why: Adding a conditional check for metadata.name can prevent potential runtime errors, enhancing the robustness of the template. However, the likelihood of metadata.name being unavailable is low.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Thanks for contributing to the Docker-Selenium project!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
chart(add): Set pod/container name to node stereotypes
Motivation and Context
se:containerName
is added by default to Node stereotypes via env varSE_NODE_CONTAINER_NAME
This is useful in few scenarios as below:
metadata.name
to the env var. For example:Via Grid UI can see stereotypes
Session capabilities can see:
Types of changes
Checklist
PR Type
Enhancement, Configuration changes
Description
HELM_VERSION
is set to "latest" inchart_setup_env.sh
.SE_NODE_CONTAINER_NAME
environment variable to Kubernetes node configuration, setting it to the pod metadata name.se:containerName
in the default node stereotype configuration inNodeBase/generate_config
andStandalone/generate_config
.Changes walkthrough 📝
chart_setup_env.sh
Dynamically fetch the latest Helm version if specified
tests/charts/make/chart_setup_env.sh
HELM_VERSION
isset to "latest".
_helpers.tpl
Add SE_NODE_CONTAINER_NAME environment variable to Kubernetes nodes
charts/selenium-grid/templates/_helpers.tpl
SE_NODE_CONTAINER_NAME
to Kubernetes nodeconfiguration.
SE_NODE_CONTAINER_NAME
to Kubernetes pod metadata name.generate_config
Include container name in default node stereotype
NodeBase/generate_config
se:containerName
to the default node stereotype configuration.generate_config
Include container name in default node stereotype
Standalone/generate_config
se:containerName
to the default node stereotype configuration.config.yml
Update Kubernetes and Helm versions in CircleCI config
.circleci/config.yml
helm-chart-test.yml
Update Kubernetes and Helm versions in GitHub Actions
.github/workflows/helm-chart-test.yml