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

k8sutil moved to internal package #3792

Closed
Kaitou786 opened this issue Aug 27, 2020 · 10 comments
Closed

k8sutil moved to internal package #3792

Kaitou786 opened this issue Aug 27, 2020 · 10 comments

Comments

@Kaitou786
Copy link

Bug Report

What did you do?

Upgrade operator-sdk from 0.18.2 -> 1.0.0

What did you expect to see?

Hi, we were in the process of upgrading our golang operator from 0.18.x to 1.0.0, and noticed k8sutil has been moved to an internal package, we removed its dependency from our codebase but, some of our other dependency like operator-marketplace still imports it causing our upgrade to halt. So I just wanted to ask is there any specific reason for why it is moved to an internal package now? I think it was used by many other projects as well

What did you see instead? Under which circumstances?

Environment

Operator type:

@joelanford
Copy link
Member

@Kaitou786 k8sutil is obsolete for use in operator projects as of SDK 1.0 because projects scaffolded by Operator SDK 1.0 no longer use it. In fact, there are no longer any public APIs in the Operator SDK repo.

The helper libraries that did exist and are still relevant have been moved to github.com/operator-framework/operator-lib.

Your project should no longer depend directly on operator-sdk, so you should be able to continue importing operator-marketplace and allow it to continue importing an older version of Operator SDK to resolve its import for k8sutil.

Can you provide more details about the issue you're running into?

  1. What does your go.mod file contain?
  2. What command are you running that is resulting in an error?
  3. What is the output of that command?

@Kaitou786
Copy link
Author

Ah okay,
content of go.mod contents:

go 1.14

require (
	github.com/RHsyseng/operator-utils v0.0.0-20200108204558-82090ef57586
	github.com/coreos/prometheus-operator v0.41.1
	github.com/cucumber/gherkin-go/v11 v11.0.0
	github.com/cucumber/godog v0.10.0
	github.com/cucumber/messages-go/v10 v10.0.3
	github.com/go-logr/logr v0.1.0
	github.com/gobuffalo/packr/v2 v2.7.1
	github.com/google/uuid v1.1.1
	github.com/imdario/mergo v0.3.9
	github.com/infinispan/infinispan-operator v0.0.0-20200820122451-4ffef65c9410
	github.com/keycloak/keycloak-operator v0.0.0-20200826070637-fa5e7988b819
	github.com/machinebox/graphql v0.2.2
	github.com/matryer/is v1.4.0 // indirect
	github.com/onsi/ginkgo v1.12.1
	github.com/onsi/gomega v1.10.1
	github.com/openshift/api v3.9.1-0.20190924102528-32369d4db2ad+incompatible
	github.com/openshift/client-go v3.9.0+incompatible
	github.com/operator-framework/operator-lifecycle-manager v0.0.0-20200321030439-57b580e57e88
	github.com/operator-framework/operator-marketplace v0.0.0-20200826070533-bb7db1173eb2
	github.com/operator-framework/operator-sdk v1.0.0
	github.com/prometheus/common v0.10.0
	github.com/spf13/cobra v1.0.0
	github.com/stretchr/testify v1.6.1
	go.uber.org/zap v1.14.1
	gopkg.in/src-d/go-git.v4 v4.13.1
	gopkg.in/yaml.v2 v2.3.0
	k8s.io/api v0.18.6
	k8s.io/apiextensions-apiserver v0.18.6
	k8s.io/apimachinery v0.18.6
	k8s.io/client-go v12.0.0+incompatible
	k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6
	sigs.k8s.io/controller-runtime v0.6.2
)

replace (
	k8s.io/api => k8s.io/api v0.18.6
	k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.6
	k8s.io/apimachinery => k8s.io/apimachinery v0.18.6
	k8s.io/apiserver => k8s.io/apiserver v0.18.6
	k8s.io/cli-runtime => k8s.io/cli-runtime v0.18.6
	k8s.io/client-go => k8s.io/client-go v0.18.6
	k8s.io/cloud-provider => k8s.io/cloud-provider v0.18.6
	k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.18.6
	k8s.io/code-generator => k8s.io/code-generator v0.18.6
	k8s.io/component-base => k8s.io/component-base v0.18.6
	k8s.io/cri-api => k8s.io/cri-api v0.18.6
	k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.18.6
	k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.18.6
	k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.18.6
	k8s.io/kube-proxy => k8s.io/kube-proxy v0.18.6
	k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.18.6
	k8s.io/kubectl => k8s.io/kubectl v0.18.6
	k8s.io/kubelet => k8s.io/kubelet v0.18.6
	k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.18.6
	k8s.io/metrics => k8s.io/metrics v0.18.6
	k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.18.6
)

// Required by Helm
replace github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309

// fix Azure bogus https://github.com/kubernetes/client-go/issues/628
replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.2+incompatible // Required by OLM

2: Running go mod tidy
3: output of the command:

        github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared imports
        github.com/operator-framework/operator-sdk/pkg/k8sutil: module github.com/operator-framework/operator-sdk@latest found (v1.0.0), but does not contain package github.com/operator-framework/operator-sdk/pkg/k8sutil```

@joelanford
Copy link
Member

Can you try removing github.com/operator-framework/operator-sdk v1.0.0 from your go.mod and retry go mod tidy?

@Kaitou786
Copy link
Author

Thanks, it replaced it with an earlier version of operator-sdk, github.com/operator-framework/operator-sdk v0.18.2

@joelanford
Copy link
Member

Also, have you read the 1.0 migration guide? Among some other great benefits to using the new project layout, you may be able to drastically reduce the content of your go.mod file by re-scaffolding your project with operator-sdk init.

@Kaitou786
Copy link
Author

@joelanford, actually I was following that guide only, and re-scaffolded by operator-sdk init, but ended up writing a lot in go.mod due to the pinning of k8s deps to a particular version, before that I was getting v0.0.0 unknown revision error.

@joelanford
Copy link
Member

Ok cool! Yeah, that must mean that one of your project's dependencies still pulls in an older version of k8s.io/kubernetes, which causes that (really annoying 🙂) error.

Sounds like you're good to go now though, so I'll close this one. If you encounter anything else while migrating, definitely open more issues!

@Kaitou786
Copy link
Author

@joelanford just out of curiosity does the olm_cataloge dir removed from this new structure?

@joelanford
Copy link
Member

It is, things are restructured a bit. Generated packagemanifests and bundles will end up in the project root directory.

There are some base files that are used to generate packagemanifests and bundles in config/manifests.

@Vihari-Panathula
Copy link

Vihari-Panathula commented Aug 25, 2021

Can you try removing github.com/operator-framework/operator-sdk v1.0.0 from your go.mod and retry go mod tidy?

For me it didn't work.

github.com/operator-framework/operator-sdk/pkg/k8sutil: module github.com/operator-framework/operator-sdk@latest found (v1.11.0), but does not contain package github.com/operator-framework/operator-sdk/pkg/k8sutil
github.com/kontena/kubelet-rubber-stamp/cmd/manager imports
github.com/operator-framework/operator-sdk/version: module github.com/operator-framework/operator-sdk@latest found (v1.11.0), but does not contain package github.com/operator-framework/operator-sdk/version

@joelanford can you help me here.

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

No branches or pull requests

3 participants