Skip to content

K8s: Node enable readiness probe checks status registered to Hub #2833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented May 15, 2025

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

From v4.31.0 - [grid] Expose register status via Node status response (SeleniumHQ/selenium#15448)
By default, enable readiness probe checks in the Node listen on value true/false of $.value.registered

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement, Documentation


Description

  • Introduced readiness probe script to check node registration status.

    • Adds nodeProbeReadiness.sh for readiness checks via /status endpoint.
    • Uses .value.registered from node status for probe success.
  • Enabled readiness probes by default for all node types.

    • Updates readinessProbe.enabled to true for chrome, firefox, edge, and relay nodes.
  • Enhanced Helm chart to support exec-based readiness probes.

    • Adds defaultNodeReadinessProbe and script wiring in templates.
  • Updated documentation for new readiness probe settings.

    • Documents new values and script options in CONFIGURATION.md.

Changes walkthrough 📝

Relevant files
Enhancement
nodeProbeReadiness.sh
Add readiness probe script for node registration status   

charts/selenium-grid/configs/node/nodeProbeReadiness.sh

  • Adds new bash script for readiness probe.
  • Checks node registration via /status endpoint.
  • Exits with failure if node is not registered.
  • +16/-0   
    _helpers.tpl
    Integrate exec-based readiness probe into Helm templates 

    charts/selenium-grid/templates/_helpers.tpl

  • Updates readinessProbe logic to support exec-based probe.
  • Integrates nodeProbeReadiness.sh script for readiness checks.
  • Adjusts indentation for probe configuration.
  • +4/-1     
    values.yaml
    Enable and configure readiness probes in values.yaml         

    charts/selenium-grid/values.yaml

  • Sets defaultNodeReadinessProbe to exec by default.
  • Enables readinessProbe for chrome, firefox, edge, and relay nodes.
  • Adds nodeProbeReadiness.sh to extraScripts.
  • +8/-4     
    Documentation
    CONFIGURATION.md
    Update documentation for readiness probe enhancements       

    charts/selenium-grid/CONFIGURATION.md

  • Documents new defaultNodeReadinessProbe setting.
  • Adds nodeProbeReadiness.sh to extraScripts documentation.
  • Updates readinessProbe defaults for all node types to enabled.
  • +6/-4     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Error Handling

    The script doesn't handle cases where the curl command fails or returns invalid JSON. Consider adding error handling for network issues or malformed responses.

    response=$(curl -skSL --noproxy "*" "${ENDPOINT}")
    
    Duplicate Comment

    There's a duplicate comment for defaultNodeReadinessProbe and defaultNodeLivenessProbe - both say "Set default readiness probe method for all nodes".

    defaultNodeReadinessProbe: exec
    # -- Set default readiness probe method for all nodes (supplied values: httpGet, exec). If not set, the default is httpGet
    defaultNodeLivenessProbe: exec

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add connection error handling

    Add error handling for the curl command to detect connection failures.
    Currently, if the curl command fails (e.g., if the node service isn't running),
    the script will still try to parse the empty response with jq, potentially
    causing misleading errors.

    charts/selenium-grid/configs/node/nodeProbeReadiness.sh [7-11]

     response=$(curl -skSL --noproxy "*" "${ENDPOINT}")
    +
    +# Check if curl command succeeded
    +if [ $? -ne 0 ]; then
    +  echo "$(date -u +"${ts_format}") [${probe_name}] - Readiness check failed: Unable to connect to node endpoint."
    +  exit 1
    +fi
     
     # Validate the JSON response
     # From v4.31.0 - [grid] Expose register status via Node status response (#15448)
     if echo "$response" | jq -e '.value.registered == true' > /dev/null; then
    • Apply / Chat
    Suggestion importance[1-10]: 7

    __

    Why: Adding error handling for the curl command is a solid improvement, as it prevents misleading errors if the endpoint is unreachable and provides clearer diagnostics. This enhances the script's robustness, though it is not a critical bug fix.

    Medium
    Validate jq command availability

    Add validation to check if jq command is available before using it. If jq is
    missing, the script will fail silently with a misleading error message about the
    node not being registered.

    charts/selenium-grid/configs/node/nodeProbeReadiness.sh [11-16]

    +if ! command -v jq &> /dev/null; then
    +  echo "$(date -u +"${ts_format}") [${probe_name}] - Readiness check failed: jq command not found."
    +  exit 1
    +fi
    +
     if echo "$response" | jq -e '.value.registered == true' > /dev/null; then
       echo "$(date -u +"${ts_format}") [${probe_name}] - Readiness check passed: Node is registered."
     else
       echo "$(date -u +"${ts_format}") [${probe_name}] - Readiness check failed: Node is not registered."
       exit 1
     fi
    • Apply / Chat
    Suggestion importance[1-10]: 7

    __

    Why: Checking for the presence of jq before using it prevents confusing failures and improves script reliability, but this is a standard defensive scripting practice rather than a critical fix.

    Medium
    • More

    @VietND96 VietND96 merged commit e2abe9f into trunk May 15, 2025
    26 of 27 checks passed
    @VietND96 VietND96 deleted the node-readiness branch May 15, 2025 18:39
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant