Skip to content

Commit

Permalink
Merge pull request #126 from 2gis/fix-deprecation-checker
Browse files Browse the repository at this point in the history
Fix deploy for deprecated api versions
  • Loading branch information
seleznev committed May 13, 2020
2 parents ae135cd + 511a8d0 commit 0bf1afd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
4 changes: 1 addition & 3 deletions k8s_handle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from k8s_handle import config
from k8s_handle import settings
from k8s_handle import templating
from k8s_handle.exceptions import DeprecationError, ProvisioningError, ResourceNotAvailableError
from k8s_handle.exceptions import ProvisioningError, ResourceNotAvailableError
from k8s_handle.filesystem import InvalidYamlError
from k8s_handle.k8s.deprecation_checker import ApiDeprecationChecker
from k8s_handle.k8s.provisioner import Provisioner
Expand Down Expand Up @@ -230,8 +230,6 @@ def main():
except InvalidYamlError as e:
log.error('{}'.format(e))
sys.exit(1)
except DeprecationError as e:
log.warning('Deprecation warning: {}'.format(e))
except RuntimeError as e:
log.error('RuntimeError: {}'.format(e))
sys.exit(1)
Expand Down
4 changes: 0 additions & 4 deletions k8s_handle/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ class ProvisioningError(Exception):
pass


class DeprecationError(Exception):
pass


class ResourceNotAvailableError(Exception):
pass

Expand Down
9 changes: 1 addition & 8 deletions k8s_handle/k8s/deprecation_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import semver

from k8s_handle.templating import get_template_contexts
from k8s_handle.exceptions import DeprecationError

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -131,13 +130,7 @@ def _is_deprecated(self, api_version, kind):
status="unsupported",
k8s_version=self.deprecated_versions[api_version][kind]["until"],
))
raise DeprecationError(
"Version {} for resourse type '{}' is unsupported since kubernetes {}".format(
api_version,
kind,
self.deprecated_versions[api_version][kind]["until"]
)
)
return True

if self._is_server_version_greater(self.deprecated_versions[api_version][kind]["since"]):
log.warning(message.format(
Expand Down
7 changes: 2 additions & 5 deletions k8s_handle/k8s/test_deprecation_checker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest

from k8s_handle.exceptions import DeprecationError
from k8s_handle.k8s.deprecation_checker import ApiDeprecationChecker


Expand Down Expand Up @@ -76,8 +75,7 @@ def test_version_is_unsupported_equal(self):
},
}
}
with self.assertRaises(DeprecationError):
checker._is_deprecated("test/v1", "Deployment")
self.assertTrue(checker._is_deprecated("test/v1", "Deployment"))

def test_version_is_unsupported(self):
checker = ApiDeprecationChecker("1.10.6")
Expand All @@ -89,8 +87,7 @@ def test_version_is_unsupported(self):
},
}
}
with self.assertRaises(DeprecationError):
checker._is_deprecated("test/v1", "Deployment")
self.assertTrue(checker._is_deprecated("test/v1", "Deployment"))

def test_version_no_until(self):
checker = ApiDeprecationChecker("1.10.6")
Expand Down

0 comments on commit 0bf1afd

Please sign in to comment.