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

chore: upgrade to go1.22.4 and rudder-go-kit #4758

Merged
merged 6 commits into from
Jun 5, 2024
Merged

Conversation

lvrach
Copy link
Member

@lvrach lvrach commented Jun 5, 2024

Description

Linear Ticket

resolves PIPE-1166

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected spelling errors in method calls related to statistics tracking to ensure accurate metric names and values.
  • Chores

    • Updated Go version from 1.22.3 to 1.22.4 in Dockerfile for improved compatibility.
    • Introduced a script to check the Go version in a Docker environment as part of the formatting process.
  • Refactor

    • Renamed guageStat to gaugeStat in multiple files to correct a typo and ensure consistency.

Copy link
Contributor

coderabbitai bot commented Jun 5, 2024

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

Commits

Files that changed from the base of the PR and between 456a535 and a86e7bb.

Files selected for processing (1)
  • gateway/gateway_test.go (4 hunks)
 _______________________________________________________________________________________________
< bm = Δc/Δt: Bug momentum equals change in code over change in time. Can't argue with physics. >
 -----------------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

Walkthrough

The updates include a minor version bump for Go in the Dockerfile, enhancements to the Makefile for formatting, and new functionality in a script for Docker Go version checking. Additionally, there are corrections and improvements in the warehouse/router package, focusing on metrics handling and method accuracy.

Changes

File Path Change Summary
Dockerfile Updated Go version from 1.22.3 to 1.22.4.
Makefile Added ./build/docker-go-version.sh to the fmt target for enhanced formatting.
build/docker-go-version.sh Introduced a script to update the GO_VERSION argument in a Dockerfile based on the installed Go version.
warehouse/router/state_export_data.go Fixed typos in method calls, updated metrics names and values, and added a new tag for sourceCategory.
warehouse/router/upload.go Updated NewUploadJob method to include additional parameters for gaugeStat with sourceCategory tag.
warehouse/router/upload_stats.go Corrected the guageStat method name to gaugeStat.

Poem

In the Dockerfile, a version we tweak,
Go's update is the change we seek.
Metrics corrected, stats now precise,
With every gauge, our data's concise.
A script to check, a tag to add,
For a warehouse that's never bad.
🐇✨ Code refined, our joy's not sad!


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@lvrach lvrach changed the title chore: upgrade go and rudder-go-kit chore: upgrade to go1.22.4 and rudder-go-kit Jun 5, 2024
@lvrach lvrach marked this pull request as ready for review June 5, 2024 07:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (4)
Dockerfile (4)

Line range hint 14-14: Pin package versions in apk add to ensure reproducible builds.

- RUN apk add --update make tzdata ca-certificates
+ RUN apk add --update make=4.3-r0 tzdata=2021a-r0 ca-certificates=20191127-r0

Line range hint 14-14: Use --no-cache with apk add to avoid the need for --update and to prevent caching.

- RUN apk add --update make tzdata ca-certificates
+ RUN apk add --no-cache make tzdata ca-certificates

Line range hint 30-30: Consolidate consecutive RUN instructions to reduce layers and optimize the Docker image size.

- RUN go build -o devtool ./cmd/devtool/
- RUN go build -o rudder-cli ./cmd/rudder-cli/
+ RUN go build -o devtool ./cmd/devtool/ && \
+     go build -o rudder-cli ./cmd/rudder-cli/

Line range hint 34-34: Pin versions in apk add and set WORKDIR before COPY to ensure reproducibility and correct file paths.

