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

enable use of existing cluster in envtest #64

Closed

Conversation

SeanMooney
Copy link
Contributor

this change modifies envtest to use an existing cluster.

@SeanMooney
Copy link
Contributor Author

so this is currently uncondtionally using an exsiting cluster
since crc is not running in ci we dont actully want that
So ill see if i can disable it by default but still get it to work in vscode in a debugger and via make with and env var set

@gibizer
Copy link
Contributor

gibizer commented Sep 21, 2022

so this is currently uncondtionally using an exsiting cluster since crc is not running in ci we dont actully want that So ill see if i can disable it by default but still get it to work in vscode in a debugger and via make with and env var set

Yeah, I would like to keep the possibility to run the envtest locally without CRC. With this patch I got the following error if I run make test locally:

Unexpected error:
<*fmt.wrapError | 0xc00056d640>: {
msg: "unable to get configuration for existing cluster: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable",
err: <clientcmd.errConfigurationInvalid | len:1, cap:1>[
<*clientcmd.errEmptyConfig | 0xc0001cd550>{
message: "no configuration has been provided, try setting KUBERNETES_MASTER environment variable",
},
],
}
unable to get configuration for existing cluster: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
occurred

For me either a separate make target or some conditional env variable is OK to be used to make the test work in both cases.

this change modifies envtest to use an existing cluster
dynamicly if USE_EXISTING_CLUSTER is defiend in the current
env. To do this when running under vscod this to settings.json

{
    "go.testEnvVars": {
        "USE_EXISTING_CLUSTER": "true",
    }
}
@SeanMooney
Copy link
Contributor Author

we dont need this at all for viscose

we just need to set
{
"go.testEnvVars": {
"USE_EXISTING_CLUSTER": "true",
}
}

in settings.json

if i set it to false on my host the test fail becuase im missing binaires in my normal path that envtest needs but if i set it to true they work so i might just abandon this.

what do you think?

i realised this probaly was not needed after i implemented looking it up form the env but envtest already supprot that so all that was/is missing is ensuring that its set in the env in vscode and or when you run make

im not sure if make normally passes all env vars or if we need to plumb those through manually but ill probably just run these from vscode so i can use the debugger to step line by line if needed anyway so settings.json works for me.

@gibizer
Copy link
Contributor

gibizer commented Sep 21, 2022

we dont need this at all for viscose

we just need to set { "go.testEnvVars": { "USE_EXISTING_CLUSTER": "true", } }

in settings.json

if i set it to false on my host the test fail becuase im missing binaires in my normal path that envtest needs but if i set it to true they work so i might just abandon this.

what do you think?

i realised this probaly was not needed after i implemented looking it up form the env but envtest already supprot that so all that was/is missing is ensuring that its set in the env in vscode and or when you run make

im not sure if make normally passes all env vars or if we need to plumb those through manually but ill probably just run these from vscode so i can use the debugger to step line by line if needed anyway so settings.json works for me.

So I assume make test would work for you as well if you set USE_EXISTING_CLUSTER="true" env. So I'm OK to abandon this.

@SeanMooney
Copy link
Contributor Author

make test just works for me and i have no idea why

[stack@crc nova-operator]$ make test
test -s /home/stack/repos/nova-operator/bin/controller-gen || GOBIN=/home/stack/repos/nova-operator/bin go install sigs.k8s.io/controller-tools/cmd/[email protected]
/home/stack/repos/nova-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/home/stack/repos/nova-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
test -s /home/stack/repos/nova-operator/bin/setup-envtest || GOBIN=/home/stack/repos/nova-operator/bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
KUBEBUILDER_ASSETS="/home/stack/.local/share/kubebuilder-envtest/k8s/1.24.2-linux-amd64" go test ./... -coverprofile cover.out
? github.com/openstack-k8s-operators/nova-operator [no test files]
ok github.com/openstack-k8s-operators/nova-operator/controllers 6.973s coverage: 0.0% of statements
[stack@crc nova-operator]$ echo $USE_EXISTING_CLUSTER

[stack@crc nova-operator]

i assume that while the binary ar enot on my path for go test to work

Ran 0 of 0 Specs in 0.013 seconds
FAIL! -- 0 Passed | 0 Failed | 0 Pending | 0 Skipped

You're using deprecated Ginkgo functionality:

Ginkgo 2.0 is under active development and will introduce several new features, improvements, and a small handful of breaking changes.
A release candidate for 2.0 is now available and 2.0 should GA in Fall 2021. Please give the RC a try and send us feedback!

You are using a custom reporter. Support for custom reporters will likely be removed in V2. Most users were using them to generate junit or teamcity reports and this functionality will be merged into the core reporter. In addition, Ginkgo 2.0 will support emitting a JSON-formatted report that users can then manipulate to generate custom reports.

If this change will be impactful to you please leave a comment on onsi/ginkgo#711
Learn more at: https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md#removed-custom-reporters

To silence deprecations that can be silenced set the following environment variable:
ACK_GINKGO_DEPRECATIONS=1.16.5

--- FAIL: TestAPIs (0.01s)
FAIL
coverage: 0.0% of statements
FAIL github.com/openstack-k8s-operators/nova-operator/controllers 0.046s
FAIL

the fact make test is adding KUBEBUILDER_ASSETS=/home/stack/.local/share/kubebuilder-envtest/k8s/1.24.2-linux-amd64

which contains the required deps is why that works

[stack@crc nova-operator]$ ls ~/.local/share/kubebuilder-envtest/k8s/1.24.2-linux-amd64/
etcd kube-apiserver kubectl

that is not using CRC but if i tell it to use the existing env it might

@SeanMooney SeanMooney closed this Sep 21, 2022
@gibizer
Copy link
Contributor

gibizer commented Sep 21, 2022

make test just works for me and i have no idea why

[stack@crc nova-operator]$ make test test -s /home/stack/repos/nova-operator/bin/controller-gen || GOBIN=/home/stack/repos/nova-operator/bin go install sigs.k8s.io/controller-tools/cmd/[email protected] /home/stack/repos/nova-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases /home/stack/repos/nova-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." go fmt ./... go vet ./... test -s /home/stack/repos/nova-operator/bin/setup-envtest || GOBIN=/home/stack/repos/nova-operator/bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest KUBEBUILDER_ASSETS="/home/stack/.local/share/kubebuilder-envtest/k8s/1.24.2-linux-amd64" go test ./... -coverprofile cover.out ? github.com/openstack-k8s-operators/nova-operator [no test files] ok github.com/openstack-k8s-operators/nova-operator/controllers 6.973s coverage: 0.0% of statements [stack@crc nova-operator]$ echo $USE_EXISTING_CLUSTER

[stack@crc nova-operator]

i assume that while the binary ar enot on my path for go test to work

Ran 0 of 0 Specs in 0.013 seconds FAIL! -- 0 Passed | 0 Failed | 0 Pending | 0 Skipped

You're using deprecated Ginkgo functionality:

Ginkgo 2.0 is under active development and will introduce several new features, improvements, and a small handful of breaking changes. A release candidate for 2.0 is now available and 2.0 should GA in Fall 2021. Please give the RC a try and send us feedback!

* To learn more, view the migration guide at https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md

* For instructions on using the Release Candidate visit https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md#using-the-beta

* To comment, chime in at [Ginkgo 2.0 Proposal onsi/ginkgo#711](https://github.com/onsi/ginkgo/issues/711)

You are using a custom reporter. Support for custom reporters will likely be removed in V2. Most users were using them to generate junit or teamcity reports and this functionality will be merged into the core reporter. In addition, Ginkgo 2.0 will support emitting a JSON-formatted report that users can then manipulate to generate custom reports.

If this change will be impactful to you please leave a comment on onsi/ginkgo#711 Learn more at: https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md#removed-custom-reporters

To silence deprecations that can be silenced set the following environment variable: ACK_GINKGO_DEPRECATIONS=1.16.5

--- FAIL: TestAPIs (0.01s) FAIL coverage: 0.0% of statements FAIL github.com/openstack-k8s-operators/nova-operator/controllers 0.046s FAIL

the fact make test is adding KUBEBUILDER_ASSETS=/home/stack/.local/share/kubebuilder-envtest/k8s/1.24.2-linux-amd64

which contains the required deps is why that works

[stack@crc nova-operator]$ ls ~/.local/share/kubebuilder-envtest/k8s/1.24.2-linux-amd64/ etcd kube-apiserver kubectl

that is not using CRC but if i tell it to use the existing env it might

There is make envtest target that sets up the local binaries to be able to run the test without CRC.

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.

2 participants