Skip to content

Docker: Resolve default component port via env var #2689

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
Mar 3, 2025

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Mar 2, 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

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

  • Updated environment variables for default ports across components.

  • Replaced SE_SESSIONS_HOST and SE_SESSIONS_PORT with SE_SESSIONS_MAP_HOST and SE_SESSIONS_MAP_PORT.

  • Added default port values for several components in Dockerfiles and documentation.

  • Simplified docker-compose files by removing redundant environment variables.


Changes walkthrough 📝

Relevant files
Enhancement
1 files
start-selenium-grid-sessions.sh
Replace `SE_SESSIONS_HOST` and `SE_SESSIONS_PORT` with new variables
+6/-6     
Configuration changes
15 files
Dockerfile
Add default port environment variables for Distributor     
+5/-0     
Dockerfile
Add default port environment variables for EventBus           
+4/-1     
Dockerfile
Add default port environment variable for Hub                       
+1/-0     
Dockerfile
Add default port environment variables for Router               
+4/-0     
Dockerfile
Add default port environment variable for SessionQueue     
+1/-0     
Dockerfile
Add default port environment variables for Sessions           
+3/-0     
session-map-deployment.yaml
Update environment variables for session map deployment   
+2/-2     
docker-compose-v3-full-grid-dev.yml
Simplify environment variables for development compose file
+0/-16   
docker-compose-v3-full-grid-external-datastore.yml
Simplify environment variables for external datastore compose file
+0/-16   
docker-compose-v3-full-grid-nightly.yml
Simplify environment variables for nightly compose file   
+0/-16   
docker-compose-v3-full-grid-secure.yml
Simplify environment variables for secure compose file     
+0/-16   
docker-compose-v3-full-grid-tracing.yml
Simplify environment variables for tracing compose file   
+0/-16   
docker-compose-v3-full-grid.yml
Simplify environment variables for default compose file   
+0/-16   
description.yaml
Remove deprecated session environment variables                   
+0/-6     
value.yaml
Add default values for new environment variables                 
+6/-10   
Documentation
1 files
ENV_VARIABLES.md
Document default port values for environment variables     
+6/-8     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    qodo-merge-pro bot commented Mar 2, 2025

    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

    Variable Renaming

    The script replaces SE_SESSIONS_HOST/PORT with SE_SESSIONS_MAP_HOST/PORT. Verify that all dependent components and configurations are updated accordingly to use the new variable names.

    if [ ! -z "${SE_SESSIONS_MAP_HOST}" ]; then
      echo "Using SE_SESSIONS_MAP_HOST: ${SE_SESSIONS_MAP_HOST}"
      HOST_CONFIG="--host ${SE_SESSIONS_MAP_HOST}"
    fi
    
    if [ ! -z "${SE_SESSIONS_MAP_PORT}" ]; then
      echo "Using SE_SESSIONS_MAP_PORT: ${SE_SESSIONS_MAP_PORT}"
      PORT_CONFIG="--port ${SE_SESSIONS_MAP_PORT}"
    fi

    Copy link
    Contributor

    qodo-merge-pro bot commented Mar 2, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Validate port number range

    Add validation to ensure the port number is within valid range (1-65535) before
    using it in PORT_CONFIG to prevent potential network configuration issues.

    Sessions/start-selenium-grid-sessions.sh [49-52]

     if [ ! -z "${SE_SESSIONS_MAP_PORT}" ]; then
    -  echo "Using SE_SESSIONS_MAP_PORT: ${SE_SESSIONS_MAP_PORT}"
    -  PORT_CONFIG="--port ${SE_SESSIONS_MAP_PORT}"
    +  if [[ "${SE_SESSIONS_MAP_PORT}" =~ ^[0-9]+$ ]] && [ "${SE_SESSIONS_MAP_PORT}" -ge 1 ] && [ "${SE_SESSIONS_MAP_PORT}" -le 65535 ]; then
    +    echo "Using SE_SESSIONS_MAP_PORT: ${SE_SESSIONS_MAP_PORT}"
    +    PORT_CONFIG="--port ${SE_SESSIONS_MAP_PORT}"
    +  else
    +    echo "Error: SE_SESSIONS_MAP_PORT must be a number between 1 and 65535"
    +    exit 1
    +  fi
     fi
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion adds crucial input validation for port numbers, preventing potential network configuration issues and system failures. This is an important security and reliability improvement.

    Medium
    • Update

    Copy link
    Contributor

    qodo-merge-pro bot commented Mar 2, 2025

    CI Feedback 🧐

    (Feedback updated until commit 5c63630)

    A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

    Action: Rerun workflow when failure

    Failed stage: Authenticate GitHub CLI for PR [❌]

    Failure summary:

    The action failed because the GitHub authentication token lacks the required 'read:org' scope
    permission. The error occurred during the gh auth login command, which requires proper token
    permissions to authenticate with GitHub CLI.

    Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    28:  SecurityEvents: write
    29:  Statuses: write
    30:  ##[endgroup]
    31:  Secret source: Actions
    32:  Prepare workflow directory
    33:  Prepare all required actions
    34:  Getting action download info
    35:  Download action repository 'actions/checkout@main' (SHA:85e6279cec87321a52edac9c87bce653a07cf6c2)
    36:  Complete job name: Rerun workflow when failure
    ...
    
    48:  show-progress: true
    49:  lfs: false
    50:  submodules: false
    51:  set-safe-directory: true
    52:  env:
    53:  GH_CLI_TOKEN: ***
    54:  GH_CLI_TOKEN_PR: ***
    55:  RUN_ID: 13619893345
    56:  RERUN_FAILED_ONLY: true
    ...
    
    119:  ##[group]Run sudo apt update
    120:  �[36;1msudo apt update�[0m
    121:  �[36;1msudo apt install gh�[0m
    122:  shell: /usr/bin/bash -e {0}
    123:  env:
    124:  GH_CLI_TOKEN: ***
    125:  GH_CLI_TOKEN_PR: ***
    126:  RUN_ID: 13619893345
    127:  RERUN_FAILED_ONLY: true
    ...
    
    176:  0 upgraded, 0 newly installed, 0 to remove and 46 not upgraded.
    177:  ##[group]Run echo "$GH_CLI_TOKEN_PR" | gh auth login --with-token
    178:  �[36;1mecho "$GH_CLI_TOKEN_PR" | gh auth login --with-token�[0m
    179:  shell: /usr/bin/bash -e {0}
    180:  env:
    181:  GH_CLI_TOKEN: ***
    182:  GH_CLI_TOKEN_PR: ***
    183:  RUN_ID: 13619893345
    184:  RERUN_FAILED_ONLY: true
    185:  RUN_ATTEMPT: 1
    186:  ##[endgroup]
    187:  error validating token: missing required scope 'read:org'
    188:  ##[error]Process completed with exit code 1.
    

    @VietND96 VietND96 force-pushed the default-port-env-var branch from b110e85 to 5c63630 Compare March 2, 2025 22:24
    Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
    @VietND96 VietND96 force-pushed the default-port-env-var branch from 5c63630 to 54b47f3 Compare March 3, 2025 00:29
    @VietND96 VietND96 merged commit 966a78a into trunk Mar 3, 2025
    24 of 26 checks passed
    @VietND96 VietND96 deleted the default-port-env-var branch March 3, 2025 00:30
    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