-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch kubernetes Api Client to work around lock contention issues
Unclear whether the benefits are worth the risk of breaking changes here, but this is a workaround for the signifcant lock contention issues with the k8s client surfaced in #23933 (reply in thread). This appears to be a known issue with the k8s python client - see kubernetes-client/python#2284. Test Plan: BK
- Loading branch information
Showing
7 changed files
with
118 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
python_modules/libraries/dagster-k8s/dagster_k8s/kubernetes_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
KUBERNETES_VERSION_UPPER_BOUND = "32" |
3 changes: 3 additions & 0 deletions
3
python_modules/libraries/dagster-k8s/dagster_k8s_tests/pytest.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
markers = | ||
nightly: only run in nightly test suite |
39 changes: 39 additions & 0 deletions
39
python_modules/libraries/dagster-k8s/dagster_k8s_tests/unit_tests/test_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,44 @@ | ||
import packaging.version | ||
import pytest | ||
import requests | ||
from dagster_k8s.version import __version__ | ||
|
||
|
||
def test_version(): | ||
assert __version__ | ||
|
||
|
||
from dagster_k8s.kubernetes_version import KUBERNETES_VERSION_UPPER_BOUND | ||
|
||
|
||
def parse_package_version(version_str: str) -> packaging.version.Version: | ||
parsed_version = packaging.version.parse(version_str) | ||
assert isinstance( | ||
parsed_version, packaging.version.Version | ||
), f"Found LegacyVersion: {version_str}" | ||
return parsed_version | ||
|
||
|
||
def _get_latest_published_k8s_version() -> packaging.version.Version: | ||
res = requests.get("https://pypi.org/pypi/kubernetes/json") | ||
module_json = res.json() | ||
releases = module_json["releases"] | ||
release_versions = [ | ||
parse_package_version(version) | ||
for version, files in releases.items() | ||
if not any(file.get("yanked") for file in files) | ||
] | ||
for release_version in reversed(sorted(release_versions)): | ||
if not release_version.is_prerelease: | ||
return release_version | ||
|
||
raise Exception("Could not find any latest published kubernetes version") | ||
|
||
|
||
@pytest.mark.nightly | ||
def test_latest_version_pin(): | ||
latest_version = _get_latest_published_k8s_version() | ||
assert latest_version.major < packaging.version.parse(KUBERNETES_VERSION_UPPER_BOUND).major, ( | ||
f"A new version {latest_version} of kubernetes has been released to pypi that exceeds our pin. " | ||
"Increase the pinned version in kubernetes_version.py and verify that it still passes tests." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters