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

9138 hostname caching policy #793

Merged
merged 44 commits into from
Dec 10, 2018

Conversation

jlitzingerdev
Copy link
Contributor

@hawkowl
Copy link
Member

hawkowl commented May 25, 2017

@jlitzingerdev Python 3 seems to be failing :(

@jlitzingerdev
Copy link
Contributor Author

Uy, Indeed it is, sorry about. My process was broken, I didn't test python 3 with TLS dependencies installed...process fixed. I'm assuming I should close, rebase, and submit a new PR, correct? Do I need to version (thinking of patch versions for kernel submissions) the PR or is a new commit sufficient?

@hawkowl
Copy link
Member

hawkowl commented May 25, 2017

@jlitzingerdev Nah, just go ahead and push another commit to the branch/PR, and it'll update/rerun tests.

@codecov
Copy link

codecov bot commented May 25, 2017

Codecov Report

Merging #793 into trunk will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##            trunk     #793      +/-   ##
==========================================
+ Coverage   91.92%   91.92%   +<.01%     
==========================================
  Files         845      845              
  Lines      151151   151224      +73     
  Branches    13187    13192       +5     
==========================================
+ Hits       138940   139015      +75     
+ Misses      10113    10111       -2     
  Partials     2098     2098

@jlitzingerdev
Copy link
Contributor Author

@hawkowl Pushed, though it ended up being three commits as there were three distinct issues I found with the previous submission. I did not rebase on trunk, but will be happy to do so if needed.

@jlitzingerdev
Copy link
Contributor Author

@hawkowl I must admin I'm a bit confused on the travis failure. Most of the jobs passed, and the one that failed "ERROR: manifest-checker: commands failed", is this related to my branch being out of date with master?

@rodrigc
Copy link
Contributor

rodrigc commented May 25, 2017

You should merge trunk into your branch to update it,
and also make sure that you have a news fragment, as specified in step 6 here:

https://twistedmatrix.com/trac/wiki/TwistedDevelopment#SubmittingaPatch

Your lack of a news fragment is causing the Travis failure.

@jlitzingerdev
Copy link
Contributor Author

@rodrigc I did indeed read the newsifle requirement, and I added a one, see https://github.com/twisted/twisted/pull/793/files#diff-3d267930e0599d705b7ed77fd7572f25, though I added it in the newsfragments directory of the twisted.web package, was that incorrect?

@jlitzingerdev
Copy link
Contributor Author

@rodrigc Also, copy that on the merge of trunk, but a question, do you really want a merge, or should I rebase my changes on current trunk (so this PR is always a fast forward)? My only concern with a merge is that, assuming I have more feedback to incorporate, new changes for this changeset will be spread across a merge commit (somewhat pointlessly). Ultimately I'll do whatever is preferred, just want the history to look how want it.

@rodrigc
Copy link
Contributor

rodrigc commented May 25, 2017

Merge is fine.

@jlitzingerdev
Copy link
Contributor Author

@rodrigc thanks, one last question pre-push. Did you see my comment about the newsfile? I did add one, and the build did pick it up. It appears the build is complaining about
missing from sdist:
src/twisted/names/topfiles

Which I'm assuming will be resolved with the merge. Was there an issue with my newsfragment as submitted?

@rodrigc
Copy link
Contributor

rodrigc commented May 25, 2017

Yes, I saw the newsfragment you submitted. Please do the merge.

jlitzingerdev added a commit to jlitzingerdev/twisted that referenced this pull request May 25, 2017
…ing-policy

Merge of trunk as requested during review of the pull request for ticket
9138.

See:
    twisted#793

For the full discussion.
@rodrigc
Copy link
Contributor

rodrigc commented May 25, 2017

Your branch has a file src/twisted/names/topfiles/8340.bug fix but that file does not exist on trunk. Maybe there was a conflict during a merge and you didn't resolve it correctly?

@rodrigc
Copy link
Contributor

rodrigc commented May 25, 2017

You need to update your tree at https:://github.com/jlitzingerdev/twisted so that it's trunk has all the commits from https://github.com/twisted/twisted . You are missing commits done later this week which are needed.

Then you need to do another merge from trunk to this branch.

@jlitzingerdev
Copy link
Contributor Author

jlitzingerdev commented May 25, 2017

@rodrigc That makes more sense. I haven't kept my fork's trunk up to date (it is locally, but I didn't push), I was (wrongly) assuming it didn't matter as the PR was against twisted's. Sorry, one moment.

@jlitzingerdev
Copy link
Contributor Author

jlitzingerdev commented May 25, 2017

@rodrigc Done, fork trunk updated, sorry about that. Re. your other comment, that 8430 does appear to exist in twisted's trunk, but it did not exist in mine at the time.

Can I assume that the tests, when they need trunk use the fork's trunk? If so, would that be helpful to add to the documentation (unless I just missed it)? If so I can add it.

Also, I did merge my fork's trunk into this branch, but it was already up to date a I merged trunk from the upstream earlier (git merge upstream/trunk).

@rodrigc
Copy link
Contributor

rodrigc commented May 25, 2017

@markrwilliams you introduced src/twisted/names/topfiles/8340.bugfix, which is now in an incorrect directory. This is now causing other pull requests to fail. Can you fix this?

@markrwilliams
Copy link
Member

markrwilliams commented May 25, 2017

@rodrigc I can fix it in this case, but @hawkowl wrote a very handy script: admin/fix-for-towncrier.py. It recursively renames topfiles to newsfragements. Contributors should run this from the top level of the git repository and commit the result.

@markrwilliams
Copy link
Member

I've updated the wiki

Copy link
Contributor

@rodrigc rodrigc left a comment

Choose a reason for hiding this comment

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

@markrwilliams Can you cherry pick 98d3e64 to trunk? The travis trunk build is red without this fix: https://travis-ci.org/twisted/twisted/branches

@jlitzingerdev
Copy link
Contributor Author

@rodrigc @hawkowl @markrwilliams It looks like the latest merge (fedec1a) introduced the same topfile fix. Do you want me to merge trunk again, or create a clean v2 branch/PR with the commits pertinent to ticket 9138 (perhaps squashed back down to two commits)?

@jlitzingerdev
Copy link
Contributor Author

I rebased this branch against trunk today. I'd merged trunk in on Sunday, but it was becoming fairly messy. I assumed rebasing this was desirable per item 15 in https://twistedmatrix.com/trac/wiki/TwistedDevelopment#SubmittingaPatch. That unfortunately required a force-push, which I typically avoid, apologies for any issues that causes. Note that I also updated my fork's trunk just after this push, which might trigger a CI failure (it seemed to before). Unless I hear otherwise I'll plan to continue rebasing this against trunk.

The custom trust root is useful when testing custom HTTPS policies, move
it outside its current test function if the SSL dependencies are
successfully imported.
The HostnameCachingHTTPSPolicy is an IPolicyForHTTPS that caches
connection creators for reuse in subsequent requests.  The cache size is
determined by the cacheSize parameter and defaults to 20.  When a cache
miss occurs, an entry for the new host is created and added to the
cache.  The cache is then purged and the oldest entry removed.
The entry.creator was cruft from a refactoring that never should have
remained in the branch, remove.
The use of finally in the previous code hid two bugs:

1. If an exception was thrown by optionsForClientTLS, entry would not
exist and an UnboundLocalError would be thrown in the finally clause,
masking the original exception.

2.  If 1 occured, _nextCacheId would still be incremented, leaving a
hole and resulting in no cache entry removed during a later purge (due
to the fact that no entry existed with that value).
Caught during test-build of pull request.  Unicode objects don't have a
decode method in Python3.  Modify the code such that, when an argument
is passed to creatorForNetloc it is always an ascii encoded byte string,
but when the _cache is manually inspected a unicode (str) object is
used.
@glyph
Copy link
Member

glyph commented Oct 15, 2018

This lint failure looks silly; don't have time to do a full review right now, but a committer should probably just come along and pacify the builder and land this.

@jlitzingerdev
Copy link
Contributor Author

@glyph I assumed from the age that there wasn't much interest in this enhancement. I haven't done much in the way of maintenance (as evidenced in the logs above) in quite some time. I'll clean up the errors and get it in shape for a proper review.

Note that I did submit a PR for the benchmarks (what's the point in an improvement if there is no measurement) here:
twisted-infra/twisted-benchmarks#5
with the intent being to update the benchmark using the code from this PR after it was merged.

@wiml
Copy link
Contributor

wiml commented Dec 2, 2018

As an aside, on Python 3, this could also be done using the @functools.lru_cache decorator.

@wiml wiml force-pushed the 9138-hostname-caching-policy branch from e90b7bd to 79d8b18 Compare December 3, 2018 02:14
@wiml wiml force-pushed the 9138-hostname-caching-policy branch from 79d8b18 to 0ecb515 Compare December 6, 2018 22:11
@wiml wiml merged commit eb2aaeb into twisted:trunk Dec 10, 2018
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

8 participants