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

feat(firehose-ethereum): rework JWT without lookup #361

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

cjorge-graphops
Copy link
Contributor

@cjorge-graphops cjorge-graphops commented Sep 19, 2024

Summary by CodeRabbit

  • New Features

    • Updated versioning for Firehose Ethereum and Graph Toolbox projects.
    • Added configuration options for genesis file in Firehose Ethereum.
    • Introduced a Kubernetes Job resource for automated JWT secret management.
    • Enhanced secret management logic for JWT configurations.
  • Bug Fixes

    • Streamlined JWT secret generation process by removing unnecessary checks.
  • Documentation

    • Improved clarity in README files for Firehose Ethereum and Graph Toolbox, including updated version badges and descriptions.

Copy link

coderabbitai bot commented Sep 19, 2024

Walkthrough

The pull request includes updates to the Firehose Ethereum Helm chart, reflected in version increments across multiple files. The Chart.yaml file's version is updated from 0.1.0-canary.1 to 0.1.0-canary.2. The README.md file has been revised to clarify configuration settings, particularly for the firehoseServiceDefaults. A new Kubernetes Job resource is introduced to manage JWT secrets, and modifications to the rendering logic for secrets have been made. Additionally, permissions for managing Kubernetes secrets have been added in the values.yaml file.

Changes

Files Change Summary
charts/firehose-ethereum/Chart.yaml Version updated from 0.1.0-canary.1 to 0.1.0-canary.2.
charts/firehose-ethereum/README.md Version badge updated to 0.1.0-canary.2; clarified defaults for firehoseServiceDefaults, including new options for genesis file configuration.
charts/firehose-ethereum/templates/resources/job.yaml Added a Kubernetes Job resource for generating a JWT secret post-installation and post-upgrade, with a TTL of 100 seconds and logic for secret creation.
charts/firehose-ethereum/templates/resources/render.yaml Enhanced rendering logic for JWT configuration, allowing for more flexible secret generation based on user-defined literals.
charts/firehose-ethereum/templates/resources/secret.yaml Simplified logic for generating JWT secret by directly encoding the JWT from a literal value, removing unnecessary checks for existing secrets.
charts/firehose-ethereum/values.yaml Added permissions for managing Kubernetes secrets, allowing the service to get and create secrets.
charts/graph-toolbox/README.md Version updated from 0.1.0 to 0.1.1 and clarified the toolbox's intended use alongside the Graph Network Indexer stack.

Possibly related PRs


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 62d1aaf and e0fe865.

Files selected for processing (7)
  • charts/firehose-ethereum/Chart.yaml (1 hunks)
  • charts/firehose-ethereum/README.md (2 hunks)
  • charts/firehose-ethereum/templates/resources/job.yaml (1 hunks)
  • charts/firehose-ethereum/templates/resources/render.yaml (1 hunks)
  • charts/firehose-ethereum/templates/resources/secret.yaml (0 hunks)
  • charts/firehose-ethereum/values.yaml (1 hunks)
  • charts/graph-toolbox/README.md (1 hunks)
Files not reviewed due to no reviewable changes (1)
  • charts/firehose-ethereum/templates/resources/secret.yaml
Files skipped from review due to trivial changes (2)
  • charts/firehose-ethereum/Chart.yaml
  • charts/graph-toolbox/README.md
Additional context used
LanguageTool
charts/firehose-ethereum/README.md

[style] ~280-~280: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rehoseDefaults> is available | object | `{"firehose":{"fireeth":{"config":{"firehose-grpc-listen-addr":"0.0.0.0:10015"}},"ports":{"fh-grpc":{"containerPort":"{{ with .Pod.fireeth.config }}{{ if (index . "firehose-grpc-listen-addr") }}{{ splitList ":" (index . "firehose-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}},"service":{"enabled":true,"spec":{"ports":{"fh-grpc":{"port":"{{ with .Pod.fireeth.config }}{{ if (index . "firehose-grpc-listen-addr") }}{{ splitList ":" (index . "firehose-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}}}}},"index-builder":{"fireeth":{"config":{"index-builder-grpc-listen-addr":"0.0.0.0:10009","index-builder-index-size":"1000"}},"ports":{"index-grpc":{"containerPort":"{{ with .Pod.fireeth.config }}{{ if (index . "index-builder-grpc-listen-addr") }}{{ splitList ":" (index . "index-builder-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}},"service":{"enabled":true,"spec":{"ports":{"index-grpc":{"port":"{{ with .Pod.fireeth.config }}{{ if (index . "index-builder-grpc-listen-addr") }}{{ splitList ":" (index . "index-builder-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}}}}},"merger":{"fireeth":{"config":{"merger-grpc-listen-addr":":10012"}},"ports":{"merger-grpc":{"containerPort":"{{ with .Pod.fireeth.config }}{{ if (index . "merger-grpc-listen-addr") }}{{ splitList ":" (index . "merger-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}},"service":{"enabled":true,"spec":{"ports":{"merger-grpc":{"port":"{{ with .Pod.fireeth.config }}{{ if (index . "merger-grpc-listen-addr") }}{{ splitList ":" (index . "merger-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}}}}},"reader-node":{"clusterRbac":{"enabled":"{{ .Pod.fireeth.p2p.enabled }}","roleSpec":{"rules":[{"apiGroups":[""],"resources":["nodes"],"verbs":["get","list","watch"]}]}},"configMap":{"data":"{{ with .Pod.fireeth.genesisJson }}{{ .enabled | ternary ( .data | toYaml | nindent 8 ) nil }}{{ end }}","options":{"useEnvSubst":true}},"env":{"MANAGER_API_PORT":"{{ with .Pod.fireeth.config }}{{ hasKey . "reader-n...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~284-~284: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... for the reader-node service | object | `{"clusterRbac":{"enabled":"{{ .Pod.fireeth.p2p.enabled }}","roleSpec":{"rules":[{"apiGroups":[""],"resources":["nodes"],"verbs":["get","list","watch"]}]}},"configMap":{"data":"{{ with .Pod.fireeth.genesisJson }}{{ .enabled | ternary ( .data | toYaml | nindent 8 ) nil }}{{ end }}","options":{"useEnvSubst":true}},"env":{"MANAGER_API_PORT":"{{ with .Pod.fireeth.config }}{{ hasKey . "reader-n...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

yamllint
charts/firehose-ethereum/templates/resources/job.yaml

[error] 2-2: syntax error: expected '', but found ''

(syntax)

Additional comments not posted (7)
charts/firehose-ethereum/templates/resources/job.yaml (1)

1-59: LGTM!

The Kubernetes Job resource definition is well-structured and follows best practices:

  • The Job is designed to generate a JWT secret only if it doesn't exist, which is a good practice to avoid redundancy and potential conflicts.
  • The Job uses a Bitnami kubectl image to execute commands, which is a standard practice.
  • The Job sets up environment variables to capture the namespace and the secret name dynamically, which is a good practice to make the Job reusable across different namespaces and secret names.
  • The Job generates a new secret using a randomly generated hexadecimal string, which is created using OpenSSL, which is a secure way to generate secrets.
  • The Job has a TTL of 100 seconds after completion for automatic cleanup, which is a good practice to avoid leaving completed Jobs around.
  • The Job uses labels and annotations to facilitate its management within the Kubernetes ecosystem, which is a good practice to make the Job easily discoverable and manageable.
  • The Job uses a service account specified by metadata.serviceAccountName, which is a good practice to give the Job the necessary permissions to execute commands.
  • The Job has a restart policy of OnFailure, which is a good practice to ensure that the Job is retried if it fails.
  • The Job uses a define template named templates.jwtJob, which is a good practice to make the Job reusable across different Helm charts.
Tools
yamllint

[error] 2-2: syntax error: expected '', but found ''

(syntax)

charts/firehose-ethereum/templates/resources/render.yaml (2)

86-89: LGTM!

The conditional rendering logic for the secret is well-implemented. It ensures that a secret is only created when necessary and allows for user-defined secret values through the fromLiteral field.


92-96: Verify the job template and approve the changes.

The conditional rendering logic for the job is well-implemented. It ensures that a job is only created when necessary and allows for automatic secret generation when no user-defined secret is available.

Please ensure that the templates.jwtJob template is correctly defined and includes the necessary logic for generating the JWT secret. You can use the following command to verify the template:

Verification successful

Template verified: templates.jwtJob is correctly defined and used.

The templates.jwtJob template is properly defined in charts/firehose-ethereum/templates/resources/job.yaml and correctly used in charts/firehose-ethereum/templates/resources/render.yaml. The template creates a Kubernetes Job resource with appropriate metadata for JWT generation.

The conditional rendering logic in the review comment ensures that the job is only created when necessary (JWT enabled, no existing secret, and no literal value provided). This implementation allows for automatic secret generation when needed while preventing unnecessary job creation.

No issues were found with the template definition or its usage. The changes can be approved as they are consistent with best practices for Helm chart development and secret management.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `templates.jwtJob` template is correctly defined.

# Test: Search for the template definition. Expect: The template to be defined with the correct logic.
rg --type yaml -A 10 $'{{- define "templates.jwtJob" -}}'

Length of output: 167


Script:

#!/bin/bash
# Description: Verify the `templates.jwtJob` template definition and usage

# Search for the template definition
echo "Searching for template definition:"
rg -A 10 'define "templates.jwtJob"' --type yaml

# Search for usage of the template
echo "Searching for template usage:"
rg 'include "templates.jwtJob"' --type yaml

Length of output: 1457

charts/firehose-ethereum/values.yaml (1)

635-640: LGTM!

The added RBAC permissions for the reader-node service to manage secrets directly aligns well with the PR objective to rework JWT without lookup. The permissions are scoped appropriately to the "secrets" resource with "get" and "create" verbs, following the principle of least privilege.

charts/firehose-ethereum/README.md (3)

5-5: LGTM!

The version badge has been correctly updated to 0.1.0-canary.2.


280-280: LGTM!

The firehoseServiceDefaults section has been appropriately updated with configuration for the firehose, index-builder, merger, and relayer services.

Tools
LanguageTool

[style] ~280-~280: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rehoseDefaults> is available | object | `{"firehose":{"fireeth":{"config":{"firehose-grpc-listen-addr":"0.0.0.0:10015"}},"ports":{"fh-grpc":{"containerPort":"{{ with .Pod.fireeth.config }}{{ if (index . "firehose-grpc-listen-addr") }}{{ splitList ":" (index . "firehose-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}},"service":{"enabled":true,"spec":{"ports":{"fh-grpc":{"port":"{{ with .Pod.fireeth.config }}{{ if (index . "firehose-grpc-listen-addr") }}{{ splitList ":" (index . "firehose-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}}}}},"index-builder":{"fireeth":{"config":{"index-builder-grpc-listen-addr":"0.0.0.0:10009","index-builder-index-size":"1000"}},"ports":{"index-grpc":{"containerPort":"{{ with .Pod.fireeth.config }}{{ if (index . "index-builder-grpc-listen-addr") }}{{ splitList ":" (index . "index-builder-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}},"service":{"enabled":true,"spec":{"ports":{"index-grpc":{"port":"{{ with .Pod.fireeth.config }}{{ if (index . "index-builder-grpc-listen-addr") }}{{ splitList ":" (index . "index-builder-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}}}}},"merger":{"fireeth":{"config":{"merger-grpc-listen-addr":":10012"}},"ports":{"merger-grpc":{"containerPort":"{{ with .Pod.fireeth.config }}{{ if (index . "merger-grpc-listen-addr") }}{{ splitList ":" (index . "merger-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}},"service":{"enabled":true,"spec":{"ports":{"merger-grpc":{"port":"{{ with .Pod.fireeth.config }}{{ if (index . "merger-grpc-listen-addr") }}{{ splitList ":" (index . "merger-grpc-listen-addr") | last | int }}{{ else }}{{ nil }}{{ end }}{{ end }}","protocol":"TCP"}}}}},"reader-node":{"clusterRbac":{"enabled":"{{ .Pod.fireeth.p2p.enabled }}","roleSpec":{"rules":[{"apiGroups":[""],"resources":["nodes"],"verbs":["get","list","watch"]}]}},"configMap":{"data":"{{ with .Pod.fireeth.genesisJson }}{{ .enabled | ternary ( .data | toYaml | nindent 8 ) nil }}{{ end }}","options":{"useEnvSubst":true}},"env":{"MANAGER_API_PORT":"{{ with .Pod.fireeth.config }}{{ hasKey . "reader-n...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


284-284: LGTM!

The firehoseServiceDefaults.reader-node section has been appropriately updated with extensive configuration for the reader-node service, including options for specifying the genesis JSON data.

Tools
LanguageTool

[style] ~284-~284: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... for the reader-node service | object | `{"clusterRbac":{"enabled":"{{ .Pod.fireeth.p2p.enabled }}","roleSpec":{"rules":[{"apiGroups":[""],"resources":["nodes"],"verbs":["get","list","watch"]}]}},"configMap":{"data":"{{ with .Pod.fireeth.genesisJson }}{{ .enabled | ternary ( .data | toYaml | nindent 8 ) nil }}{{ end }}","options":{"useEnvSubst":true}},"env":{"MANAGER_API_PORT":"{{ with .Pod.fireeth.config }}{{ hasKey . "reader-n...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cjorge-graphops cjorge-graphops merged commit c474375 into main Sep 20, 2024
1 check passed
@cjorge-graphops cjorge-graphops deleted the carlos/rework-jwt-without-lookup branch September 20, 2024 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants