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

✨ Use ErrorIfCRDPathMissing in EnvTest #1765

Merged
merged 1 commit into from
Jan 20, 2021

Conversation

jamielennox
Copy link
Contributor

The error message if the path to CRDs is missing is misleading.
envtest.Environment has an option to throw a sensible error here if the
path is wrong and for kubebuilder it would be likely we always want to
upload our CRDs.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 2, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @jamielennox!

It looks like this is your first PR to kubernetes-sigs/kubebuilder 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubebuilder has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 2, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @jamielennox. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 2, 2020
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 2, 2020
@jamielennox
Copy link
Contributor Author

I'm not sure how you handle changes here. You can squash the PR or i can merge them and force push. Let me know.

@prafull01
Copy link
Contributor

Hi @jamielennox You need to squash the commits into 1 commit and force push. Thanks

Copy link
Contributor

@Adirio Adirio left a comment

Choose a reason for hiding this comment

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

Code-wise, the change LGTM. I don't know what is implied by this flag so someone with better knowledge about EnvTest should aprove it.

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 2, 2020
@prafull01
Copy link
Contributor

It is a good to have functionality, when the CRD path specified envtest is not present, it throws error (which it should be). With current implementation even if the CRD is not present, the scaffolded suite doesn't throw error.
I tested it locally, kb init and kb create api, these two command will scaffold the suite_test.go but does not generate the config/crd/bases folder until I run make test all:

Running tests before make manifests without these changes:

prafull@EMPID18004:~/go/src/github.com/prafull01/kubebuilder/proj$ go test -v ./controllers/...
=== RUN   TestAPIs
Running Suite: Controller Suite
===============================
Random Seed: 1604307472
Will run 0 of 0 specs



Ran 0 of 0 Specs in 4.208 seconds
SUCCESS! -- 0 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestAPIs (4.21s)
PASS
ok  	sigs.k8s.io/kubebuilder/controllers	4.218s

Running tests before make manifests with these changes:

prafull@EMPID18004:~/go/src/github.com/prafull01/kubebuilder/proj$ go test -v ./controllers/...
=== RUN   TestAPIs
Running Suite: Controller Suite
===============================
Random Seed: 1604307507
Will run 0 of 0 specs

STEP: bootstrapping test environment
2020-11-02T14:28:27.418+0530	DEBUG	controller-runtime.test-env	starting control plane	{"api server flags": []}
2020-11-02T14:28:32.630+0530	DEBUG	controller-runtime.test-env	installing CRDs
Failure [5.212 seconds]
[BeforeSuite] BeforeSuite 
/home/prafull/go/src/github.com/prafull01/kubebuilder/proj/controllers/suite_test.go:52

  Unexpected error:
      <*os.PathError | 0xc0006711a0>: {
          Op: "stat",
          Path: "../config/crd/bases",
          Err: 0x2,
      }
      stat ../config/crd/bases: no such file or directory
  occurred

  /home/prafull/go/src/github.com/prafull01/kubebuilder/proj/controllers/suite_test.go:63
------------------------------


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

Running test with these changes after make manifests which will generate the CRD:

prafull@EMPID18004:~/go/src/github.com/prafull01/kubebuilder/proj$ go test -v ./controllers/...
=== RUN   TestAPIs
Running Suite: Controller Suite
===============================
Random Seed: 1604307565
Will run 0 of 0 specs



Ran 0 of 0 Specs in 7.440 seconds
SUCCESS! -- 0 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestAPIs (7.44s)
PASS
ok  	sigs.k8s.io/kubebuilder/controllers	7.453s

IMO, this change is LGTM.

PTAL for
/cc @camilamacedo86

@prafull01
Copy link
Contributor

/approve

@camilamacedo86
Copy link
Member

/hold

Until the fix #1770 get merged and this one realised with master.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 2, 2020
@camilamacedo86
Copy link
Member

HI @jamielennox,

Could you please rebase it with the master, run make generate and push?

/hold
cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 3, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 4, 2020
@jamielennox
Copy link
Contributor Author

I've very simply rebased this, reading #1770 maybe we want to only set true on WireResource?

@Adirio
Copy link
Contributor

Adirio commented Nov 4, 2020

I've very simply rebased this, reading #1770 maybe we want to only set true on WireResource?

Probably yes

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 5, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2020
@camilamacedo86
Copy link
Member

Hi @jamielennox,

Could you check what will be the behaviour faced after this change in the scenario #1765 (comment)? Could you please let us know?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2020
@camilamacedo86
Copy link
Member

Hi @jamielennox,

Could you please get it rebased with the master for we are able to move forward with it?

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 14, 2020
The error message if the path to CRDs is missing is misleading.
envtest.Environment has an option to throw a sensible error here if the
path is wrong and for kubebuilder it would be likely we always want to
upload our CRDs.
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 17, 2020
@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-16-15

@camilamacedo86
Copy link
Member

/restest

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

It receives approval of 2 very active contributors/maintainers (@prafull01 and @Adirio)
The changes here shows fine for me as well.

Great job @jamielennox 🥇

/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Adirio, camilamacedo86, jamielennox, prafull01

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@camilamacedo86
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 20, 2021
@k8s-ci-robot k8s-ci-robot merged commit 79ecd51 into kubernetes-sigs:master Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants