sorintlab / stolon

PostgreSQL cloud native High Availability and more.
https://talk.stolon.io
Apache License 2.0
4.62k stars 443 forks source link

go upgrade (1.20.3) - compile error using "k8s.io/api v0.18.19" instead of "k8s.io/api v0.17.3" #908

Closed full1985 closed 1 year ago

full1985 commented 1 year ago

What happened:

I would like to upgrade stolon with some new libraries and I made these kind of changes inside go module (compiling with go1.20.3):

$go version go version go1.20.3 linux/amd64

$diff --ignore-all-space go.mod_orig3 go.mod_orig 3a4,5

  github.com/coreos/bbolt v1.3.3 // indirect
  github.com/coreos/etcd v3.3.18+incompatible // indirect

7c9 < github.com/evanphx/json-patch v4.9.0+incompatible

  github.com/evanphx/json-patch v4.5.0+incompatible

9,10c11,12 < github.com/golang/mock v1.4.1 < github.com/google/go-cmp v0.5.5

  github.com/golang/mock v1.4.0
  github.com/google/go-cmp v0.4.0

15c17 < github.com/prometheus/client_golang v1.11.1

  github.com/prometheus/client_golang v1.4.1

22,24c24,26 < k8s.io/api v0.18.19 < k8s.io/apimachinery v0.18.19 < k8s.io/client-go v0.18.19

  k8s.io/api v0.17.3
  k8s.io/apimachinery v0.17.3
  k8s.io/client-go v0.17.3

27c29 < go 1.20

go 1.12

If I try to use library "k8s.io/api v0.18.19" instead of "k8s.io/api v0.17.3", I got the following errors running make command:

$make CGO_ENABLED=0 GO111MODULE=on go build -ldflags "-w -X github.com/sorintlab/stolon/cmd.Version=4bb4107523c2db09fa711c1d96ddfe33bacf405c-dirty" -o /opt/som/db/ta/git/stolon//bin/stolon-sentinel github.com/sorintlab/stolon/cmd/sentinel

github.com/sorintlab/stolon/internal/store

internal/store/k8s.go:80:41: not enough arguments in call to podsClient.Get have (string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) want ("context".Context, string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) internal/store/k8s.go:105:62: not enough arguments in call to podsClient.Patch have (string, "k8s.io/apimachinery/pkg/types".PatchType, []byte) want ("context".Context, string, "k8s.io/apimachinery/pkg/types".PatchType, []byte, "k8s.io/apimachinery/pkg/apis/meta/v1".PatchOptions, ...string) internal/store/k8s.go:122:48: not enough arguments in call to epsClient.Get have (string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) want ("context".Context, string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) internal/store/k8s.go:161:30: not enough arguments in call to epsClient.Update have ("k8s.io/api/core/v1".ConfigMap) want ("context".Context, "k8s.io/api/core/v1".ConfigMap, "k8s.io/apimachinery/pkg/apis/meta/v1".UpdateOptions) internal/store/k8s.go:171:30: not enough arguments in call to epsClient.Create have ("k8s.io/api/core/v1".ConfigMap) want ("context".Context, "k8s.io/api/core/v1".ConfigMap, "k8s.io/apimachinery/pkg/apis/meta/v1".CreateOptions) internal/store/k8s.go:194:48: not enough arguments in call to epsClient.Get have (string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) want ("context".Context, string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) internal/store/k8s.go:204:30: not enough arguments in call to epsClient.Update have ("k8s.io/api/core/v1".ConfigMap) want ("context".Context, "k8s.io/api/core/v1".ConfigMap, "k8s.io/apimachinery/pkg/apis/meta/v1".UpdateOptions) internal/store/k8s.go:209:30: not enough arguments in call to epsClient.Create have ("k8s.io/api/core/v1".ConfigMap) want ("context".Context, "k8s.io/api/core/v1".ConfigMap, "k8s.io/apimachinery/pkg/apis/meta/v1".CreateOptions) internal/store/k8s.go:226:47: not enough arguments in call to epsClient.Get have (string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) want ("context".Context, string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) internal/store/k8s.go:263:33: not enough arguments in call to podsClient.List have ("k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions) want ("context".Context, "k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions) internal/store/k8s.go:263:33: too many errors make: *** [sentinel] Error 1 $

What you expected to happen:

I should be able to compile correctly, I guess that with the new library that methods changed the number of arguments and need to be fixed accordingly

How to reproduce it (as minimally and precisely as possible):

see above the details

Anything else we need to know?:

Environment:

development

sorintlab/stolon:master-pg13

$cat /etc/os-release NAME="Amazon Linux" VERSION="2" ID="amzn" ID_LIKE="centos rhel fedora" VERSION_ID="2" PRETTY_NAME="Amazon Linux 2" ANSI_COLOR="0;33" CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2" HOME_URL="https://amazonlinux.com/"

sgotti commented 1 year ago

@full1985 If you want to contribute to stolon updating its dependencies feel free to do it. Just open multiple PR for every group of dependencies or the changes will be too much for a single PR.

If you're asking why just updating the dependencies doesn't compile: it's normal if dependencies changes their API, you should understand the compilation error, update the related code and test it.