Package: openstack-requirements
========================Team and repository tags========================.. image:: https://governance.openstack.org/tc/badges/requirements.svg:target: https://governance.openstack.org/tc/reference/tags/index.html.. Change things from this point on============================================Global Requirements for OpenStack Projects============================================Why Global Requirements?========================During the Havana release cycle we kept running into coherency issueswith trying to install all the OpenStack components into a singleenvironment. The issue is that syncing of ``requirements.txt`` betweenprojects was an eventually consistent problem. Some projects wouldupdate quickly, others would not. We'd never have the same versionsspecified as requirements between packages.Because of the way that python package installation with pip works,this means that if you get lucky you'll end up with a workingsystem. If you don't you can easily break all of OpenStack on arequirements update.An example of how bad this had gotten is that python-keystoneclientwould typically be installed / uninstalled 6 times during the courseof a DevStack gate run during Havana. If the last version of pythonkeystoneclient happened to be incompatible with some piece ofOpenStack a very hard to diagnose break occurs.We also had an issue with projects adding dependencies of pythonlibraries without thinking through the long term implications of thoselibraries. Is the library actively maintained? Is the library of acompatible license? Does the library duplicate the function of existinglibraries that we already have in requirements? Is the library python3 compatible? Is the library something that already exists in LinuxDistros that we target (Ubuntu / Fedora). The answer to many of thesequestions was no.Global requirements gives us a single place where we can evaluatethese things so that we can make a global decision for OpenStack onthe suitability of the library.Since Havana we've also observed significant CI disruption occurring due toupstream releases of software that are incompatible (whether in smallor large ways) with OpenStack. So Global Requirements also serves as a controlpoint to determine the precise versions of dependencies that will be usedduring CI.Solution========The mechanics of the solution are relatively simple. We maintain acentral list of all the requirements (``global-requirements.txt``)that are allowed in OpenStack projects. This is enforced for``requirements.txt``, ``test-requirements.txt``,``doc/requirements.txt``, and extras defined in``setup.cfg``. This is maintained by hand, with changes going through CI.We also maintain a compiled list of the exact versions, including transitivedependencies, of packages that are known to work in the OpenStack CI system.This is maintained via an automated process that calculates the list andproposes a change back to this repository. A consequence of this is thatnew releases of OpenStack libraries are not immediately used: they have topass through this automated process before we can benefit from (or be harmedby) them.Format------``global-requirements.txt`` supports a subset of pip requirement filecontents. Distributions may only be referenced by name, not URL. Options(such as -e or -f) may not be used. Version specifiers, environment markersand comments are all permitted. A single distribution may be listed more thanonce if different specifiers are required with different markers - forinstance, if a dependency has dropped Python 2.7 support.``upper-constraints.txt`` is machine generated and nothing more or less thanan exact list of versions.Enforcement for Test Runs-------------------------DevStack++++++++DevStack uses the pip ``-c`` option to pin all the libraries to known goodversions. ``edit-constraints`` can be used to unpin a single constraint, andthis is done to install libraries from git.Tox+++We are working on the necessary changes to use ``upper-constraints.txt`` intox jobs but it is not yet complete.Enforcement in Projects-----------------------All projects that have accepted the requirements contract (as listedin ``projects.txt``) are expected to run a requirements compatibilityjob. This job ensures that a project can not change any dependencies toversions not compatible with ``global-requirements.txt``. It also ensures thatthose projects can not add a requirement that is not already in``global-requirements.txt``. This ``check-requirements`` job shouldbe merged in infra before proposing the change to ``projects.txt`` in``openstack/requirements``.Automatic Sync of Accepted Requirements---------------------------------------If an updated requirement is proposed to OpenStack and accepted to``global-requirements.txt``, the system then also automatically pushesa review request for the new requirements definition to the projectsthat include it.For instance: if a review is accepted to ``global-requirements.txt``that increases the minimum version of python-keystoneclient, thesystem will submit patches to all the OpenStack projects that listpython-keystoneclient as a requirement or test requirement to matchthis new version definition.This is intended as a time saving device for projects, as they canfast approve requirements syncs and not have to manually worry aboutwhether or not they are up to date with the global definition.Tools=====All the tools require openstack_requirements to be installed (e.g. in a Pythonvirtualenv). They all have help, which is the authoritative documentation.update-requirements-------------------This will update the requirements in a project from the global requirementsfile found in ``.``. Alternatively, pass ``--source`` to use a differentglobal requirements file::update-requirements --source /opt/stack/requirements /opt/stack/novaEntries in all requirements files will have their versions updated to matchthe entries listed in the global requirements.  Excess entries will causeerrors in hard mode (the default) or be ignored in soft mode.generate-constraints--------------------Compile a constraints file showing the versions resulting from installing allof ``global-requirements.txt``::generate-constraints -p /usr/bin/python2.7 -p /usr/bin/python3 \-b blacklist.txt -r global-requirements.txt > new-constraints.txtedit-constraints----------------Replace all references to a package in a constraints file with a newspecification. Used by DevStack to enable git installations of libraries thatare normally constrained::edit-constraints oslo.db "-e file://opt/stack/oslo.db#egg=oslo.db"Proposing changes=================Look at the `Review Guidelines` and make sure your change meets them.All changes to ``global-requirements.txt`` may dramatically alter the contentsof ``upper-constraints.txt`` due to adding or removing transitivedependencies. As such you should always generate a diff against the currentmerged constraints, otherwise your change may fail if it is incompatible withthe current tested constraints.Regenerating involves five steps.1) Install the dependencies needed to compile various Python packages::sudo apt-get install $(bindep -b)2) Create a reference file (do this without your patch applied)::generate-constraints -p /usr/bin/python2.7 -p /usr/bin/python3 \-b blacklist.txt -r global-requirements.txt > baseline3) Apply your patch and generate a new reference file::generate-constraints -p /usr/bin/python2.7 -p /usr/bin/python3 \-b blacklist.txt -r global-requirements.txt > updated4) Diff them::diff -p baseline updated5) Apply the patch to ``upper-constraints.txt``. This may require somefiddling. ``edit-constraint`` can do this for you **when the changedoes not involve multiple lines for one package**.Review Guidelines=================There are a set of questions that every reviewer should ask on anyproposed requirements change. Proposers can make reviewing easier byincluding the answers to these questions in the commit message fortheir change.General Review Criteria------------------------ No specifications for library versions should contain version capsAs a community we value early feedback of broken upstreamrequirements, so version caps should be avoided except when dealingwith exceptionally unstable libraries.If a library is exceptionally unstable, we should also beconsidering whether we want to replace it over time with one that*is* stable, or to contribute to the upstream community to helpstabilize it.- Libraries should contain a sensible known working minimum versionBare library names are bad. If it's unknown what a working minimumis, look at the output of pip freeze at the end of a successfulDevStack/tempest run and use that version. At least that's known tobe working now.- Commit message should refer to consuming projects(s)Preferably, the comments should also identify which feature orblueprint requires the new specification. Ideally, changes shouldalready be proposed, so that its use can be seen.- The blacklist is for handling dependencies that cannot be constrained.For instance, linters which each project has at a different release level,and which make projects fail on every release (because they add rules) -those cannot be globally constrained unless we coordinate updating all ofOpenStack to the new release at the same time - but given the volunteerand loosely coupled nature of the big tent that is infeasible. Dependenciesthat are only used in unconstrained places should not be blacklisted - theymay be constrained in future, and there's no harm caused by constrainingthem today. Entries in the blacklist should have a comment explaining thereason for blacklisting.- Reviews that only update ``projects.txt`` should be workflow approvedalongside or before other reviews in order to have the OpenStack Proposal Botpropagation be useful as soon as possible for the other projects. For projectremoval or addition, the +1 from the current PTL (or core if the PTL proposedthe change) should be enough.For new Requirements--------------------- Is the library actively maintained?We *really* want some indication that the library is something wecan get support on if we or our users find a bug, and that wedon't have to take over and fork the library.Pointers to recent activity upstream and a consistent release modelare appreciated.- Is the library good code?It's expected, before just telling everyone to download arbitrary 3rdparty code from the internet, that the submitter has taken a deep diveinto the code to get a feel on whether this code seems solid enoughto depend on. That includes ensuring the upstream code has somereasonable testing baked in.- Is the library python 3 compatible?OpenStack will eventually need to support python 3. At this pointadding non python 3 compatible libraries should only be done under*extreme* need. It should be considered a very big exception.- Is the library license compatible?The library should be licensed as described in `Licensing requirements`_,and the license should be described in a comment on the same line as theadded dependency. If you have doubts over licensing compatibility, likefor example when adding a GPL test dependency, you can seek advice fromRobert Collins (lifeless), Monty Taylor (mordred) or Jim Blair (jeblair).- Is the library already packaged in the distros we target (Ubuntulatest / Fedora latest)?By adding something to OpenStack ``global-requirements.txt`` we arebasically demanding that Linux Distros package this for the nextrelease of OpenStack. If they already have, great. If not, we shouldbe cautious of adding it. :ref:`finding-distro-status`- Is the function of this library already covered by other librariesin ``global-requirements.txt``?Everyone has their own pet libraries that they like to use, but wedo not need three different request mocking libraries in OpenStack.If this new requirement is about replacing an existing library withone that's better suited for our needs, then we also need thetransition plan to drop the old library in a reasonable amount oftime.- Is the library required for OpenStack project or related dev orinfrastructure setup? (Answer to this should be Yes, of course)Which?Please provide details such as gerrit change request or launchpadbug/blueprint specifying the need for adding this library.- If the library release is managed by the Openstack release process doesit use the `cycle-with-intermediary` release type?This is needed to ensure that updated releases that consume requirementsupdates are available for integration/coninstallability tests with otherprojects.- Do I need to update anything else?When new library is added, initial version of release needs to be addedto ``upper-constraints.txt``. After that, OpenStack Proposal Bot willpropose updates... _Licensing requirements: https://governance.openstack.org/tc/reference/licensing.htmlFor Upgrading Requirements Versions------------------------------------ Why is it impossible to use the current version definition?Everyone likes everyone else to use the latest version of theircode. However, deployers really don't like to be constantly updatingthings. Unless it's actually **impossible** to use the minimumversion specified in ``global-requirements.txt``, it should not bechanged.Leave that decision to deployers and distros.- Changes to update the minimum version of a library developed by theOpenStack community can be approved by one reviewer, as long as theconstraints are correct and the tests pass... _finding-distro-status:Finding Distro Status---------------------From the OpenStack distro support policy:OpenStack will target its development efforts to latest Ubuntu/Fedora,but will not introduce any changes that would make it impossible torun on the latest Ubuntu LTS or latest RHEL.As such we really need to know what the current state of packaging ison these platforms (and ideally Debian, Gentoo, and SUSE as well).For people unfamiliar with Linux Distro packaging you can use thefollowing tools to search for packages:- Ubuntu - http://packages.ubuntu.com/- Fedora - https://apps.fedoraproject.org/packages/- Gentoo - https://packages.gentoo.org/- SUSE - https://build.opensuse.org/project/show/devel:languages:pythonFor ``upper-constraints.txt`` changes-------------------------------------If the change was proposed by the OpenStack CI bot, then if the change haspassed CI, only one reviewer is needed and they should +2 +A without thinkingabout things.If the change was not proposed by the OpenStack CI bot, and onlychanges the ``upper-constraints.txt`` entry for a new library release,then the change should be approved if it passes the tests. See theREADME.rst in openstack/releases for more details of the releaseprocess.If the change was not proposed by the OpenStack CI bot, and is notrelated to releasing one of our libraries, and does not include a``global-requirements.txt`` change, then it should be rejected: the CIbot will generate an appropriate change itself. Ask in#openstack-infra if the bot needs to be run more quickly.Otherwise the change may be the result of recalculating the constraints whichchanged when a ``global-requirements.txt`` change is proposed. In this case, ignorethe changes to ``upper-constraints.txt`` and review the``global-requirements.txt`` component of the change.stable-branch maintenance-------------------------Upper-constraints+++++++++++++++++Most of the work is done by stable-maint in the releases project.  The releasesproject ensures valid stable releases (little to no API level changes, bugfixonly, etc).  Once released, the new version is requested to be updated inrequirements.  The following restrictions are in place to help ensure stablebranches do not break.- In stable branches, we usually only update constraints for projects managedwithin the OpenStack community. Exceptions are made for other projects whenthere are gate issues. Those updates must be proposed by hand.- The requirements team also verifies the new version's requirements changesline up with the requirements in the stable branch (GR and UC).Global-requirements+++++++++++++++++++These should be few and far between on stable branches, mainly masking knownbad versions or in extreme adding a maximum version allowable for a package.We work to remove these caps as well.  Raising effective minimums is onlyacceptable during `Phase I`, and only due to security issues... _Phase I: https://docs.openstack.org/project-team-guide/stable-branches.html#support-phasesNew requirements++++++++++++++++In nearly all cases this is not allowed.  An example where this is allowedwould be:  A dependency of a dependency has an issue that impacts OpenStack.It wasn't listed in global-requirements.txt but it is required.  In order toblock the affected releases and still be able to keep requirements in sync, welist the library in global-requirements.txt and update all projects thatrequire it.Resources=========- Documentation: https://docs.openstack.org/requirements/latest/- Wiki: https://wiki.openstack.org/wiki/Requirements- Bugs: https://launchpad.net/openstack-requirements