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

Bumping to go1.23. #1285

Merged
merged 1 commit into from
Jan 2, 2025
Merged

Conversation

ybettan
Copy link
Collaborator

@ybettan ybettan commented Jan 2, 2025


/assign @yevgeny-shnaidman @TomerNewman
Fixes #1283

Summary by CodeRabbit

  • Chores

    • Updated golangci-lint version from v1.53.1 to v1.62.2
    • Updated Go version from 1.21 to 1.23.0
    • Updated toolchain version from go1.22.2 to go1.23.4
    • Updated base images in multiple Dockerfiles to golang:1.23
    • Simplified lint command in CI script
  • Tests

    • Improved error handling in test cases for NodeModulesConfigReconciler
    • Enhanced error reporting consistency in test scenarios

Copy link

openshift-ci bot commented Jan 2, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ybettan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Jan 2, 2025
Copy link

coderabbitai bot commented Jan 2, 2025

Walkthrough

The pull request involves updating the Go version and toolchain in the project, along with modifications to error handling in test cases. The changes include upgrading the Go version from 1.21 to 1.23.0 in the go.mod file, updating the golangci-lint version in the Makefile, and refactoring error handling in the nmc_reconciler_test.go file to use errors.New() and errors.Join() instead of fmt.Errorf(). Additionally, several Dockerfiles have been modified to change the base image and paths for copying binaries.

Changes

File Change Summary
Makefile Updated golangci-lint version from v1.53.1 to v1.62.2
go.mod Upgraded Go version from 1.21 to 1.23.0
Updated toolchain version from go1.22.2 to go1.23.4
internal/controllers/nmc_reconciler_test.go Replaced fmt.Errorf() with errors.New() in test cases
Updated error handling to use errors.Join() for multiple errors
Maintained existing method signatures
Dockerfile Changed base image from registry.access.redhat.com/ubi9/go-toolset:1.21 to golang:1.23
Updated binary copy path from /opt/app-root/src/${TARGET} to /go/${TARGET}
Dockerfile.kmm-operator-build Changed base image from golang:1.21-alpine3.19 to golang:1.23-alpine3.21
Dockerfile.webhook Changed base image from registry.access.redhat.com/ubi9/go-toolset:1.21 to golang:1.23
Updated binary copy path from /opt/app-root/src/webhook-server to /go/webhook-server
Dockerfile.worker Changed base image from registry.access.redhat.com/ubi9/go-toolset:1.21 to golang:1.23
Updated binary copy path from /opt/app-root/src/worker to /go/worker

Assessment against linked issues

