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

NewFakeClientWithScheme dies silently #354

Closed
michaelgugino opened this issue Mar 8, 2019 · 9 comments
Closed

NewFakeClientWithScheme dies silently #354

michaelgugino opened this issue Mar 8, 2019 · 9 comments
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@michaelgugino
Copy link

Current master commit:

log.Error(err, "failed to add object to fake client", "object", obj)

This line does not result in actual logging in my case, just results (confusingly) in a call to os.Exit(1).

Simple test case (replace clusterautoscaler with a suitable object that is not part of default scheme):

package clusterautoscaler

import (
	"testing"
	fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
	"k8s.io/apimachinery/pkg/runtime"
)

func TestAvailableAndUpdatedCheck2(t *testing.T) {
	tscheme := runtime.NewScheme()
	// With the following commented, we fail silently.
	//apis.AddToScheme(tscheme)
	ca := NewClusterAutoscaler()
	_ = fakeclient.NewFakeClientWithScheme(tscheme, ca)
}
@michaelgugino
Copy link
Author

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 8, 2019
@DirectXMan12
Copy link
Contributor

a) that should probably be a panic, not a log-then-exit. I suspect it was an incorrectly replaced pattern from our purge of fatalf (which doesn't existing in logr).

b) you should generally set up logging in TestMain, BeforeSuite, each test, or what have you (by calling "pkg/log".SetLogger).

@DirectXMan12
Copy link
Contributor

/good-first-issue

/priority backlog

@k8s-ci-robot
Copy link
Contributor

@DirectXMan12:
This request has been marked as suitable for new contributors.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-good-first-issue command.

In response to this:

/good-first-issue

/priority backlog

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 priority/backlog Higher priority than priority/awaiting-more-evidence. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Mar 11, 2019
@anthonyho007
Copy link
Contributor

@DirectXMan12 Can i work on this issue ?

@DirectXMan12
Copy link
Contributor

go ahead. Can't officially assign unless you're an org member, but consider it assigned :-)

/assign @anthonyho007

@k8s-ci-robot
Copy link
Contributor

@DirectXMan12: GitHub didn't allow me to assign the following users: anthonyho007.

Note that only kubernetes-sigs members and repo collaborators can be assigned and that issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

go ahead. Can't officially assign unless you're an org member, but consider it assigned :-)

/assign @anthonyho007

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.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 23, 2019
@DirectXMan12
Copy link
Contributor

close as per above PRs

DirectXMan12 pushed a commit that referenced this issue Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

5 participants