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

Switch to internalclientset #11916

Merged
merged 2 commits into from Nov 25, 2016

Conversation

soltysh
Copy link
Member

@soltysh soltysh commented Nov 15, 2016

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

@soltysh soltysh mentioned this pull request Nov 15, 2016
2 tasks
@soltysh
Copy link
Member Author

soltysh commented Nov 15, 2016

[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,
Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

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

Copy link
Member Author

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 😜

@ncdc
Copy link
Contributor

ncdc commented Nov 15, 2016

cc @deads2k @liggitt @sttts

@@ -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,
Copy link
Contributor

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?

Copy link
Member Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

Copy link
Contributor

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.

Copy link
Contributor

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.....

Copy link
Contributor

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?

Copy link
Contributor

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)

Copy link
Member Author

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.

@bparees
Copy link
Contributor

bparees commented Nov 15, 2016

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) {
Copy link
Contributor

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?

Copy link
Member Author

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.

@soltysh soltysh force-pushed the remove_unversionedclient branch 3 times, most recently from c304cb2 to ddd2cf5 Compare November 18, 2016 18:23
@soltysh soltysh changed the title [WIP] Switch to internalclientset Switch to internalclientset Nov 18, 2016
@soltysh
Copy link
Member Author

soltysh commented Nov 18, 2016

@ncdc I think this is ready, eventual leftovers we'll handle afterwards/during the rebase itself.

I need lots of eyes on your area:
@knobunc for networking stuff
@bparees for build stuff
@deads2k @liggitt for auth stuff
@smarterclayton overall

@smarterclayton
Copy link
Contributor

Are there any changes here that aren't just simple refactoring?

@ncdc
Copy link
Contributor

ncdc commented Nov 18, 2016

@soltysh needs rebase. Last failure flaked on #11775 and this:

--- FAIL: TestPullThroughInsecure (4.14s)
    dockerregistry_pullthrough_test.go:175: External registry got GET /v2/
    dockerregistry_pullthrough_test.go:175: External registry got GET /v2/test/testrepo/manifests/testtag
    dockerregistry_pullthrough_test.go:175: External registry got HEAD /v2/test/testrepo/manifests/testtag
    dockerregistry_pullthrough_test.go:175: External registry got GET /v2/test/testrepo/manifests/sha256:958608f8ecc1dc62c93b6c610f3a834dae4220c9642e6e8b4e0f2b3ad7cbd238
    dockerregistry_pullthrough_test.go:246: unexpected status 0: unversioned.Status{TypeMeta:unversioned.TypeMeta{Kind:"", APIVersion:""}, ListMeta:unversioned.ListMeta{SelfLink:"", ResourceVersion:""}, Status:"Failure", Message:"Internal error occurred: invalid character '\\n' in string literal", Reason:"InternalError", Details:(*unversioned.StatusDetails)(0xc825c3b360), Code:500}

@soltysh
Copy link
Member Author

soltysh commented Nov 18, 2016

Are there any changes here that aren't just simple refactoring?

Most is just simple refactoring, but there are a few places where bigger changes were required.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2016
@soltysh
Copy link
Member Author

soltysh commented Nov 18, 2016

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 {
Copy link
Contributor

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

Copy link
Contributor

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",
Copy link
Contributor

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?

Copy link
Member Author

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",
Copy link
Contributor

Choose a reason for hiding this comment

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

same question

Copy link
Member Author

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.

@smarterclayton
Copy link
Contributor

I asked because the mechanical transform need to be separate from the
important changes somehow so we can focus on what needs reviewing.

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
#11916:

@@ -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",
    

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.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#11916, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p7btI0LTWa71bpzWB42Fk9a04eJCks5q_ic0gaJpZM4Kyl-W
.

@soltysh
Copy link
Member Author

soltysh commented Nov 18, 2016

I asked because the mechanical transform need to be separate from the important changes somehow so we can focus on what needs reviewing.

OK, I'll update that PR into what needs review and the rest.

@soltysh
Copy link
Member Author

soltysh commented Nov 18, 2016

Looks like one another error:

--- FAIL: TestDeployScale (4.23s)
    deploy_scale_test.go:48: Couldn't create DeploymentConfig: the namespace of the provided object does not match the namespace sent on the request &api.DeploymentConfig{TypeMeta:unversioned.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:api.ObjectMeta{Name:"config", GenerateName:"", Namespace:"default", SelfLink:"/oapi/v1/namespaces/default/deploymentconfig/config", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:unversioned.Time{Time:time.Time{sec:0, nsec:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*unversioned.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string(nil), OwnerReferences:[]api.OwnerReference(nil), Finalizers:[]string(nil), ClusterName:""}, Spec:api.DeploymentConfigSpec{Strategy:api.DeploymentStrategy{Type:"Recreate", CustomParams:(*api.CustomDeploymentStrategyParams)(nil), RecreateParams:(*api.RecreateDeploymentStrategyParams)(0xc82ffda3c0), RollingParams:(*api.RollingDeploymentStrategyParams)(nil), Resources:api.ResourceRequirements{Limits:api.ResourceList{"cpu":resource.Quantity{i:resource.int64Amount{value:10, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"10", Format:"DecimalSI"}, "memory":resource.Quantity{i:resource.int64Amount{value:10, scale:9}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"10G", Format:"DecimalSI"}}, Requests:api.ResourceList(nil)}, Labels:map[string]string(nil), Annotations:map[string]string(nil)}, MinReadySeconds:0, Triggers:[]api.DeploymentTriggerPolicy{}, Replicas:1, RevisionHistoryLimit:(*int32)(nil), Test:false, Paused:false, Selector:map[string]string{"a":"b"}, Template:(*api.PodTemplateSpec)(0xc82d4cfa40)}, Status:api.DeploymentConfigStatus{LatestVersion:0, ObservedGeneration:0, Replicas:0, UpdatedReplicas:0, AvailableReplicas:0, UnavailableReplicas:0, Details:(*api.DeploymentDetails)(nil), Conditions:[]api.DeploymentCondition(nil)}}
    etcd.go:99: dumping etcd to "/tmp/openshift/test-integration//etcd-dump-runtime.call32.json"
FAIL

but I think I'll leave that for tomorrow to handle.

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 19, 2016
@soltysh
Copy link
Member Author

soltysh commented Nov 19, 2016

Fixed the test and re-organized into 2 commits boring and interesting, per Clayton request.

@smarterclayton, @liggitt @ncdc ptal

@soltysh soltysh force-pushed the remove_unversionedclient branch 2 times, most recently from b0cbac2 to 199f3c4 Compare November 22, 2016 20:54
@soltysh
Copy link
Member Author

soltysh commented Nov 22, 2016

Rebased and fixed the testclient.go @liggitt ptal

@liggitt
Copy link
Contributor

liggitt commented Nov 22, 2016

@soltysh ReadObjectsFromPath change LGTM, thanks

@soltysh
Copy link
Member Author

soltysh commented Nov 22, 2016

Thx, @smarterclayton anything more or we're good to merge this as is?

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 23, 2016
@soltysh soltysh removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 23, 2016
@soltysh
Copy link
Member Author

soltysh commented Nov 23, 2016

Rebased.

@soltysh
Copy link
Member Author

soltysh commented Nov 23, 2016

Flake #10988

[test]

@soltysh
Copy link
Member Author

soltysh commented Nov 23, 2016

Flake #10951

[test]

@soltysh
Copy link
Member Author

soltysh commented Nov 23, 2016

Flake #10988

[test]

@soltysh
Copy link
Member Author

soltysh commented Nov 23, 2016

Flake #10663

[test]

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 24, 2016
@soltysh
Copy link
Member Author

soltysh commented Nov 24, 2016

Rebased.

@soltysh soltysh removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 24, 2016
@soltysh
Copy link
Member Author

soltysh commented Nov 24, 2016

Flake #11016

[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 97e6f1d

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11687/) (Base Commit: 571845b)

@soltysh
Copy link
Member Author

soltysh commented Nov 24, 2016

@smarterclayton anything more or we're good to go as is?

@smarterclayton
Copy link
Contributor

Lgtm [merge]

@soltysh
Copy link
Member Author

soltysh commented Nov 25, 2016

Flake #8502.

[merge]

@soltysh
Copy link
Member Author

soltysh commented Nov 25, 2016

Flake #10951

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 97e6f1d

@openshift-bot
Copy link
Contributor

openshift-bot commented Nov 25, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11705/) (Base Commit: e115e25) (Image: devenv-rhel7_5418)

@openshift-bot openshift-bot merged commit 6f7e2fd into openshift:master Nov 25, 2016
@soltysh soltysh deleted the remove_unversionedclient branch November 28, 2016 09:02
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.

None yet

9 participants