+ WORKDIR /rudder-server
- RUN apk --no-cache upgrade && \
-     apk --no-cache add tzdata ca-certificates postgresql-client curl bash
+ RUN apk --no-cache upgrade && \
+     apk --no-cache add tzdata=2021a-r0 ca-certificates=20191127-r0 postgresql-client=13.3-r0 curl=7.76.1-r0 bash=5.1.4-r0
- COPY --from=builder rudder-server/rudder-server .
- COPY --from=builder rudder-server/build/wait-for-go/wait-for-go .
- COPY --from=builder rudder-server/build/regulation-worker .
- COPY --from=builder rudder-server/devtool .
- COPY --from=builder rudder-server/rudder-cli /usr/bin/rudder-cli
+ COPY --from=builder /rudder-server/rudder-server .
+ COPY --from=builder /rudder-server/build/wait-for-go/wait-for-go .
+ COPY --from=builder /rudder-server/build/regulation-worker .
+ COPY --from=builder /rudder-server/devtool .
+ COPY --from=builder /rudder-server/rudder-cli /usr/bin/rudder-cli

Also applies to: 37-40

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4568777 and d49d045.

Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum
Files selected for processing (1)
  • Dockerfile (1 hunks)
Additional context used
Hadolint
Dockerfile

[warning] 14-14: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version> (DL3018)


[info] 14-14: Use the --no-cache switch to avoid the need to use --update and remove /var/cache/apk/* when done installing packages (DL3019)


[warning] 25-25: This expansion will not see the mentioned assignment. (SC2098)


[info] 30-30: Multiple consecutive RUN instructions. Consider consolidation. (DL3059)


[warning] 34-34: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version> (DL3018)


[warning] 37-37: COPY to a relative destination without WORKDIR set. (DL3045)


[warning] 38-38: COPY to a relative destination without WORKDIR set. (DL3045)


[warning] 39-39: COPY to a relative destination without WORKDIR set. (DL3045)


[warning] 40-40: COPY to a relative destination without WORKDIR set. (DL3045)

Additional comments not posted (2)
Dockerfile (2)

3-3: Update to Go version 1.22.4 aligns with the PR objectives to address vulnerabilities and maintain compatibility.


Line range hint 25-25: Ensure that the BUILD_DATE variable is correctly expanded in the RUN command.

Verification successful

The BUILD_DATE variable is correctly expanded in the RUN command within the Dockerfile.

  • Dockerfile:RUN BUILD_DATE=$(date "+%F,%T") \
  • Dockerfile: LDFLAGS="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT_HASH} -X main.buildDate=$BUILD_DATE -X main.builtBy=${REVISION} -X main.enterpriseToken=${ENTERPRISE_TOKEN} " \
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that BUILD_DATE is correctly expanded in the Dockerfile.

# Test: Search for the BUILD_DATE usage. Expect: Correct expansion.
rg --type dockerfile $'BUILD_DATE'

Length of output: 68



Script:

#!/bin/bash
# Description: Verify that BUILD_DATE is correctly expanded in the Dockerfile.

# Test: Search for the BUILD_DATE usage in Dockerfiles. Expect: Correct expansion.
rg 'BUILD_DATE' --glob '*Dockerfile*'

Length of output: 275

Copy link
Contributor

@mihir20 mihir20 left a comment

Choose a reason for hiding this comment

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

We should update suppression-backup-service/Dockerfile as well

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d49d045 and b1a3179.

Files selected for processing (3)
  • Dockerfile (1 hunks)
  • Makefile (1 hunks)
  • build/docker-go-version.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • build/docker-go-version.sh
Files skipped from review as they are similar to previous changes (1)
  • Dockerfile
Additional comments not posted (1)
Makefile (1)

110-110: Ensure the new script build/docker-go-version.sh functions as expected.

#!/bin/bash
# Description: Verify the functionality of the script `build/docker-go-version.sh`.

# Test: Execute the script and check for correct Go version output.
./build/docker-go-version.sh

@lvrach lvrach force-pushed the chore.go-kit-upgrade branch 2 times, most recently from 54ae53c to 53837eb Compare June 5, 2024 09:16
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (4)
Dockerfile (4)

Line range hint 16-16: Pin package versions to ensure reproducible builds.

- RUN apk add --update make tzdata ca-certificates
+ RUN apk add --no-cache make=4.3-r0 tzdata=2021a-r0 ca-certificates=20191127-r4

This change pins the versions of the packages to ensure that the build is reproducible and consistent across environments. It also uses --no-cache to avoid the need to use --update and to remove /var/cache/apk/* when done installing packages.


Line range hint 27-27: Correct the environment variable expansion in the RUN command.

- RUN BUILD_DATE=$(date "+%F,%T") \
+ RUN export BUILD_DATE=$(date "+%F,%T") \

This change ensures that the BUILD_DATE variable is correctly exported and available in the subsequent commands in the same RUN instruction.


Line range hint 32-32: Consolidate consecutive RUN instructions to reduce layers.

- RUN go build -o devtool ./cmd/devtool/
- RUN go build -o rudder-cli ./cmd/rudder-cli/
+ RUN go build -o devtool ./cmd/devtool/ && \
+     go build -o rudder-cli ./cmd/rudder-cli/

This change consolidates the RUN instructions into a single layer, reducing the total number of layers in the image, which can improve the build time and the size of the final image.


Line range hint 39-42: Set a WORKDIR before copying files to ensure the destination is clear.

+ WORKDIR /rudder-server
  COPY --from=builder rudder-server/rudder-server .
  COPY --from=builder rudder-server/build/wait-for-go/wait-for-go .
  COPY --from=builder rudder-server/build/regulation-worker .
  COPY --from=builder rudder-server/devtool .
  COPY --from=builder rudder-server/rudder-cli /usr/bin/rudder-cli

Adding a WORKDIR directive ensures that all COPY commands are relative to a known directory, improving the clarity and maintainability of the Dockerfile.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b1a3179 and 53837eb.

Files selected for processing (4)
  • Dockerfile (1 hunks)
  • Makefile (1 hunks)
  • build/docker-go-version.sh (1 hunks)
  • suppression-backup-service/Dockerfile (1 hunks)
Files skipped from review due to trivial changes (1)
  • suppression-backup-service/Dockerfile
Files skipped from review as they are similar to previous changes (1)
  • Makefile
Additional context used
Shellcheck
build/docker-go-version.sh

[style] 11-11: Use $(...) notation instead of legacy backticks .... (SC2006)


[info] 11-11: read without -r will mangle backslashes. (SC2162)


[info] 11-11: Double quote to prevent globbing and word splitting. (SC2086)


[info] 17-17: Double quote to prevent globbing and word splitting. (SC2086)


[info] 17-17: Double quote to prevent globbing and word splitting. (SC2086)

Hadolint
Dockerfile

[warning] 16-16: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version> (DL3018)


[info] 16-16: Use the --no-cache switch to avoid the need to use --update and remove /var/cache/apk/* when done installing packages (DL3019)


[warning] 27-27: This expansion will not see the mentioned assignment. (SC2098)


[info] 32-32: Multiple consecutive RUN instructions. Consider consolidation. (DL3059)


[warning] 36-36: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version> (DL3018)


[warning] 39-39: COPY to a relative destination without WORKDIR set. (DL3045)


[warning] 40-40: COPY to a relative destination without WORKDIR set. (DL3045)


[warning] 41-41: COPY to a relative destination without WORKDIR set. (DL3045)


[warning] 42-42: COPY to a relative destination without WORKDIR set. (DL3045)

build/docker-go-version.sh Show resolved Hide resolved

for DOCKERFILE_PATH in "$@"
do
sed -i $BAK_SUFFIX "s/ARG GO_VERSION=[0-9].*/ARG GO_VERSION=$v/" $DOCKERFILE_PATH && rm $DOCKERFILE_PATH$BAK_SUFFIX
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure variables are properly quoted to prevent word splitting and globbing.

- sed -i $BAK_SUFFIX "s/ARG GO_VERSION=[0-9].*/ARG GO_VERSION=$v/" $DOCKERFILE_PATH && rm $DOCKERFILE_PATH$BAK_SUFFIX
+ sed -i "$BAK_SUFFIX" "s/ARG GO_VERSION=[0-9].*/ARG GO_VERSION=$v/" "$DOCKERFILE_PATH" && rm "$DOCKERFILE_PATH$BAK_SUFFIX"

This change wraps the variables in double quotes to ensure that filenames with spaces or special characters are handled correctly.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
sed -i $BAK_SUFFIX "s/ARG GO_VERSION=[0-9].*/ARG GO_VERSION=$v/" $DOCKERFILE_PATH && rm $DOCKERFILE_PATH$BAK_SUFFIX
sed -i "$BAK_SUFFIX" "s/ARG GO_VERSION=[0-9].*/ARG GO_VERSION=$v/" "$DOCKERFILE_PATH" && rm "$DOCKERFILE_PATH$BAK_SUFFIX"
Tools
Shellcheck

[info] 17-17: Double quote to prevent globbing and word splitting. (SC2086)


[info] 17-17: Double quote to prevent globbing and word splitting. (SC2086)

@lvrach lvrach force-pushed the chore.go-kit-upgrade branch 2 times, most recently from 872d710 to 12ac3a1 Compare June 5, 2024 09:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 53837eb and 3329b70.

Files selected for processing (1)
  • build/docker-go-version.sh (1 hunks)
Files not reviewed due to errors (1)
  • build/docker-go-version.sh (no review received)
Additional context used
Shellcheck
build/docker-go-version.sh

[style] 11-11: Use $(...) notation instead of legacy backticks .... (SC2006)


[info] 11-11: read without -r will mangle backslashes. (SC2162)


[info] 11-11: Double quote to prevent globbing and word splitting. (SC2086)

@lvrach lvrach requested a review from achettyiitr June 5, 2024 10:59
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3329b70 and 456a535.

Files selected for processing (3)
  • warehouse/router/state_export_data.go (2 hunks)
  • warehouse/router/upload.go (1 hunks)
  • warehouse/router/upload_stats.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • warehouse/router/state_export_data.go
  • warehouse/router/upload_stats.go
Additional comments not posted (1)
warehouse/router/upload.go (1)

215-218: The addition of the sourceCategory tag in the gaugeStat method enhances tracking capabilities. Ensure that this new tag is properly integrated and utilized in relevant parts of the system.

Verification successful

The sourceCategory tag is consistently used across various parts of the system, including test files, state export data, integrations, and reporting. This indicates that the integration of the new tag is thorough and well-implemented.

  • warehouse/router/upload_test.go
  • warehouse/router/state_export_data.go
  • warehouse/integrations/snowflake/snowflake.go
  • warehouse/integrations/deltalake/deltalake.go
  • utils/types/reporting_types.go
  • router/worker.go
  • router/batchrouter/handle_observability.go
  • router/types/types.go
  • processor/processor.go
  • processor/transformer/transformer.go
  • integration_test/warehouse/integration_test.go
  • enterprise/reporting/event_stats_test.go
  • enterprise/reporting/event_stats.go
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of the `sourceCategory` tag across the system.

# Test: Search for the usage of `sourceCategory` tag. Expect: Consistent usage across relevant parts.
rg --type go $'sourceCategory'

Length of output: 3810

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.68%. Comparing base (1857735) to head (a86e7bb).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4758      +/-   ##
==========================================
+ Coverage   74.60%   74.68%   +0.08%     
==========================================
  Files         414      414              
  Lines       48595    48597       +2     
==========================================
+ Hits        36254    36297      +43     
+ Misses       9961     9937      -24     
+ Partials     2380     2363      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lvrach lvrach merged commit e7d0dec into master Jun 5, 2024
54 checks passed
@lvrach lvrach deleted the chore.go-kit-upgrade branch June 5, 2024 12:50
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.

None yet

5 participants