[openstack-dev] [all] Deprecating exceptions

Doug Hellmann doug at doughellmann.com
Mon Sep 22 19:15:24 UTC 2014


On Sep 22, 2014, at 11:07 AM, Radomir Dopieralski <openstack at sheep.art.pl> wrote:

> Horizon's tests were recently broken by a change in the Ceilometer
> client that removed a deprecated exception. The exception was deprecated
> for a while already, but as it often is, nobody did the
> work of removing all references to it from Horizon before it was too

This is a good example of the sort of communication and coordination issue that we’ve had with Oslo as the number of consuming projects scaled up significantly. Horizon may be able to apply the same solution we’ve used.
 
Since starting the Liaison program, we’ve had mixed success with rolling out changes to the projects, but we have definitely improved our communication with the other teams over the course of this cycle. If Horizon adopted a similar approach, asking one member of each project that has integrated with horizon to designate a person to attend the *horizon* meetings and communicate changes from their project to the horizon team, these sorts of things could be flagged earlier.

> late. Sure, in theory we should all be reading the release notes of
> all versions of all dependencies and acting upon things like this.
> In practice, if there is no warning generated in the unit tests,
> nobody is going to do anything about it.

Take my word, you cannot keep up with this on your own, and you should not feel that you’re failing because of that; the approach just does not scale. Consider the difference between an application that polls for status and one that is event-driven. You’re trying to poll, but you need to establish an event stream for input.

> 
> So I sat down and started thinking about how to best generate a warning
> when someone is trying to catch a deprecated exception. I came up with
> this code:
> 
> http://paste.openstack.org/show/114170/
> 
> It's not pretty -- it is based on the fact that the `except` statement
> has to do a subclass check on the exceptions it is catching. It requires
> a metaclass and a class decorator to work, and it uses a global
> variable. I'm sure it would be possible to do it in a little bit cleaner
> way. But at least it gives us the warning (sure, only if an exception is
> actually being thrown, but that's test coverage problem).
> 
> I propose to do exception deprecating in this way in the future.

That’s a clever bit of code. We do already have a deprecation mechanism in oslo [1], but what you have would be a nice addition to deal with the special case that exceptions represent. Please propose a patch to the incubator!

Doug

[1] http://git.openstack.org/cgit/openstack/oslo-incubator/tree/openstack/common/versionutils.py#n33

> -- 
> Radomir Dopieralski
> 
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev




More information about the OpenStack-dev mailing list