Skip to content

Commit

Permalink
Fixes #439 - Announce deprecation of py27 support on 2020-01-01 and r…
Browse files Browse the repository at this point in the history
…aise PendingDeprecationWarning
  • Loading branch information
jantman committed Oct 31, 2019
1 parent bf5fe01 commit 59d08d8
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ exclude_lines =
raise NotImplementedError
except ImportError:
pragma: no cover
.*# nocoverage.*
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog
Unreleased Changes
------------------

**Important:** This release includes **major** changes to the EC2 On-Demand Instances service limits! For most users, this means the 175 Instance-type-specific limits will be removed and replaced with five (5) limits. Please see the sections below for further details, as this will especially impact anyone using limit or threshold overrides, or post-processing awslimitchecker's output. This is also a time to remind all users that this project adheres to a strict :ref:`development.versioning_policy` and if occasional breakage due to limit or IAM policy changes is unacceptable, you should pin to a major version.
**Important:** This release includes **major** changes to the EC2 On-Demand Instances service limits! For most users, this means the 175 Instance-type-specific limits will be removed and replaced with five (5) limits. Please see the "New EC2 vCPU Limits" section below for further details, as this will especially impact anyone using limit or threshold overrides, or post-processing awslimitchecker's output. This is also a time to remind all users that this project adheres to a strict :ref:`development.versioning_policy` and if occasional breakage due to limit or IAM policy changes is unacceptable, you should pin to a major version.

**Important:** Python versions prior to 3.5, including 2.7, are now pending deprecation. As of January 1, 2020, they will no longer be tested or supported, and awslimitchecker **will require Python 3.5 or newer**. Please see below for details. Also take note that running via the official Docker image is a way to ensure the best version of Python is always used.

* `Issue #400 <https://github.com/jantman/awslimitchecker/issues/400>`__ / `PR #434 <https://github.com/jantman/awslimitchecker/pull/434>`__ - Support GovCloud region and alternate partitions in STS assumed roles and Trusted Advisor. Thanks to `@djkiourtsis <https://github.com/djkiourtsis>`__.
* `Issue #432 <https://github.com/jantman/awslimitchecker/issues/432>`__ - Update EC2 limit handling for new vCPU-based limits in regions other than ``cn-*`` and ``us-gov-*`` (which still use old per-instance-type limits). See section below for further information. For regions other than ``cn-*`` and ``us-gov-*``, **this will remove** all 175 ``Running On-Demand <type> instances`` and the ``Running On-Demand EC2 instances`` limit, and replace them with:
Expand All @@ -19,6 +21,7 @@ Unreleased Changes
* `Issue #433 <https://github.com/jantman/awslimitchecker/issues/433>`_ - Fix broken links in the docs; waffle.io and landscape.io are both gone, sadly.
* `Issue #441 <https://github.com/jantman/awslimitchecker/issues/441>`_ - Fix critical bug where awslimitchecker would die with an unhandled ``botocore.exceptions.ParamValidationError`` exception in accounts that have Trusted Advisor but do not have a "Service Limits" check in the "performance" category.
* `Issue #439 <https://github.com/jantman/awslimitchecker/issues/439>`_ - Fix unhandled exception in CloudTrail service when attempting to call ``GetEventSelectors`` on an Organization trail. When calling ``DescribeTrails``, we will now pass ``includeShadowTrails`` as False, to not include replications of trails in different regions or organization trails in member accounts (relevant `API documentation <https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_DescribeTrails.html>`_).
* `Issue #438 <https://github.com/jantman/awslimitchecker/issues/438>`_ - Per `PEP 373 <https://www.python.org/dev/peps/pep-0373/>`__, Python 2.7 will officially end support on January 1, 2020. As such, and in keeping with reasoning explained at `python3statement.org <https://python3statement.org/>`__, awslimitchecker will **stop supporting and testing against Python 2.7** on January 1, 2020. At that point, all new versions will be free to use Python features introduced in 3.5. As of this version, a `PendingDeprecationWarning <https://docs.python.org/3/library/exceptions.html#PendingDeprecationWarning>`__ will be emitted when running awslimitchecker under Python 2.7.

New EC2 vCPU Limits
+++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Requirements

**Either Docker in order to run via the** `docker image <http://awslimitchecker.readthedocs.io/en/latest/docker.html>`__, **or:**

* Python 2.7 or 3.4+. Python 2.6 and 3.3 are no longer supported.
* Python 3.5 or newer. Python 2.7 will not be supported as of January 1, 2010.
* Python `VirtualEnv <http://www.virtualenv.org/>`_ and ``pip`` (recommended installation method; your OS/distribution should have packages for these)
* `boto3 <http://boto3.readthedocs.org/>`_ >= 1.4.6 and its dependency `botocore <https://botocore.readthedocs.io/en/latest/>`_ >= 1.6.0.

Expand Down
38 changes: 38 additions & 0 deletions awslimitchecker/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,17 @@
import boto3
import sys
import logging
import warnings

logger = logging.getLogger(__name__)

warnings.filterwarnings(
action="always", category=DeprecationWarning, module=__name__
)
warnings.filterwarnings(
action="always", category=PendingDeprecationWarning, module=__name__
)


class AwsLimitChecker(object):

Expand Down Expand Up @@ -160,6 +168,7 @@ def __init__(self, warning_threshold=80, critical_threshold=99,
' is %s; please consider upgrading.', self.vinfo.release,
latest_ver
)
self._check_python_version()
self.warning_threshold = warning_threshold
self.critical_threshold = critical_threshold
self.profile_name = profile_name
Expand All @@ -185,6 +194,35 @@ def __init__(self, warning_threshold=80, critical_threshold=99,
ta_refresh_timeout=ta_refresh_timeout,
ta_api_region=ta_api_region)

def _check_python_version(self):
"""
Check that we are running under a supported Python version, and emit a
warning otherwise.
"""
if sys.version_info[:2] == (2, 7): # nocoverage
warnings.warn(
'awslimitchecker has detected that it is running under Python '
'2.7. This will no longer be supported as of January 1, 2020. '
'Please upgrade to Python 3.5 or newer. Please see the '
'changelog for awslimitchecker version 8.0.0 at <https://'
'awslimitchecker.readthedocs.io/en/latest/changes.html>'
'for further details.',
PendingDeprecationWarning
)
elif (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
): # nocoverage
warnings.warn(
'awslimitchecker has detected that it is running under Python '
'%d.%d. This version has reached end-of-life and is no longer '
'supported by awslimitchecker, and may not function correctly. '
'Please update to a newer Python version (>= 3.5) or switch '
'to running via the official Docker image.'
'' % (sys.version_info[0], sys.version_info[1]),
DeprecationWarning
)

@property
def _boto_conn_kwargs(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ To setup awslimitchecker for development:

1. Fork the `awslimitchecker <https://github.com/jantman/awslimitchecker>`_ repository on GitHub

2. Create a ``virtualenv`` to run the code in:
2. Create a ``virtualenv`` (using Python 3.5 or later) to run the code in:

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Requirements

**Either Docker in order to run via the** :ref:`docker image <docker>`, **or:**

* Python 2.7 or 3.4+. Python 2.6 and 3.3 are no longer supported.
* Python 3.5 or newer. Python 2.7 will not be supported as of January 1, 2010.
* Python `VirtualEnv <http://www.virtualenv.org/>`_ and ``pip`` (recommended installation method; your OS/distribution should have packages for these)
* `boto3 <http://boto3.readthedocs.org/>`_ >= 1.4.6 and its dependency `botocore <https://botocore.readthedocs.io/en/latest/>`_ >= 1.6.0.

Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
]

classifiers = [
'Development Status :: 4 - Beta',
'Development Status :: 6 - Mature',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
Expand All @@ -63,13 +63,11 @@
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Internet',
'Topic :: System :: Monitoring',
]
Expand Down

0 comments on commit 59d08d8

Please sign in to comment.