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

move cached_discovery to client-go/discovery #63550

Merged

Conversation

juanvallejo
Copy link
Contributor

Release note:

NONE

Moves the cmd/util CachedDiscoveryClient to client-go

cc @soltysh @deads2k

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 8, 2018
@k8s-ci-robot k8s-ci-robot requested review from sttts and vishh May 8, 2018 17:52
@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch 2 times, most recently from a314732 to ef7b7bf Compare May 8, 2018 18:12
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 8, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from ef7b7bf to 28a8021 Compare May 8, 2018 18:15
@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from 28a8021 to e036f67 Compare May 8, 2018 18:32
@@ -194,3 +200,76 @@ func TestKindFor(t *testing.T) {
}
}
}

type fakeDiscoveryClient struct {
groupCalls int
Copy link
Contributor

Choose a reason for hiding this comment

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

slim down to what is actually needed.

@juanvallejo someone was working on a real fake discovery client. We need to find that pull again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k

someone was working on a real fake discovery client. We need to find that pull again.

was it #62069 ?

@@ -30,15 +30,14 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/version"
"k8s.io/client-go/discovery"
restclient "k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/kubectl/scheme"
Copy link
Contributor

Choose a reason for hiding this comment

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

You may not have this dependency in client-go. nothing from kube/kube

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to k8s.io/client-go/kubernetes/scheme

Copy link
Contributor

Choose a reason for hiding this comment

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

witched to k8s.io/client-go/kubernetes/scheme

What is it used for? I expected you to create your own scheme locally like our other clients do.

@deads2k
Copy link
Contributor

deads2k commented May 8, 2018

I'm 95% sure you need the associated transport and that your external constructor needs to wrap the entire thing.

@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from e036f67 to bba674c Compare May 8, 2018 20:15
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 8, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from bba674c to da5ca88 Compare May 8, 2018 20:21
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 8, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from da5ca88 to ec57ab0 Compare May 8, 2018 20:24
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 8, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from ec57ab0 to e4a6d04 Compare May 8, 2018 20:26
@deads2k
Copy link
Contributor

deads2k commented May 8, 2018

I still don't see the transport

@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from e4a6d04 to 237d7f1 Compare May 8, 2018 20:49
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 8, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from 90131dd to caa31e0 Compare May 8, 2018 21:19
@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch 3 times, most recently from 319f5d8 to e3a82b4 Compare May 11, 2018 22:00
}

discoveryCacheDir := computeDiscoverCacheDir(filepath.Join(homedir.HomeDir(), ".kube", "cache", "discovery"), config.Host)
return discovery.NewCachedDiscoveryClientForConfig(config, discoveryCacheDir, httpCacheDir, time.Duration(10*time.Minute))
Copy link
Contributor

Choose a reason for hiding this comment

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

You eventually went with double cache options? Any particular reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@soltysh

You eventually went with double cache options? Any particular reason?

Per our conversation, I thought about this a bit further and decided that it might be best to add any changes in behavior in a separate PR explicitly for doing so.

Per @deads2k 's comments below, will add a godoc explaining the current behavior

@@ -1380,3 +1418,76 @@ func TestMultipleTypesRequested(t *testing.T) {
}
}
}

type fakeDiscoveryClient struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks like it should be deleted.

// NewCachedDiscoveryClientForConfig creates a new DiscoveryClient for the given config, and wraps
// the created client in a CachedDiscoveryClient. The provided configuration is upddated with a
// custom transport that understands cache responses.
func NewCachedDiscoveryClientForConfig(config *restclient.Config, discoveryCacheDir, httpCacheDir string, ttl time.Duration) (*CachedDiscoveryClient, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Document why we have two cache dirs, even if it is just historical with a TODO to figure out how to stop having two.

Copy link
Contributor

Choose a reason for hiding this comment

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

and doc behavior on empty

@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch 4 times, most recently from 3f86e26 to d6c4009 Compare May 14, 2018 15:01
@juanvallejo
Copy link
Contributor Author

@deads2k thanks, comments addressed

@deads2k
Copy link
Contributor

deads2k commented May 14, 2018

/retest

@deads2k
Copy link
Contributor

deads2k commented May 14, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 14, 2018
@deads2k deads2k added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2018
@deads2k
Copy link
Contributor

deads2k commented May 14, 2018

metrics change is a generated file based on client needs.

@juanvallejo juanvallejo force-pushed the jvallejo/move-cached-discovery branch from d6c4009 to 57f308a Compare May 15, 2018 14:38
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 15, 2018
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 15, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: deads2k, juanvallejo, soltysh

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

@juanvallejo
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit f2ea83b into kubernetes:master May 15, 2018
@juanvallejo juanvallejo deleted the jvallejo/move-cached-discovery branch May 15, 2018 18:08
k8s-github-robot pushed a commit that referenced this pull request May 17, 2018
…-genericclioptions

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

move config flags to pkg/kubectl/genericclioptions

**Release note**:
```release-note
NONE
```

Moves ConfigFlags to `pkg/kubectl/genericclioptions`
~~Depends on #63550

cc @soltysh @deads2k
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. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants