Skip to content

[Helm Chart] only add annotations stanza if they are annotations to add #2580

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
Jan 13, 2025
Merged

Conversation

KyriosGN0
Copy link
Contributor

@KyriosGN0 KyriosGN0 commented Jan 13, 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.

when deploying with argocd and with existing KEDA, we want to deploy the scaledJob without helm hooks, since the template for those objects doesn't check if they annotations exist, when passing null to the annotations section in the values.yaml, it will cause argocd to be in a content state of diff with the templated yaml file.

Description

this PR wraps the annotations section of the scaledJobs template in an if statement, only if there are annotations it will create that section, if they are none, that annotations key is not templated.

Motivation and Context

to not have constant diff in argocd when deploying seleniun grid with the chart and with existing keda without helm hooks

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

Bug fix


Description

  • Added conditional logic for annotations in ScaledJob templates.

  • Prevents unnecessary diffs in ArgoCD when annotations are null.

  • Updated templates for Chrome, Edge, Firefox, and Relay nodes.

  • Ensures compatibility with existing KEDA deployments without Helm hooks.


Changes walkthrough 📝

Relevant files
Bug fix
chrome-node-scaledjobs.yaml
Add conditional annotations logic for Chrome node               

charts/selenium-grid/templates/chrome-node-scaledjobs.yaml

  • Added if condition to include annotations only if defined.
  • Prevents unnecessary diffs in ArgoCD for Chrome node ScaledJob.
  • +2/-0     
    edge-node-scaledjob.yaml
    Add conditional annotations logic for Edge node                   

    charts/selenium-grid/templates/edge-node-scaledjob.yaml

  • Added if condition to include annotations only if defined.
  • Prevents unnecessary diffs in ArgoCD for Edge node ScaledJob.
  • +2/-0     
    firefox-node-scaledjob.yaml
    Add conditional annotations logic for Firefox node             

    charts/selenium-grid/templates/firefox-node-scaledjob.yaml

  • Added if condition to include annotations only if defined.
  • Prevents unnecessary diffs in ArgoCD for Firefox node ScaledJob.
  • +2/-0     
    relay-node-scaledjobs.yaml
    Add conditional annotations logic for Relay node                 

    charts/selenium-grid/templates/relay-node-scaledjobs.yaml

  • Added if condition to include annotations only if defined.
  • Prevents unnecessary diffs in ArgoCD for Relay node ScaledJob.
  • +2/-0     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @CLAassistant
    Copy link

    CLAassistant commented Jan 13, 2025

    CLA assistant check
    All committers have signed the CLA.

    @KyriosGN0 KyriosGN0 marked this pull request as ready for review January 13, 2025 13:55
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Enhance conditional check to prevent creation of empty annotation sections in Kubernetes manifests

    The condition should check if annotations is both defined and non-empty to prevent
    creating an empty annotations section. Use $.Values.autoscaling.annotations |
    default dict | len gt 0 instead.

    charts/selenium-grid/templates/chrome-node-scaledjobs.yaml [9-14]

    -{{- if $.Values.autoscaling.annotations }}
    +{{- if and ($.Values.autoscaling.annotations) (gt (len $.Values.autoscaling.annotations) 0) }}
     annotations:
       {{- with $.Values.autoscaling.annotations }}
         {{- toYaml . | nindent 4 }}
       {{- end }}
     {{- end }}
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The suggestion improves robustness by preventing empty annotation sections when the annotations map exists but is empty. This is a valuable enhancement for Kubernetes manifest generation that would prevent potential issues and improve manifest cleanliness.

    8

    Copy link
    Member

    @VietND96 VietND96 left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM! Thank you @KyriosGN0

    @VietND96 VietND96 merged commit 6423b48 into SeleniumHQ:trunk Jan 13, 2025
    28 of 36 checks passed
    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.

    3 participants