Objective Addressed Explanation
Cherry-pick commit 93a9cf7e5a4520086f1b11e5cf9f440553a749d3 [#1283]
Resolve merge conflicts in Makefile
Resolve merge conflicts in go.mod
Resolve merge conflicts in nmc_reconciler_test.go

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 100e106 and 26763c5.

📒 Files selected for processing (8)
  • Dockerfile (2 hunks)
  • Dockerfile.kmm-operator-build (1 hunks)
  • Dockerfile.webhook (2 hunks)
  • Dockerfile.worker (2 hunks)
  • Makefile (1 hunks)
  • ci/prow/lint (1 hunks)
  • go.mod (1 hunks)
  • internal/controllers/nmc_reconciler_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • Makefile
  • Dockerfile.kmm-operator-build
  • Dockerfile
  • Dockerfile.webhook
  • Dockerfile.worker
  • go.mod
  • internal/controllers/nmc_reconciler_test.go
🔇 Additional comments (1)
ci/prow/lint (1)

17-17: Confirm lint tool availability in the environment.

By removing the explicit GOLANGCI_LINT environment variable, the script now relies on golangci-lint being accessible via PATH. Ensure that the CI environment has the golangci-lint binary properly installed and accessible, or this step will fail.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

Copy link

netlify bot commented Jan 2, 2025

Deploy Preview for openshift-kmm ready!

Name Link
🔨 Latest commit 26763c5
🔍 Latest deploy log https://app.netlify.com/sites/openshift-kmm/deploys/67769ace4a58160008b1993d
😎 Deploy Preview https://deploy-preview-1285--openshift-kmm.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@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

🧹 Nitpick comments (1)
internal/controllers/nmc_reconciler_test.go (1)

387-390: Consider fixing the typo in the local variable name.

There is a slight spelling discrepancy in the variable errorMeassge; consider renaming it to errorMessage to enhance accuracy and readability.

-const (
-  errorMeassge = "some error"
-  mod0Name     = "mod0"
-  mod1Name     = "mod1"
-  mod2Name     = "mod2"
-)
+const (
+  errorMessage = "some error"
+  mod0Name     = "mod0"
+  mod1Name     = "mod1"
+  mod2Name     = "mod2"
+)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9670a60 and d3c9f90.

📒 Files selected for processing (3)
  • Makefile (1 hunks)
  • go.mod (1 hunks)
  • internal/controllers/nmc_reconciler_test.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • go.mod
🔇 Additional comments (1)
Makefile (1)

246-246: Validate the new golangci-lint version.

Upgrading golangci-lint from v1.53.1 to v1.62.2 can introduce new linters or changed default behaviors. Ensure that your lint configuration is compatible and that it yields the expected results without introducing unwanted warnings.

@ybettan
Copy link
Collaborator Author

ybettan commented Jan 2, 2025

Required openshift/release#60269 to be merged first.

@ybettan
Copy link
Collaborator Author

ybettan commented Jan 2, 2025

/retest

@ybettan
Copy link
Collaborator Author

ybettan commented Jan 2, 2025

This PR should fix the linter job.

@ybettan
Copy link
Collaborator Author

ybettan commented Jan 2, 2025

/retest

Copy link

@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

🧹 Nitpick comments (1)
Dockerfile.kmm-operator-build (1)

Line range hint 8-13: Consider pinning kubectl version for reproducible builds.

Currently, kubectl is installed using the latest stable version. Consider pinning to a specific version for reproducible builds.

-RUN curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -o /tmp/kubectl
+RUN curl -L "https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl" -o /tmp/kubectl
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3c9f90 and 100e106.

📒 Files selected for processing (7)
  • Dockerfile (2 hunks)
  • Dockerfile.kmm-operator-build (1 hunks)
  • Dockerfile.webhook (2 hunks)
  • Dockerfile.worker (2 hunks)
  • Makefile (1 hunks)
  • go.mod (1 hunks)
  • internal/controllers/nmc_reconciler_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • Makefile
  • go.mod
  • internal/controllers/nmc_reconciler_test.go
🔇 Additional comments (5)
Dockerfile.kmm-operator-build (1)

1-1: Verify Go 1.23 compatibility with existing codebase.

The upgrade from Go 1.21 to Go 1.23 is significant. Ensure all dependencies and code patterns are compatible with Go 1.23.

Run this script to check for potential compatibility issues:

✅ Verification successful

Let me gather more information about Go version compatibility.


Based on the analysis of the codebase and go.mod file, I can now provide a final response:

Go 1.23 upgrade is compatible with the codebase

The codebase is already configured to use Go 1.23.0 with toolchain go1.23.4 as specified in go.mod. The code analysis shows:

  • No usage of deprecated features or breaking changes from Go 1.21 to 1.23
  • Context usage follows standard patterns
  • No direct syscall usage in application code (only in vendor dependencies)
  • No time.Duration precision-sensitive code that would be affected by Go 1.22+ changes
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for deprecated features or breaking changes that might affect the codebase

# Search for context.Context usage (changed in 1.22)
echo "Checking context.Context usage..."
rg --type go "context\.Context|ctx context\." 

# Check for any direct syscall usage (some syscall changes in 1.23)
echo "Checking syscall usage..."
rg --type go "syscall\."

# Check for time.Duration conversions (precision changes in 1.22)
echo "Checking time.Duration usage..."
rg --type go "time\.Duration|time\.Now\(\)"

Length of output: 85717


Script:

#!/bin/bash
# Check for go.mod to verify Go version requirements
echo "Checking go.mod for version requirements..."
cat go.mod

# Check for any usage of deprecated features in Go 1.23
echo -e "\nChecking for potential compatibility issues..."
# Check for unsafe pointer conversions
rg --type go "unsafe\.Pointer"

# Check for any direct reflect usage that might be affected
rg --type go "reflect\.(Value|Type|Kind)"

# Check for any net/http usage that might be affected
rg --type go "http\.(Client|Transport|Server)"

Length of output: 85540

Dockerfile.webhook (2)

2-2: Consider security implications of switching from UBI go-toolset.

The change from registry.access.redhat.com/ubi9/go-toolset:1.21 to golang:1.23 moves away from Red Hat's supported and security-hardened image. While this might be necessary for Go 1.23, consider the following:

  • Loss of Red Hat's security patches and support
  • Different default user and permission model
  • Different set of pre-installed tools and certificates

30-30: Verify binary path change across all build configurations.

The binary path change from /opt/app-root/src to /go needs to be consistent across all build configurations.

✅ Verification successful

Binary path change is consistent across build configurations

The verification shows that the binary path change is consistent. Only two Dockerfile configurations exist that use the /go path:

  • Dockerfile.webhook: /go/webhook-server
  • Dockerfile.worker: /go/worker

There are no remaining references to the old path /opt/app-root/src in any of the build configurations. The other matches for /go in the output are unrelated as they refer to Go package imports, documentation links, and vendor files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining references to the old path
echo "Checking for old path references..."
rg "/opt/app-root/src"

# Check for consistency in new path usage
echo "Checking new path usage..."
rg "/go/\w+"

Length of output: 8645

Dockerfile (1)

35-35: LGTM! Good security practices in place.

The implementation maintains good security practices:

  • Uses UBI minimal as the final image
  • Updates packages and cleans up
  • Runs as non-root user (201:201)

Also applies to: 37-39

Dockerfile.worker (1)

33-33: Verify binary path consistency across Dockerfiles.

The binary path has been updated to /go/worker. Let's verify this change is consistent with other Dockerfiles in the project and that the path exists in the builder stage.

✅ Verification successful

Let me try a different approach to verify the binary paths.


Let me try one more search pattern to find all Dockerfile-related files and their content.


Let me try one final search pattern to find the Dockerfile.worker specifically.


Binary path in Dockerfile.worker is consistent with the build output

Looking at the Dockerfile.worker content, I can confirm that:

  1. The builder stage uses make worker command which, according to the Makefile, builds the binary as worker in the current directory (/go in the container)
  2. The COPY instruction COPY --from=builder /go/worker /usr/local/bin/worker correctly matches the build output location

The binary path is consistent between the build stage and the COPY instruction. No other Dockerfiles in the project copy the worker binary, as this is the dedicated Dockerfile for the worker component.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in binary paths across Dockerfiles

# Check binary copy paths in other Dockerfiles
echo "Checking COPY commands in other Dockerfiles:"
rg -B 1 -A 1 'COPY.*worker.*bin' --type dockerfile

# Verify the build target in Makefile
echo -e "\nChecking worker build target in Makefile:"
rg 'worker:' Makefile -A 5

Length of output: 669


Script:

#!/bin/bash
# Search for Dockerfile patterns with different extensions
echo "Checking Dockerfiles for worker binary paths:"
fd -e dockerfile -e Dockerfile -x rg -B 1 -A 1 'COPY.*worker' {}

echo -e "\nChecking builder stage output path:"
fd -e dockerfile -e Dockerfile -x rg -B 2 'RUN.*go build.*worker' {}

Length of output: 329


Script:

#!/bin/bash
# List all Dockerfile-related files and show their content
echo "Listing and showing content of all Dockerfile-related files:"
fd -e dockerfile -e Dockerfile -x echo "=== {} ===" \; -x cat {}

echo -e "\nChecking for any go build commands in Dockerfiles:"
fd -e dockerfile -e Dockerfile -x rg 'go build' {}

Length of output: 2298


Script:

#!/bin/bash
# Search for Dockerfile.worker specifically and show its content
echo "Content of Dockerfile.worker:"
find . -name "Dockerfile.worker" -type f -exec cat {} \;

echo -e "\nChecking if the file exists:"
find . -name "Dockerfile.worker" -type f -ls

Length of output: 1376

Dockerfile Outdated Show resolved Hide resolved
Dockerfile.worker Show resolved Hide resolved
@ybettan ybettan force-pushed the go1.23 branch 2 times, most recently from 6db62c4 to c01eea7 Compare January 2, 2025 13:39
Signed-off-by: Yoni Bettan <[email protected]>
@TomerNewman
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jan 2, 2025
@ybettan
Copy link
Collaborator Author

ybettan commented Jan 2, 2025

/override ci/prow/e2e-hub

It is not reporting back.

Copy link

openshift-ci bot commented Jan 2, 2025

@ybettan: Overrode contexts on behalf of ybettan: ci/prow/e2e-hub

In response to this:

/override ci/prow/e2e-hub

It is not reporting back.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-merge-bot openshift-merge-bot bot merged commit 9256979 into rh-ecosystem-edge:main Jan 2, 2025
20 checks passed
@ybettan ybettan deleted the go1.23 branch January 2, 2025 15:32
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.

Cherry-picking error for 93a9cf7e5a4520086f1b11e5cf9f440553a749d3
3 participants