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

make all alias correctly #7661

Merged
merged 2 commits into from
Mar 5, 2016
Merged

make all alias correctly #7661

merged 2 commits into from
Mar 5, 2016

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Feb 26, 2016

This updates the all alias to actually mean what we want with respect to available resources. There is refactoring needed upstream for purity, but we can delay that . This doesn't change behavior of clients against old servers, so our client looks just as ugly if you're hitting an old atomic server. This doesn't use a cache, but you can see where to plug it.

@smarterclayton @fabianofranz @liggitt

Alternative to #7634

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 26, 2016 via email

@deads2k
Copy link
Contributor Author

deads2k commented Feb 26, 2016

Add a simple test

Is this preferred in principle? If so, I'll bring it home with unit tests and a list of issues for refactoring.

@smarterclayton
Copy link
Contributor

Yes I'm fine with this change

On Fri, Feb 26, 2016 at 4:00 PM, David Eads notifications@github.com
wrote:

Add a simple test

Is this preferred in principle? If so, I'll bring it home with unit tests
and a list of issues for refactoring.


Reply to this email directly or view it on GitHub
#7661 (comment).

@deads2k deads2k changed the title [POC] make all alias correctly make all alias correctly Feb 29, 2016
@deads2k
Copy link
Contributor Author

deads2k commented Feb 29, 2016

test and time based cache added. @liggitt ptal.

return mapper, api.Scheme

// at this point we've negotiated and can get the client
oclient, err := clients.ClientForVersion(nil)
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 the other methods aren't doing the right thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks like the other methods aren't doing the right thing.

I know that this version is pre-negotiated and for a discovery lookup the version doesn't matter so I went with congruence to make the association obvious.

@deads2k
Copy link
Contributor Author

deads2k commented Mar 1, 2016

Comments addressed. I didn't see a good library method for "replace all illegal characters in a filename" so I went with a very restrictive replacement policy.

@@ -450,6 +468,19 @@ func NewFactory(clientConfig kclientcmd.ClientConfig) *Factory {
return w
}

// overlyCautiousIllegalFileCharacters matches characters that *might* not be supported. Windows is really restrictive, so this is really restrictive
var overlyCautiousIllegalFileCharacters = regexp.MustCompile(`[^(\w/\.)]`)
Copy link
Contributor

Choose a reason for hiding this comment

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

not as cautious as you might hope...
computeDiscoverCacheDir(".","foo/bar") == "foo/bar"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not as cautious as you might hope...
computeDiscoverCacheDir(".","foo/bar") == "foo/bar"

and? Slash gets used as a path demiliter and you get a sane directory structure right?

Copy link
Contributor

Choose a reason for hiding this comment

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

assumed you wanted it to "do a simple collapse of non-AZ09 characters"

@fabianofranz
Copy link
Member

Not directly related to this PR, but could the caching here be used in other places where we display lists of the available server resources, like oc get without arguments?

@deads2k
Copy link
Contributor Author

deads2k commented Mar 1, 2016

Not directly related to this PR, but could the caching here be used in other places where we display lists of the available server resources, like oc get without arguments?

The information is necessary, but not sufficient. You'd need to harvest all available resources, then find a way to associate those resources potential RESTMapper shortcuts. Currently there's not a structured way to do this. After that, you'd need to inspect the result to see which ones conflict and require qualification. You'd then be left deciding when winning based on priority requires qualification or not.

All that work is probably logically required, but I don't think all the APIs are present right now.

}

func (d *CachedDiscoveryClient) getCachedFile(filename string) ([]byte, error) {
// don't fail on errors, we either don't have a file or won't be able to run the cached check. Either way we can fallback.
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment doesn't make sense here. Maybe add it as a godoc for this function if you want it around. You already include it everywhere getCachedFile is called

@deads2k
Copy link
Contributor Author

deads2k commented Mar 3, 2016

I'll update the comment and the logging request from @Kargakis . Any additional comments?

@deads2k
Copy link
Contributor Author

deads2k commented Mar 4, 2016

Comments addressed.

return nil, err
}

return cachedBytes, nil
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to be able to debug when the client is actually using a cached version of the resources list, or from rest (and then caching it). I'd suggest a couple glog (level 6 probably, like in configs) around the get|writeCachedFile methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to be able to debug when the client is actually using a cached version of the resources list, or from rest (and then caching it). I'd suggest a couple glog (level 6 probably, like in configs) around the get|writeCachedFile methods.

Done. The write time can be checked in the filesystem and doesn't really affect anything until its read again.

@fabianofranz
Copy link
Member

Minor comment, but LGTM. Good job on moving shortcuts and aliases out of the factory file.

@deads2k
Copy link
Contributor Author

deads2k commented Mar 4, 2016

[merge]

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/1845/) (Image: devenv-rhel7_3615)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 39ea086

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 39ea086

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/1845/)

openshift-bot pushed a commit that referenced this pull request Mar 5, 2016
@openshift-bot openshift-bot merged commit 264c51e into openshift:master Mar 5, 2016
@deads2k deads2k deleted the fix-all branch September 6, 2016 17:09
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.

6 participants