kubewharf / kubebrain

A High Performance Metadata System for Kubernetes
Apache License 2.0
790 stars 77 forks source link

chore: remove the dependency with k8s.io/kubernetes #5

Closed STRRL closed 2 years ago

STRRL commented 2 years ago

Signed-off-by: STRRL im@strrl.dev

What type of PR is this?

enhancements

What this PR does / why we need it:

Which issue(s) this PR fixes:

4

Special notes for your reviewer:

No other notes.

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

divanodestiny commented 2 years ago

@STRRL Thx~ It would be great if you can remove the replacement here, and run go mod tidy to refresh the file go.sum https://github.com/kubewharf/kubebrain/blob/793d0cfde538ab9d05995efdc54e9e594fb44d15/go.mod#L57

STRRL commented 2 years ago

@STRRL Thx~ It would be great if you can remove the replacement here, and run go mod tidy to refresh the file go.sum

https://github.com/kubewharf/kubebrain/blob/793d0cfde538ab9d05995efdc54e9e594fb44d15/go.mod#L57

Updated! PTAL!

I also updated the pseudo version for k8s.io/kube-openapi as the version used in kubernetes 1.20.4

STRRL commented 2 years ago

I found other issues when I remove the replace statements in go.mod:

make            
/home/strrl/playground/github/kubebrain
fatal: No names found, cannot describe anything.

build env 
version         prune-kubernetes-dependency
sha             bc573df
go_version      go1.18.3
go_os           linux
go_arch         amd64
storage         Badger

# github.com/kubewharf/kubebrain/pkg/backend/election
../pkg/backend/election/election.go:68:9: cannot use r.resourceLock (variable of type *resourceLock) as type resourcelock.Interface in return statement:
        *resourceLock does not implement resourcelock.Interface (wrong type for Create method)
                have Create(ler resourcelock.LeaderElectionRecord) error
                want Create(ctx context.Context, ler resourcelock.LeaderElectionRecord) error
make: *** [makefile:4: badger] Error 2

It relates to changes in the interface.

STRRL commented 2 years ago

I found other issues when I remove the replace statements in go.mod:

make            
/home/strrl/playground/github/kubebrain
fatal: No names found, cannot describe anything.

build env 
version         prune-kubernetes-dependency
sha             bc573df
go_version      go1.18.3
go_os           linux
go_arch         amd64
storage         Badger

# github.com/kubewharf/kubebrain/pkg/backend/election
../pkg/backend/election/election.go:68:9: cannot use r.resourceLock (variable of type *resourceLock) as type resourcelock.Interface in return statement:
        *resourceLock does not implement resourcelock.Interface (wrong type for Create method)
                have Create(ler resourcelock.LeaderElectionRecord) error
                want Create(ctx context.Context, ler resourcelock.LeaderElectionRecord) error
make: *** [makefile:4: badger] Error 2

It relates to changes in the interface.

What do you think about it? @divanodestiny

divanodestiny commented 2 years ago

I found other issues when I remove the replace statements in go.mod:

make            
/home/strrl/playground/github/kubebrain
fatal: No names found, cannot describe anything.

build env 
version         prune-kubernetes-dependency
sha             bc573df
go_version      go1.18.3
go_os           linux
go_arch         amd64
storage         Badger

# github.com/kubewharf/kubebrain/pkg/backend/election
../pkg/backend/election/election.go:68:9: cannot use r.resourceLock (variable of type *resourceLock) as type resourcelock.Interface in return statement:
        *resourceLock does not implement resourcelock.Interface (wrong type for Create method)
                have Create(ler resourcelock.LeaderElectionRecord) error
                want Create(ctx context.Context, ler resourcelock.LeaderElectionRecord) error
make: *** [makefile:4: badger] Error 2

It relates to changes in the interface.

What do you think about it? @divanodestiny

  • Keep using replace k8s.io/* dependencies with version 1.14.x, then update dependencies and codes about interface changes in other PR?
  • Or make required changes in this PR?

Just keep k8s.io/* dependencies with version 1.14 now,and we will find the way to update them later. It seems that the resourcelock.Interface is changed after v1.18.0-beta.0

STRRL commented 2 years ago

I found other issues when I remove the replace statements in go.mod:

make            
/home/strrl/playground/github/kubebrain
fatal: No names found, cannot describe anything.

build env 
version         prune-kubernetes-dependency
sha             bc573df
go_version      go1.18.3
go_os           linux
go_arch         amd64
storage         Badger

# github.com/kubewharf/kubebrain/pkg/backend/election
../pkg/backend/election/election.go:68:9: cannot use r.resourceLock (variable of type *resourceLock) as type resourcelock.Interface in return statement:
        *resourceLock does not implement resourcelock.Interface (wrong type for Create method)
                have Create(ler resourcelock.LeaderElectionRecord) error
                want Create(ctx context.Context, ler resourcelock.LeaderElectionRecord) error
make: *** [makefile:4: badger] Error 2

It relates to changes in the interface.

What do you think about it? @divanodestiny

  • Keep using replace k8s.io/* dependencies with version 1.14.x, then update dependencies and codes about interface changes in other PR?
  • Or make required changes in this PR?

Just keep k8s.io/* dependencies with version 1.14 now,and we will find the way to update them later. It seems that the resourcelock.Interface is changed after v1.18.0-beta.0

got that.

STRRL commented 2 years ago

Updated! PTAL! @divanodestiny

PS: I am very pleased to help if you meet some issue when bump the version of kubernetes deps. We (Chaos Mesh Contributors) also make a script for upgrade replace statements in go.mod: https://github.com/chaos-mesh/chaos-mesh/blob/master/hack/update-kubernetes-library.sh

STRRL commented 2 years ago

Another thing needs to be mentioned: when I tried to execute go mod tidy, this issue occurs on me:

$ go mod tidy
go: finding module for package github.com/googleapis/gnostic/OpenAPIv2
github.com/kubewharf/kubebrain/pkg/server/service/leader imports
        k8s.io/client-go/tools/leaderelection tested by
        k8s.io/client-go/tools/leaderelection.test imports
        k8s.io/client-go/kubernetes/fake imports
        k8s.io/client-go/discovery imports
        github.com/googleapis/gnostic/OpenAPIv2: module github.com/googleapis/gnostic@latest found (v0.6.9), but does not contain package github.com/googleapis/gnostic/OpenAPIv2

That's a historical issue with kubernetes client-go: https://github.com/kubernetes/client-go/issues/741#issuecomment-606883355

I am not sure why you did not face this issue. Maybe the (internal) go module proxy server that you used cached an old version for github.com/googleapis/gnostic@latest.

And that's the reason why I replace the github.com/googleapis/gnostic with version v0.3.1

divanodestiny commented 2 years ago

@STRRL Thx for your help~ It seems to work now. I will recheck this PR after merging #2, which sets the actions for UT and lint to run basic checks.

divanodestiny commented 2 years ago

@STRRL hi~ would you mind updating this PR to trigger the workflows, which were set recently.

STRRL commented 2 years ago

@STRRL hi~ would you mind updating this PR to trigger the workflows, which were set recently.

OK! I would have a try later.