Skip to content

Commit

Permalink
Bump to go1.22 (#1185)
Browse files Browse the repository at this point in the history
* Bump the minimum version of go to 1.22.0

* Bump assets to use use/require go1.22

* Update README with new Go version
  • Loading branch information
ctlong authored Aug 1, 2024
1 parent c21d940 commit 043a63f
Show file tree
Hide file tree
Showing 24 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ in such a way as to impact other tests.

## Test Setup
### Prerequisites for running CATS
- Install golang >= `1.21`. Set up your golang development environment, per
- Install golang >= `1.22`. Set up your golang development environment, per
[golang.org](http://golang.org/doc/install).
- Install the [`cf CLI`](https://github.com/cloudfoundry/cli) >= `8.5.0`. Make
sure that it is accessible in your `$PATH`.
Expand All @@ -53,7 +53,7 @@ in such a way as to impact other tests.
All `go` dependencies required by CATs
are vendored in the `vendor` directory.

Make sure to have Golang 1.21+
Make sure to have Golang 1.22+

In order to update a current dependency to a specific version,
do the following:
Expand Down
2 changes: 1 addition & 1 deletion assets/binary/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/binary

go 1.21
go 1.22.0
2 changes: 1 addition & 1 deletion assets/catnip/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/catnip

go 1.21
go 1.22.0

require (
code.cloudfoundry.org/clock v1.2.0
Expand Down
2 changes: 1 addition & 1 deletion assets/credhub-service-broker/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/credhub-service-broker

go 1.21
go 1.22.0

require (
code.cloudfoundry.org/credhub-cli v0.0.0-20230320130818-a7d5420b283b
Expand Down
2 changes: 1 addition & 1 deletion assets/go_calls_ruby/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/go_calls_ruby

go 1.21
go 1.22.0
2 changes: 1 addition & 1 deletion assets/golang/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/golang

go 1.21
go 1.22.0
6 changes: 3 additions & 3 deletions assets/golang/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
applications:
- env:
GOPACKAGENAME: go-online
GOVERSION: go1.21
- env:
GOPACKAGENAME: go-online
GOVERSION: go1.22
2 changes: 1 addition & 1 deletion assets/grpc/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/grpc

go 1.21
go 1.22.0

require (
google.golang.org/grpc v1.65.0
Expand Down
2 changes: 1 addition & 1 deletion assets/http2/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/http2

go 1.21
go 1.22.0

require golang.org/x/net v0.27.0

Expand Down
2 changes: 1 addition & 1 deletion assets/logging-route-service/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/cloudfoundry-samples/logging-route-service

go 1.21
go 1.22.0
10 changes: 5 additions & 5 deletions assets/logging-route-service/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
applications:
- buildpacks:
- go_buildpack
env:
GOVERSION: go1.21
GOPACKAGENAME: github.com/cloudfoundry-samples/logging-route-service
- buildpacks:
- go_buildpack
env:
GOVERSION: go1.22
GOPACKAGENAME: github.com/cloudfoundry-samples/logging-route-service
2 changes: 1 addition & 1 deletion assets/multi-port-app/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/multi-port-app

go 1.21
go 1.22.0
4 changes: 2 additions & 2 deletions assets/multi-port-app/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
applications:
- env:
GOVERSION: go1.21
- env:
GOVERSION: go1.22
2 changes: 1 addition & 1 deletion assets/pora/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/pora

go 1.21
go 1.22.0
12 changes: 6 additions & 6 deletions assets/pora/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
applications:
- name: pora
buildpacks:
- go_buildpack
env:
GOPACKAGENAME: pora
GOVERSION: go1.21
- name: pora
buildpacks:
- go_buildpack
env:
GOPACKAGENAME: pora
GOVERSION: go1.22
2 changes: 1 addition & 1 deletion assets/proxy/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module example-apps/proxy

go 1.21
go 1.22.0
2 changes: 1 addition & 1 deletion assets/proxy/internal-route-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ applications:
buildpack: go_buildpack
env:
GOPACKAGENAME: example-apps/proxy
GOVERSION: go1.21
GOVERSION: go1.22
routes:
- route: app-smoke.apps.internal
4 changes: 2 additions & 2 deletions assets/proxy/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ applications:
memory: 32M
disk_quota: 32M
buildpacks:
- go_buildpack
- go_buildpack
env:
GOPACKAGENAME: example-apps/proxy
GOVERSION: go1.21
GOVERSION: go1.22
2 changes: 1 addition & 1 deletion assets/syslog-drain-listener/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/syslog-drain-listener

go 1.21
go 1.22.0

require code.cloudfoundry.org/tlsconfig v0.0.0-20220621140725-0e6fbd869921
8 changes: 4 additions & 4 deletions assets/syslog-drain-listener/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
applications:
- name: syslog-drain-listener
env:
GOPACKAGENAME: main
GOVERSION: go1.21
- name: syslog-drain-listener
env:
GOPACKAGENAME: main
GOVERSION: go1.22
2 changes: 1 addition & 1 deletion assets/tcp-listener/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/tcp-listener

go 1.21
go 1.22.0
6 changes: 3 additions & 3 deletions assets/tcp-listener/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
applications:
- env:
GOPACKAGENAME: tcp-listener
GOVERSION: go1.21
- env:
GOPACKAGENAME: tcp-listener
GOVERSION: go1.22
2 changes: 1 addition & 1 deletion assets/worker/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/cloudfoundry/cf-acceptance-tests/assets/worker

go 1.21
go 1.22.0
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cloudfoundry/cf-acceptance-tests

go 1.21
go 1.22.0

require (
code.cloudfoundry.org/archiver v0.0.0-20230220125704-e06c77649d28
Expand Down

7 comments on commit 043a63f

@thelangley
Copy link

Choose a reason for hiding this comment

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

@ctlong, hey this change causes breaks in our pipelines as the 1.22.0 runtime isn't available in the buildpack and it causes it to download the older specific 1.22.0 from proxy.golang.org which we block.

Could you please change this 1.22.0 values to be more flexible like 1.22 then the apps will bounce between the available runtimes as new buildpacks are released?

@ctlong
Copy link
Member Author

@ctlong ctlong commented on 043a63f Aug 13, 2024

Choose a reason for hiding this comment

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

To be clear, 1.22.0 is valid, as the go line is only meant to specify the minimum version of Go for a project.

I've no problem changing these to use 1.22 right now. I would recommend revisiting your buildpack logic though, as it's likely that this project (or real production Go apps) will use this format again in the future.

@thelangley
Copy link

Choose a reason for hiding this comment

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

Thanks @ctlong , appreciate the time

Our buildpack packaging is just a simple offline build using the official library which includes the main runtimes. We haven't done anything special to remove stuff.

Here's the error, maybe I'm not articulating it particularly well or have misunderstood the error and it's more of a the test assets needing go mod vendoring issue then.

I just know that this issue appeared after the recent pinning.

     2024-08-12T06:16:03.28+0000 [STG/0] OUT **ERROR** problem retrieving main package name: go: downloading go1.22.0 (linux/amd64)

     2024-08-12T06:16:03.28+0000 [STG/0] OUT go: download go1.22.0: golang.org/[email protected]: Get "https://proxy.golang.org/golang.org/toolchain/@v/v0.0.1-go1.22.0.linux-amd64.zip": dial tcp 216.58.212.241:443: connect: connection refused

Not sure which asset it is but it causes this test to fail [apps] Healthcheck when the healthcheck is set to none [It] starts up successfully

@ctlong
Copy link
Member Author

@ctlong ctlong commented on 043a63f Aug 15, 2024

Choose a reason for hiding this comment

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

I would recommend looking into your GOTOOLCHAIN setting. This error looks to be coming from your Go runtime trying, and failing, to implement forward/backward compatibility by downloading (what it determines to be) the correct toolchain for this project.

You can turn off all toolchain checks by setting GOTOOLCHAIN=local, which I think would likely fix your error.

@thelangley
Copy link

Choose a reason for hiding this comment

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

Hey @ctlong , this sounds interesting but I'm not sure how I would implement this in a buildpack. I only want to consume a non-hacked offline version of the "official" go-buildpack and run the stock cf-acceptance-tests against this but since this change was made, this isn't possible.

Are you suggesting that we clone/fork/repackage all of the assets in the cf-acceptance-tests to have this GOTOOLCHAIN setting or sedding the cf-acceptance-tests scripts to use GOTOOLCHAIN set to local?

It doesn't sound very intuitive

https://docs.cloudfoundry.org/buildpacks/go/index.html seems to indicate "When you specify versions, specify only majoror[sic] minor versions, such as Go 1.6, rather than Go 1.6.0. This ensures you receive the most recent patches."

If this is cf-acceptance-tests which is used to test specific versions of CF which specific dependencies, you'd want to make sure that you're testing apps against the buildpacks relevant for that version and the default runtimes contained within. You'd need to go back to February to find a buildpack with 1.22.0 runtime set as default. So currently you're testing a modern CF, using a new/modern buildpack with old dependencies from a non-default runtime.

@ctlong
Copy link
Member Author

@ctlong ctlong commented on 043a63f Aug 28, 2024

Choose a reason for hiding this comment

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

I only want to consume a non-hacked offline version of the "official" go-buildpack and run the stock cf-acceptance-tests against this but since this change was made, this isn't possible.

Unfortunately, the "official" Go Buildpack is online-only and neither the folks maintaining it, nor CATs, test it for offline use-cases, as far as I know. CATs' CI, which only tests the Go Buildpack in an online setting, succeeded. Obviously, we would like to accommodate every use-case, but that's not always possible.

Hopefully, the changes in #1195 work for both your use-case, and others'.

Are you suggesting that we clone/fork/repackage all of the assets in the cf-acceptance-tests to have this GOTOOLCHAIN setting or sedding the cf-acceptance-tests scripts to use GOTOOLCHAIN set to local?

I'm not suggesting either of those options.

  1. GOTOOLCHAIN is an env var, so it can't be "set" on the code contained in the modules in the assets directory. It could be provided as an env var in the relevant app manifests, but I don't know if the Go buildpack will actually pick that up when compiling the apps.
  2. Since buildpacks compile apps on-platform, it won't do any good to set that env var locally.

What I was suggesting is that the offline Go Buildpack in question should change its default GOTOOLCHAIN env var to only present the versions that are bundled in that buildpack. Since it presumably only has a few versions of Go bundled, and can't reach out to the internet to download more, it would ideally export a GOTOOLCHAIN env var of value x+path, where x is the lowest version of Go that is bundled. As of this writing, that would be 1.21.13 in the latest release of the Go Buildpack, so 1.21.13+path. A simpler alternative would be to just export GOTOOLCHAIN as local to skip compatibility computation and use the installed version.

https://docs.cloudfoundry.org/buildpacks/go/index.html seems to indicate "When you specify versions, specify only majoror[sic] minor versions, such as Go 1.6, rather than Go 1.6.0. This ensures you receive the most recent patches."

That docs line is 8 years old (ignoring a minor cosmetic edit). Go modules were only introduced around 6 years ago, so there's no way that line was referring to the go line in a Go module.

If this is cf-acceptance-tests which is used to test specific versions of CF which specific dependencies, you'd want to make sure that you're testing apps against the buildpacks relevant for that version and the default runtimes contained within. You'd need to go back to February to find a buildpack with 1.22.0 runtime set as default. So currently you're testing a modern CF, using a new/modern buildpack with old dependencies from a non-default runtime.

You seem to be misunderstanding the purpose of the go line in the Go Module. According to the Go Modules Reference, it only "sets the minimum version of Go required to use this module". If the unset toolchain in the Go Buildpack results in a value of auto, which I suspect it does, then it would elect to use the latest version of Go available. In a supported, online use-case, that would be go1.23.0.

@ctlong
Copy link
Member Author

@ctlong ctlong commented on 043a63f Aug 28, 2024

Choose a reason for hiding this comment

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

This medium (i.e. comments on a commit) is too hard for me to track. If you want to continue this conversation further, I'd suggest you raise a GH issue or start a thread in CFF Slack.

Please sign in to comment.