-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Switch to internalclientset #11916
Switch to internalclientset #11916
Conversation
[test] |
@@ -22,7 +22,9 @@ const ( | |||
func OkDeploymentConfig(version int64) *deployapi.DeploymentConfig { | |||
return &deployapi.DeploymentConfig{ | |||
ObjectMeta: kapi.ObjectMeta{ | |||
Name: "config", | |||
Name: "config", | |||
Namespace: kapi.NamespaceDefault, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this change? It will probably break tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fake.NewSimpleClientset
requires to have namespace set, it panicked without it. The unit tests are green already ;)
@@ -221,7 +225,7 @@ func (r *REST) returnApplicationPodName(target *kapi.ReplicationController) (str | |||
selector := labels.Set(target.Spec.Selector).AsSelector() | |||
sortBy := func(pods []*kapi.Pod) sort.Interface { return controller.ByLogging(pods) } | |||
|
|||
pod, _, err := kcmdutil.GetFirstPod(r.pn, target.Namespace, selector, r.timeout, sortBy) | |||
pod, _, err := kcmdutil.GetFirstPod(r.oldPn, target.Namespace, selector, r.timeout, sortBy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you open a follow-up upstream to switch this to use a clientset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or issue is just fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, so we just need the rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why this PR is a prereq 😜
@@ -305,7 +305,8 @@ func mockBuildConfig(baseImage, triggerImage, repoName, repoTag string) *buildap | |||
dockerfile := "FROM foo" | |||
return &buildapi.BuildConfig{ | |||
ObjectMeta: kapi.ObjectMeta{ | |||
Name: "testBuildCfg", | |||
Name: "testBuildCfg", | |||
Namespace: kapi.NamespaceDefault, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is something requiring we set this namespace now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the fake clientset is now namespace aware, without it you'll get nasty panic complaining that you're trying to use namespaced resource without namespace.
@@ -741,7 +741,7 @@ func TestGenerateBuildFromConfig(t *testing.T) { | |||
bc := &buildapi.BuildConfig{ | |||
ObjectMeta: kapi.ObjectMeta{ | |||
Name: "test-build-config", | |||
Namespace: "test-namespace", | |||
Namespace: kapi.NamespaceDefault, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
The new testing mock used by generated fake clients requires that namespaced resources come in with namespaces. It doesn't understand defaulting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and we don't consider that an upstream bug? ok.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also that still doesn't explain why this object which had a valid namespace, is being changed to use a different namespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I don't think this particular test actually cares what the namespace value is, but it seems odd to change it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Differences between tests caused errors, I've unified all to use kapi.NamespaceDefault
. Even if test doesn't care about namespace the fake clientset will complain, see my previous comment.
I have concerns/questions about all the default namespacing you're introducing in the tests, otherwise lgtm. |
@@ -144,15 +146,49 @@ func mockREST(version, desired int64, status api.DeploymentStatus) *REST { | |||
Phase: kapi.PodRunning, | |||
}, | |||
} | |||
fakePn.PrependReactor("get", "pods", func(action ktestclient.Action) (handled bool, ret runtime.Object, err error) { | |||
oldPn.PrependReactor("get", "pods", func(action ktestclient.Action) (handled bool, ret runtime.Object, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for this pretty big change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rolling and recreate invoke commands from k8s.io/kubernetes/pkg/kubectl
package, which is using clientset only in 1.5, which we'll get after the rebase. Example line:
kubectl.ScalerFor(kapi.Kind("ReplicationController"), oldClient)
for that reason we need old k8s client in only certain places, which will be removed after the rebase. See my discussion with Michalis in this PR.
c304cb2
to
ddd2cf5
Compare
Are there any changes here that aren't just simple refactoring? |
@soltysh needs rebase. Last failure flaked on #11775 and this:
|
Most is just simple refactoring, but there are a few places where bigger changes were required. |
ddd2cf5
to
93ce1d9
Compare
Rebased and fixed the test Andy pointed out. |
for _, o := range objs { | ||
if itemMeta, err := meta.Accessor(o); err == nil { | ||
// we can't set namespace for everything, some resources are non-namespaced | ||
if _, ok := o.(*projectapi.Project); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why special case this? We have a registry of root scope vs namespace scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all used to be handled by the RESTMapper. Why are we having to special case it now?
"on fedora:23", | ||
"-> repo-base:latest", | ||
"on istag/fedora:23", | ||
"-> istag/repo-base:latest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did this output change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually wondering why it wasn't like that before, looking at other test cases.
@@ -313,9 +312,9 @@ func TestProjectStatus(t *testing.T) { | |||
ErrFn: func(err error) bool { return err == nil }, | |||
Contains: []string{ | |||
"In project example on server https://example.com:8443\n", | |||
"svc/galera[default] (headless):3306", | |||
"svc/galera (headless):3306", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, situation is a bit more complicated. Fake clientset forces to always use namesapces, previously it was not required. I've added them and previously we've had parts of the petset created in default namespace and now it's all in one. Thus the change.
I asked because the mechanical transform need to be separate from the On Nov 18, 2016, at 5:31 PM, Maciej Szulik notifications@github.com wrote: @soltysh commented on this pull request.In pkg/cmd/cli/describe/projectstatus_test.go
Here, situation is a bit more complicated. Fake clientset forces to always — |
OK, I'll update that PR into what needs review and the rest. |
Looks like one another error:
but I think I'll leave that for tomorrow to handle. |
93ce1d9
to
7daf1c6
Compare
Fixed the test and re-organized into 2 commits boring and interesting, per Clayton request. @smarterclayton, @liggitt @ncdc ptal |
7daf1c6
to
c7ad80c
Compare
b0cbac2
to
199f3c4
Compare
Rebased and fixed the |
@soltysh ReadObjectsFromPath change LGTM, thanks |
Thx, @smarterclayton anything more or we're good to merge this as is? |
199f3c4
to
bacdba6
Compare
Rebased. |
Flake #10988 [test] |
Flake #10951 [test] |
Flake #10988 [test] |
Flake #10663 [test] |
bacdba6
to
7cf64f4
Compare
Rebased. |
Flake #11016 [test] |
Evaluated for origin test up to 97e6f1d |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11687/) (Base Commit: 571845b) |
@smarterclayton anything more or we're good to go as is? |
Lgtm [merge] |
Flake #8502. [merge] |
Flake #10951 [merge] |
Evaluated for origin merge up to 97e6f1d |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11705/) (Base Commit: e115e25) (Image: devenv-rhel7_5418) |
This is switching us to use internalclientset instead of plain client.
@ncdc we need this land before the rebase
@bparees for the build parts
@Kargakis for the deployment parts