Skip to content

upgrade Go version to 1.21.1#13877

Merged
roperzh merged 9 commits intomainfrom
13715-bump-go-version
Sep 13, 2023
Merged

upgrade Go version to 1.21.1#13877
roperzh merged 9 commits intomainfrom
13715-bump-go-version

Conversation

@roperzh
Copy link
Copy Markdown
Contributor

@roperzh roperzh commented Sep 12, 2023

For #13715, this:

  • Upgrades the Go version to 1.21.1, infrastructure changes are addressed separately at upgrade Go to 1.21.1 for infra #13878
  • Upgrades the linter version, as the current version doesn't work well after the Go upgrade
  • Fixes new linting errors (we now get errors for memory aliasing in loops! 🎉 )

After this is merged people will need to:

  1. Update their Go version. I use gvm and I did it like:
$ gvm install go1.21.1
$ gvm use go1.21.1 --default
  1. Update the local version of golangci-lint:
$ go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2
  1. (optional) depending on your setup, you might need to re-install some packages, for example:
# goimports to automatically import libraries
$  go install golang.org/x/tools/cmd/goimports@latest

# gopls for the language server
$ go install golang.org/x/tools/gopls@latest

# etc...

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/ or orbit/changes/.
    See Changes files for more information.
  • Manual QA for all new/changed functionality
    • For Orbit and Fleet Desktop changes:
      • Manual QA must be performed in the three main OSs, macOS, Windows and Linux.
      • Auto-update manual QA, from released version of component to new version (see tools/tuf/test).

@roperzh roperzh temporarily deployed to Docker Hub September 12, 2023 15:55 — with GitHub Actions Inactive
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 12, 2023

Codecov Report

Patch coverage: 31.57% and project coverage change: -0.01% ⚠️

Comparison is base (9c352ef) 58.76% compared to head (c7d1002) 58.76%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13877      +/-   ##
==========================================
- Coverage   58.76%   58.76%   -0.01%     
==========================================
  Files         899      900       +1     
  Lines       73855    74009     +154     
  Branches     2098     2098              
==========================================
+ Hits        43401    43489      +88     
- Misses      26996    27047      +51     
- Partials     3458     3473      +15     
Flag Coverage Δ
backend 59.30% <31.57%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
server/datastore/mysql/testing_utils.go 67.86% <0.00%> (-0.23%) ⬇️
server/mdm/microsoft/microsoft_mdm.go 0.00% <ø> (ø)
...ns/tables/20230315104937_EnsureUniformCollation.go 61.66% <20.00%> (+10.33%) ⬆️
server/datastore/mysql/app_configs.go 82.60% <100.00%> (+0.10%) ⬆️
server/datastore/mysql/packs.go 72.26% <100.00%> (+0.14%) ⬆️

... and 6 files with indirect coverage changes

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

@roperzh roperzh temporarily deployed to Docker Hub September 12, 2023 16:59 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 12, 2023 16:59 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 12, 2023 19:14 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 12, 2023 19:23 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 12, 2023 19:23 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 13, 2023 14:05 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 13, 2023 14:06 — with GitHub Actions Inactive
_, err := tx.Exec("SET SESSION sort_buffer_size = 2560000000")
if err != nil {
return fmt.Errorf("increasing global sort buffer size: %w", err)
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was getting:

Error 1038 (HY001): Out of sort memory, consider increasing server sort buffer size

on the newly added check for rows.Err below. I figured this is the simplest way to go about this without touching this tricky migration too much, but I'm open to any ideas.

@roperzh roperzh temporarily deployed to Docker Hub September 13, 2023 14:59 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 13, 2023 15:01 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 13, 2023 15:01 — with GitHub Actions Inactive
Comment thread .golangci.yml
main:
deny:
- pkg: github.com/pkg/errors
msg: "use ctxerr if a context.Context is available or stdlib errors.New / fmt.Errorf with the %w verb"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the configuration changed in this newer version, so I adjusted it accordingly.

@roperzh roperzh temporarily deployed to Docker Hub September 13, 2023 16:42 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub September 13, 2023 16:42 — with GitHub Actions Inactive
@roperzh roperzh marked this pull request as ready for review September 13, 2023 17:06
@roperzh roperzh requested review from a team and rachaelshaw as code owners September 13, 2023 17:06
Copy link
Copy Markdown
Member

@georgekarrv georgekarrv left a comment

Choose a reason for hiding this comment

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

LGTM, we should try to merge this asap so devs can get some runtime with it applied before release

}
secretsCreatedAt := make(map[string]*time.Time, len(existingSecrets))
for _, es := range existingSecrets {
es := es
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did this fix a bug? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it might! I'm not completely sure. How cool is that new check?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is an awesome check. The issue is that we were taking the address of es.CreatedAt in the loop, but es gets modified on each loop iteration, so that pointer pointed to the last CreatedAt in the existingSecrets slice. Unlikely to have been a big issue (since this is just the created-at timestamp), but still...

Copy link
Copy Markdown
Member

@mna mna left a comment

Choose a reason for hiding this comment

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

🎉

{"unenroll after 3 tries", nil, 3, false},
{"unenroll after one try", nil, 1, false},
{"error after max number of tries is exceeded", nil, 99, true},
{"error after max number of tries is exceeded", nil, 1000, true},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason this was bumped so much?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wanted to be on the safe side, but you made me wonder if I'm not hiding some dirt under the rug here. I will circle back to this between today and tomorrow.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh was that a flaky test previously?


// Load targets
for _, spec := range specs {
spec := spec
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah those were fine since we don't store the address (it gets used inside the loop before the next iteration), but makes sense that it's a bit much to ask of the lint check to go to that level of analysis.

@roperzh roperzh merged commit ea6b59f into main Sep 13, 2023
@roperzh roperzh deleted the 13715-bump-go-version branch September 13, 2023 18:59
rfairburn pushed a commit that referenced this pull request Oct 13, 2023
related to #13715, this updates the infra dependencies for the general
go upgrade that's happening at
#13877

I'm thinking we probably want to merge this after we're sure that
everything works well, maybe even after we have a release with go 1.21.1
out, so I'm making a separate PR.

---------

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
@roperzh roperzh mentioned this pull request May 20, 2024
2 tasks
roperzh added a commit that referenced this pull request May 20, 2024
For #16795, this:

- Updates Go to go1.22.3
- Per
  #16795 (comment),
  I also ran the following to update the versions requested by
  @getvictor

```
go get github.com/kataras/golog@v0.1.12
go get github.com/kataras/iris/v12@v12.2.11
go get github.com/sethvargo/go-password@v0.3.0
```

**Notes**

After this is merged people will need to update their Go version. I use gvm and I did it like:

```
$ gvm install go1.22.3
$ gvm use go1.22.3 --default
```

**Relevant changes**

The release notes mention:

> Previously, the variables declared by a “for” loop were created once
> and updated by each iteration. In Go 1.22, each iteration of the loop
> creates new variables, to avoid accidental sharing bugs.

However, we already have a lint rule (see
#13877) for this scenario, so it
shouldn't affect us.
roperzh added a commit that referenced this pull request May 23, 2024
For #16795, this:

- Updates Go to go1.22.3
- Per
#16795 (comment), I
also ran the following to update the versions requested by @getvictor

```
go get github.com/kataras/golog@v0.1.12
go get github.com/kataras/iris/v12@v12.2.11
go get github.com/sethvargo/go-password@v0.3.0
```

**Notes**

After this is merged people will need to update their Go version. I use
gvm and I did it like:

```
$ gvm install go1.22.3
$ gvm use go1.22.3 --default
```

**Relevant changes**

The release notes mention:

> Previously, the variables declared by a “for” loop were created once
> and updated by each iteration. In Go 1.22, each iteration of the loop
> creates new variables, to avoid accidental sharing bugs.

However, we already have a lint rule (see
#13877) for this scenario, so it
shouldn't affect us.
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.

5 participants