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

Deprecate all tls-sni related objects in acme module #6859

Merged
merged 23 commits into from
Mar 27, 2019

Conversation

adferrand
Copy link
Collaborator

@adferrand adferrand commented Mar 14, 2019

This PR is a part of the tls-sni-01 removal plan described in #6849.

As acme is a library, we need to put some efforts to make a decent deprecation path before totally removing tls-sni in it. While initialization of acme.challenges.TLSSNI01 was already creating deprecation warning, not all cases were covered.

For instance, and innocent call like this ...

if not isinstance(challenge, acme.challenges.TLSSNI01):
    print('I am not using this TLS-SNI deprecated stuff, what could possibly go wrong?')

... would break if we suddenly remove all objects related to this challenge.

So, I use the Deprecator Warning Machine, Let's Pacify this Technical Debt (Guido ®), to make acme.challenges and acme.standalone patch themselves, and display a deprecation warning on stderr for any access to the tls-sni challenge objects.

No dev should be able to avoid the deprecation warning. I set the deprecation warning in the idea to remove the code on 0.34.0, but the exact deprecation window is open to discussion of course.

…cation warning when tls-sni related objects are accessed.
@adferrand adferrand force-pushed the wide-deprecation-tls-sni-in-acme branch from 75e3dd0 to 610f4f4 Compare March 17, 2019 16:36
@adferrand
Copy link
Collaborator Author

adferrand commented Mar 17, 2019

Fixing TestSimpleTLSSNI01Server on Linux also corrected it on Windows. So I take it.

@adferrand adferrand force-pushed the wide-deprecation-tls-sni-in-acme branch from a659bc1 to e76f68e Compare March 17, 2019 16:59
@adferrand adferrand force-pushed the wide-deprecation-tls-sni-in-acme branch from d1fbf2f to 2fb736f Compare March 17, 2019 18:42
@bmw
Copy link
Member

bmw commented Mar 20, 2019

So, I use the Deprecator Warning Machine, Let's Pacify this Technical Debt (Guido ®)

Did the approach here come from Guido? If so, have a link?

@adferrand
Copy link
Collaborator Author

@adferrand
Copy link
Collaborator Author

But it is not specific to monkey patch a module. I took the solution from you in fact (of a link you gave), from discussions about josepy. I will find the link tomorrow.

About the class approach, it is because __getattr__ is not always called for a missing property, depending of the Python version. Here again, a link tomorrow.

@bmw
Copy link
Member

bmw commented Mar 20, 2019

For what it's worth, cryptography takes a similar approach which is a big +1 to me about its sanity. Here's a deprecated attribute which uses the code at https://github.com/pyca/cryptography/blob/ac1d13f43dea5ebee0506dc229cd431660916c73/src/cryptography/utils.py#L154.

@adferrand
Copy link
Collaborator Author

It was exactly the example I saw, during the discussion about the retro-portage of new josepy module to jose module. Finally, a simple from ... import ... as did the trick, but this example was a very relevant way to handle non trivial monkey patch for existing modules.

@adferrand
Copy link
Collaborator Author

Also from this example it shows that __dict__ must also be exported to ensure a transparent behavior. I will add it.

@adferrand
Copy link
Collaborator Author

adferrand commented Mar 20, 2019

Here is the link about the problem of get attribute protocol using __getattr__ on modules, and the workaround that involve to use a class delegating to the module instead.

https://stackoverflow.com/questions/2447353/getattr-on-a-module

acme/acme/__init__.py Show resolved Hide resolved
acme/acme/__init__.py Outdated Show resolved Hide resolved
acme/acme/__init__.py Outdated Show resolved Hide resolved
'forever': False,
},
)
self.port = 40000
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should hardcode a port like this.

As a more minor point, why are these changes in this PR?

Copy link
Collaborator Author

@adferrand adferrand Mar 25, 2019

Choose a reason for hiding this comment

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

In fact this code was subject to deadlock, and it was already the case on Windows. It started also to be it in this PR on Linux. So I refactor to not have this kind of deadlock.

For the port, I would argue that this kind of hardcoded port is in several places in certbot tests: I am not talking of parameters in mocked objects, but in integration tests with real bindings on the system that execute them.

Copy link
Member

Choose a reason for hiding this comment

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

In fact this code was subject to deadlock, and it was already the case on Windows. It started also to be it in this PR on Linux.

I don't see how the other changes in this PR cause a deadlock on Linux here.

For the port, I would argue that this kind of hardcoded port is in several places in certbot tests: I am not talking of parameters in mocked objects, but in integration tests with real bindings on the system that execute them.

I think the major difference is our unit tests are shipped in the Python package and usually run by OS packagers to see if the code is working correctly on their system. We don't have the same control on these environments as we do as on the environment for our integration tests so I think we should try and make our unit tests more robust and avoid doing things like hardcoding ports.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do not see neither why it suddenly deadlocked. But since it already happened, in similar code, I preferred to rewrite.

If I solve the static port attribution, to get randomly an available one, like in the previous implementation, will you be OK with the modifications I did here?

Copy link
Member

Choose a reason for hiding this comment

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

If I solve the static port attribution, to get randomly an available one, like in the previous implementation, will you be OK with the modifications I did here?

I'll need to review the test changes more closely when it's finished, but I should be!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. I pick a random free port.

@bmw
Copy link
Member

bmw commented Mar 25, 2019

The changelog needs to be updated in this PR as well.

@adferrand adferrand force-pushed the wide-deprecation-tls-sni-in-acme branch from 9d9cfc3 to 0737d37 Compare March 26, 2019 00:14
acme/acme/__init__.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
'forever': False,
},
)
self.port = 40000
Copy link
Member

Choose a reason for hiding this comment

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

In fact this code was subject to deadlock, and it was already the case on Windows. It started also to be it in this PR on Linux.

I don't see how the other changes in this PR cause a deadlock on Linux here.

For the port, I would argue that this kind of hardcoded port is in several places in certbot tests: I am not talking of parameters in mocked objects, but in integration tests with real bindings on the system that execute them.

I think the major difference is our unit tests are shipped in the Python package and usually run by OS packagers to see if the code is working correctly on their system. We don't have the same control on these environments as we do as on the environment for our integration tests so I think we should try and make our unit tests more robust and avoid doing things like hardcoding ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants