Skip to content
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

Feature add environment name to resources #38

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

AngeloB-AIS
Copy link
Contributor

ADDING ENVIRONMENT NAME TO RESOURCES

This PR adds the value of the appEnv to the names of the various k8s resources created by the helm chart. This change was implemented to make it clearer what environment a cluster admin was working against. Before, the names were identical in Staging and Production and unless an admin is proactively checking their kubectl context, they may accidentally apply changes to one environment that were intended for another.

@subintp
Copy link
Collaborator

subintp commented Sep 17, 2024

/review

@subintp
Copy link
Collaborator

subintp commented Sep 17, 2024

/improve

@subintp
Copy link
Collaborator

subintp commented Sep 17, 2024

/review

@subintp
Copy link
Collaborator

subintp commented Sep 17, 2024

/improve

Copy link

PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Key issues to review

Configuration Update
The dbHost and temporalHost values have been updated to include the community- prefix. Ensure this change is intentional and consistent with the new naming convention.

Resource Naming
The ConfigMap name and labels now include the appEnv value. Verify that this change is applied consistently across all resources and that it doesn't break any existing references.

Copy link

CI Failure Feedback 🧐

Action: deploy

Failed stage: Deploy chart to staging [❌]

Failure summary:

The action failed due to an error during the upgrade process:

  • The admission webhook "validate.nginx.ingress.kubernetes.io" denied the request.
  • The error was caused because the host "staging.squared.ai" and path "/.well-known/acme-challenge/"
    is already defined in the ingress "multiwoven/multiwoven-ingress".
  • This indicates a conflict in the ingress configuration, preventing the upgrade from proceeding.

  • Relevant error logs:
    1:  Runner name: 'gha-job-helm-charts-ml4j4-zqlsz'
    2:  Runner group name: 'Default'
    ...
    
    104:  AZURE_HTTP_USER_AGENT: 
    105:  AZUREPS_HOST_ENVIRONMENT: 
    106:  KUBECONFIG: /home/runner/_work/_temp/kubeconfig_1726573333252
    107:  KUBE_CONFIG_PATH: /home/runner/_work/_temp/kubeconfig_1726573333252
    108:  ##[endgroup]
    109:  W0917 11:42:18.044950     344 warnings.go:70] unknown field "spec.template.spec.containers[0].limits"
    110:  W0917 11:42:18.044979     344 warnings.go:70] unknown field "spec.template.spec.containers[0].requests"
    111:  W0917 11:42:18.313878     344 warnings.go:70] path /(.*) cannot be used with pathType Prefix
    112:  Error: UPGRADE FAILED: failed to create resource: admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: host "staging.squared.ai" and path "/.well-known/acme-challenge/" is already defined in ingress multiwoven/multiwoven-ingress
    113:  ##[error]Process completed with exit code 1.
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    @AngeloB-AIS
    Copy link
    Contributor Author

    /review

    @AngeloB-AIS
    Copy link
    Contributor Author

    /improve

    Copy link

    qodo-merge-pro bot commented Sep 28, 2024

    PR Code Suggestions ✨

    Latest suggestions up to c31a8f2

    CategorySuggestion                                                                                                                                    Score
    Security
    Use Kubernetes secrets instead of ConfigMaps for sensitive information

    Consider using Kubernetes secrets instead of ConfigMaps for storing sensitive
    information like database passwords. This improves the security of your deployment
    by keeping sensitive data encrypted.

    charts/multiwoven/templates/multiwoven-postgresql-deployment.yaml [25-29]

     valueFrom:
    -  configMapKeyRef:
    +  secretKeyRef:
         key: DB_PASSWORD
    -    name: {{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-config
    +    name: {{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-secrets
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: This suggestion significantly improves security by recommending the use of Kubernetes secrets for sensitive data, ensuring it is encrypted and better protected.

    9
    Enhancement
    Refactor repeated kubectl commands into a loop for better maintainability

    Consider using a loop or a reusable workflow step to reduce code duplication for the
    kubectl rollout restart commands. This will make the workflow more maintainable and
    easier to update in the future.

    .github/workflows/deploy-staging.yml [47-49]

    -kubectl rollout restart deployment ${{ vars.APP_ENV }}-multiwoven-worker -n multiwoven
    -kubectl rollout restart deployment ${{ vars.APP_ENV }}-multiwoven-server -n multiwoven
    -kubectl rollout restart deployment ${{ vars.APP_ENV }}-multiwoven-ui -n multiwoven
    +for component in worker server ui; do
    +  kubectl rollout restart deployment ${{ vars.APP_ENV }}-multiwoven-${component} -n multiwoven
    +done
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: This suggestion reduces code duplication and enhances maintainability by using a loop for similar commands. It simplifies future updates and reduces the risk of errors.

    8
    Best practice
    Create a helper template for generating consistent service names in the ingress configuration

    Consider using a template or a helper function to generate the service names
    consistently. This will reduce the risk of errors and make it easier to maintain the
    ingress configuration.

    charts/multiwoven/templates/multiwoven-ingress.yaml [35-54]

    -name: '{{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-ui'
    +{{- define "service.name" -}}
    +{{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-{{ . }}
    +{{- end -}}
     ...
    -name: '{{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-server'
    +name: '{{ include "service.name" "ui" }}'
     ...
    -name: '{{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-temporal-ui'
    +name: '{{ include "service.name" "server" }}'
    +...
    +name: '{{ include "service.name" "temporal-ui" }}'
    Suggestion importance[1-10]: 7

    Why: Using a helper template for service names improves consistency and reduces the risk of errors. It enhances maintainability by centralizing the naming logic.

    7
    ✅ Use a more descriptive placeholder for the Appsignal Push API key
    Suggestion Impact:The placeholder for the Appsignal Push API key was changed to a more descriptive one, as suggested.

    code diff:

    -  appsignalPushApiKey: yourkey
    +  appsignalPushApiKey: "" # Replace with your actual Appsignal Push API key

    Consider using a more specific default value for appsignalPushApiKey instead of
    "yourkey". This can help prevent accidental deployments with an invalid key and make
    it clearer that this value needs to be replaced.

    charts/multiwoven/values.yaml [9]

    -appsignalPushApiKey: yourkey
    +appsignalPushApiKey: "" # Replace with your actual Appsignal Push API key
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: Changing the placeholder to a more descriptive one helps prevent accidental deployments with an invalid key and clarifies that the value needs to be replaced, improving usability.

    6

    Previous suggestions

    Suggestions up to commit 17f661a
    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Use template variables for environment-specific hostnames to improve flexibility and consistency

    Consider using a template variable for the environment name instead of hardcoding
    'community' in the dbHost and temporalHost values. This would make the configuration
    more flexible and consistent with the use of {{ .Values.multiwovenConfig.appEnv }}
    in other files.

    charts/multiwoven/values.yaml [13-40]

    -dbHost: community-multiwoven-postgresql
    +dbHost: "{{ .Values.multiwovenConfig.appEnv }}-{{ include \"chart.fullname\" . }}-postgresql"
     ...
    -temporalHost: community-multiwoven-temporal
    +temporalHost: "{{ .Values.multiwovenConfig.appEnv }}-{{ include \"chart.fullname\" . }}-temporal"
     
    Suggestion importance[1-10]: 9

    Why: The suggestion correctly identifies an opportunity to enhance flexibility and consistency by using template variables for environment-specific hostnames, aligning with the existing pattern used in other parts of the code.

    9
    Best practice
    Standardize the use of quotes in service name definitions for consistency

    Consider using a consistent naming convention for the service names in the ingress
    configuration. Currently, some services use quotes while others don't. Standardizing
    this would improve readability and maintainability.

    charts/multiwoven/templates/multiwoven-ingress.yaml [42-68]

    -name: '{{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-ui'
    +name: {{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-ui
     ...
    -name: '{{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-server'
    +name: {{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-server
     ...
    -name: '{{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-temporal-ui'
    +name: {{ .Values.multiwovenConfig.appEnv }}-{{ include "chart.fullname" . }}-temporal-ui
     
    Suggestion importance[1-10]: 7

    Why: The suggestion addresses a minor inconsistency in the code style, which can improve readability and maintainability, but it does not affect functionality.

    7

    Copy link

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Configuration Change
    The ingress configuration has been updated to include the environment name in the service names. This change needs to be carefully reviewed to ensure it doesn't break existing routing rules.

    Configuration Update
    The database host and Temporal host configurations have been updated to include the environment name. This change should be reviewed to ensure it's consistent across all environments and doesn't break existing connections.

    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