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

Changes in the installer script and the voyager code to upgrade golang version from 1.20 to 1.23.1 #1717

Merged
merged 7 commits into from
Sep 24, 2024

Conversation

ShivanshGahlot
Copy link
Collaborator

@ShivanshGahlot ShivanshGahlot commented Sep 20, 2024

  • Updated go.mod with the new version 1.23.1 and updated the unsupported library versions
  • Updated the installer script to install 1.23.1
  • Updated a code snippet that uses SortFunc to use the correct and latest way of implementing it
  • Updated go.yml to install Go version 1.23.1 on GH actions
  • Changed the staticcheck version to 2024.1.1. The older version was failing with the new golang version. Hence pinning it to the latest available at the time of this change.

### Jenkins Tests:
https://jenkins.dev.yugabyte.com/job/users/job/yb-voyager-testing/job/yb-voyager-testing-pipeline/3476/
https://jenkins.dev.yugabyte.com/job/users/job/yb-voyager-testing/job/yb-voyager-testing-pipeline/3475/
https://jenkins.dev.yugabyte.com/job/users/job/yb-voyager-testing/job/yb-voyager-testing-pipeline/3495/
https://jenkins.dev.yugabyte.com/job/users/job/yb-voyager-testing/job/yb-voyager-testing-pipeline/3494/

### Golang 1.21 new features:

  • The new functions min and max compute the smallest (or largest, for max) value of a fixed number of given arguments. See the language spec for details.
  • The new function clear deletes all elements from a map or zeroes all elements of a slice. See the language spec for details.

### Golang 1.22 new features:

  • 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.

  • “For” loops may now range over integers.

  • database/sql: The new Null[T] type provide a way to scan nullable columns for any column types.

  • slices:

       1. The new function Concat concatenates multiple slices.
       2. Functions that shrink the size of a slice (Delete, DeleteFunc, Compact, CompactFunc, and Replace) now zero the elements between the new length and the old length.
       3. Insert now always panics if the argument i is out of range. Previously it did not panic in this situation if there were no elements to be inserted.
    

### Golang 1.23 new features:

  • The “range” clause in a “for-range” loop now accepts iterator functions of the following types
func(func() bool)
func(func(K) bool)
func(func(K, V) bool)

as range expressions. Calls of the iterator argument function produce the iteration values for the “for-range” loop. For details see the iter package documentation, the language spec, and the Range over Function Types blog post.

  • The new iter package provides the basic definitions for working with user-defined iterators.

  • The slices package adds several functions that work with iterators:
    All returns an iterator over slice indexes and values.
    Values returns an iterator over slice elements.
    Backward returns an iterator that loops over a slice backward.
    Collect collects values from an iterator into a new slice.
    AppendSeq appends values from an iterator to an existing slice.
    Sorted collects values from an iterator into a new slice, and then sorts the slice.
    SortedFunc is like Sorted but with a comparison function.
    SortedStableFunc is like SortFunc but uses a stable sort algorithm.
    Chunk returns an iterator over consecutive sub-slices of up to n elements of a slice.

  • The maps package adds several functions that work with iterators:
    All returns an iterator over key-value pairs from a map.
    Keys returns an iterator over keys in a map.
    Values returns an iterator over values in a map.
    Insert adds the key-value pairs from an iterator to an existing map.
    Collect collects key-value pairs from an iterator into a new map and returns it.

  • path/filepath: The new Localize function safely converts a slash-separated path into an operating system path.

  • slices: The Repeat function returns a new slice that repeats the provided slice the given number of times.

  • database/sql: Errors returned by driver.Valuer implementations are now wrapped for improved error handling during operations like DB.Query, DB.Exec, and DB.QueryRow.

if [[ $version_ok -eq 1 ]]
then
output "Found golang=${gov}"
return
fi
fi
export GOROOT="/tmp/go"
GO_VERSION="go1.20"
GO_VERSION="go1.23.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

@ShivanshGahlot, I think you should also include the changes in the code base required for upgrading in the same PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have included those changes.

Copy link
Collaborator

@sanyamsinghal sanyamsinghal left a comment

Choose a reason for hiding this comment

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

@ShivanshGahlot please go through the change log of 1.23 release once.

Look at major changes - bug fixes, support for some new coding syntax removed/added.
Performance aspects etc...

Overall you can look from two perspective:

  1. If some existing syntax/feature got affected/unsupported.
  2. If some thing is new can make code better.
    For the later you can create tickets, but 1 will be required in this PR.

Also please run tests including - gh, jenkins, and Perf tests for verification

@ShivanshGahlot ShivanshGahlot changed the title Installing go version 1.23.0 in the installer script Installing go version 1.23.0 in the installer script and making corresponding changes in the voyager code Sep 23, 2024
Copy link
Contributor

@priyanshi-yb priyanshi-yb left a comment

Choose a reason for hiding this comment

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

LGTM,
Change the PR title to mention that its upgrade for 1.23.1 not just installing.
Please wait till tomorrow for others to take a look also before merging.

@@ -36,5 +36,5 @@ jobs:
- name: Run staticcheck
run: |
cd yb-voyager
go install honnef.co/go/tools/cmd/staticcheck@2023.1.7
go install honnef.co/go/tools/cmd/staticcheck@2024.1.1
Copy link
Contributor

@priyanshi-yb priyanshi-yb Sep 23, 2024

Choose a reason for hiding this comment

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

Mention in the description that this is also updated and reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@sanyamsinghal sanyamsinghal left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines +302 to +308
slices.SortFunc(allTables, func(a, b sqlname.NameTuple) int {
if a.ForKey() < b.ForKey() {
return -1 // a is less than b
} else if a.ForKey() > b.ForKey() {
return 1 // a is greater than b
}
return 0 // a is equal to b
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious, why was it required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They have changed the syntax. The sorting function now needs to return int instead of boolean:
https://pkg.go.dev/slices#SortFunc

@ShivanshGahlot ShivanshGahlot changed the title Installing go version 1.23.0 in the installer script and making corresponding changes in the voyager code Changes in the installer script and the voyager code to upgrade golang version from 1.20 to 1.23.1 Sep 24, 2024
@ShivanshGahlot ShivanshGahlot merged commit c6b0ae8 into main Sep 24, 2024
16 checks passed
@ShivanshGahlot ShivanshGahlot deleted the shivansh/installer-script-go-1.22 branch September 24, 2024 06:20
shaharuk-yb pushed a commit that referenced this pull request Oct 7, 2024
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.

3 participants