Skip to content

Commit

Permalink
Merge pull request #444 from /issues/436
Browse files Browse the repository at this point in the history
Python version deprecations and add 3.8 testing
  • Loading branch information
jantman committed Oct 31, 2019
2 parents 2737fad + 04c1593 commit 5fa0804
Show file tree
Hide file tree
Showing 51 changed files with 195 additions and 150 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.*
8 changes: 0 additions & 8 deletions .landscape.yaml

This file was deleted.

8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@ matrix:
env: TOXENV=py37
dist: xenial
sudo: true
- python: "3.8"
env: TOXENV=py38
dist: xenial
sudo: true
- python: "3.7"
env: TOXENV=docker
dist: xenial
sudo: true
services:
- docker
- python: "2.7"
- python: "3.7"
env: TOXENV=docs
- python: "2.7"
env: TOXENV=integration
- python: "3.6"
- python: "3.7"
env: TOXENV=integration3
install:
- git config --global user.email "travisci@jasonantman.com"
Expand Down
8 changes: 7 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,10 @@ 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.
* `Issue #437 <https://github.com/jantman/awslimitchecker/issues/437>`_ - Per `PEP 429 <https://www.python.org/dev/peps/pep-0429/>`_, Python 3.4 reached end-of-life on March 18, 2019 and is now officially retired. Add a ``PendingDeprecationWarning`` for users running under this version, announcing that support for Python 3.4 will be removed on January 1, 2020.
* In following with the above two issues, raise a ``DeprecationWarning`` when running on any Python2 version prior to 2.7 or any Python3 version prior to 3.4, in accorance with the `published end-of-life dates of those versions <https://devguide.python.org/devcycle/#end-of-life-branches>`_.
* `Issue #436 <https://github.com/jantman/awslimitchecker/issues/436>`_ - Begin testing under Python 3.8 and base our Docker image on ``python:3.8-alpine``.

New EC2 vCPU Limits
+++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3-alpine
FROM python:3.8-alpine

ARG git_version

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
48 changes: 48 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,45 @@ 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[:2] == (3, 4): # nocoverage
warnings.warn(
'awslimitchecker has detected that it is running under Python '
'3.4. 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
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.alerts.base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.alerts.base module
==================================

.. automodule:: awslimitchecker.alerts.base
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.alerts.dummy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.alerts.dummy module
===================================

.. automodule:: awslimitchecker.alerts.dummy
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.alerts.pagerdutyv1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.alerts.pagerdutyv1 module
=========================================

.. automodule:: awslimitchecker.alerts.pagerdutyv1
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
7 changes: 3 additions & 4 deletions docs/source/awslimitchecker.alerts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ awslimitchecker.alerts package
==============================

.. automodule:: awslimitchecker.alerts
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:

Submodules
----------
Expand All @@ -14,4 +14,3 @@ Submodules
awslimitchecker.alerts.base
awslimitchecker.alerts.dummy
awslimitchecker.alerts.pagerdutyv1

6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.checker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.checker module
==============================

.. automodule:: awslimitchecker.checker
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.connectable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.connectable module
==================================

.. automodule:: awslimitchecker.connectable
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.limit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.limit module
============================

.. automodule:: awslimitchecker.limit
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.metrics.base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.metrics.base module
===================================

.. automodule:: awslimitchecker.metrics.base
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.metrics.datadog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.metrics.datadog module
======================================

.. automodule:: awslimitchecker.metrics.datadog
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.metrics.dummy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.metrics.dummy module
====================================

.. automodule:: awslimitchecker.metrics.dummy
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
7 changes: 3 additions & 4 deletions docs/source/awslimitchecker.metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ awslimitchecker.metrics package
===============================

.. automodule:: awslimitchecker.metrics
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:

Submodules
----------
Expand All @@ -14,4 +14,3 @@ Submodules
awslimitchecker.metrics.base
awslimitchecker.metrics.datadog
awslimitchecker.metrics.dummy

13 changes: 6 additions & 7 deletions docs/source/awslimitchecker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ awslimitchecker package
=======================

.. automodule:: awslimitchecker
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:

Subpackages
-----------

.. toctree::

awslimitchecker.alerts
awslimitchecker.metrics
awslimitchecker.services
awslimitchecker.alerts
awslimitchecker.metrics
awslimitchecker.services

Submodules
----------
Expand All @@ -27,4 +27,3 @@ Submodules
awslimitchecker.trustedadvisor
awslimitchecker.utils
awslimitchecker.version

6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.runner module
=============================

.. automodule:: awslimitchecker.runner
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.services.apigateway.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.services.apigateway module
==========================================

.. automodule:: awslimitchecker.services.apigateway
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.services.autoscaling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.services.autoscaling module
===========================================

.. automodule:: awslimitchecker.services.autoscaling
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.services.base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.services.base module
====================================

.. automodule:: awslimitchecker.services.base
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.services.cloudformation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.services.cloudformation module
==============================================

.. automodule:: awslimitchecker.services.cloudformation
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.services.cloudtrail.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.services.cloudtrail module
==========================================

.. automodule:: awslimitchecker.services.cloudtrail
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.services.directoryservice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.services.directoryservice module
================================================

.. automodule:: awslimitchecker.services.directoryservice
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.services.dynamodb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.services.dynamodb module
========================================

.. automodule:: awslimitchecker.services.dynamodb
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/source/awslimitchecker.services.ebs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ awslimitchecker.services.ebs module
===================================

.. automodule:: awslimitchecker.services.ebs
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:

0 comments on commit 5fa0804

Please sign in to comment.