Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fred/eng 101 argo rollout support #303

Merged
merged 30 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d22602f
WIP support for argo rollouts
linkous8 Jul 20, 2021
bdd9fbd
Merge branch 'main' into fred/eng-101-argo-rollout-support
linkous8 Jul 22, 2021
02e303c
Resolve rollout sidecar injection, refactor fixtures
linkous8 Jul 22, 2021
5674675
Fix failing integration tests
linkous8 Jul 22, 2021
d70f8bf
Fix opsani dev rollout config generation
linkous8 Jul 23, 2021
07dc8e5
FIx model and unit test
linkous8 Jul 23, 2021
8f78362
Fix rollout opsani_dev checks reference deployment
linkous8 Jul 23, 2021
986dbcb
Update rollout remedies to use merge patch type
linkous8 Jul 23, 2021
b4c9ad5
Allow rollout in inject inject_sidecar validation
linkous8 Jul 23, 2021
03f5d81
Fix opsani_dev envoy scrape check cant port
linkous8 Jul 23, 2021
a2b0507
Fix rollout model conversion preventing cascade
linkous8 Jul 23, 2021
f01b9a6
Update model conversion exclude_unset>exclude_none
linkous8 Jul 23, 2021
04eabd8
Cleanup kubernetes connector rollout support
linkous8 Jul 28, 2021
e52b92b
Refactor opsani dev checks to reduce redundancies
linkous8 Jul 29, 2021
84672cf
Merge branch 'main' into fred/eng-101-argo-rollout-support
linkous8 Jul 29, 2021
7558f1b
Update test params, name to prevent ns collision
linkous8 Jul 29, 2021
e9b472a
Drop remedy from rollout selector check, fix tests
linkous8 Jul 30, 2021
e5226c4
Fix tests, rename opsani dev rollout checks tests to
linkous8 Jul 30, 2021
89d39e4
Test if owner reference prevents rollout adoption
linkous8 Jul 30, 2021
91f7566
Fix rollout selector check test, expand coverage
linkous8 Jul 30, 2021
e083d2c
Restore dropped label assert in opsani_dev checks,
linkous8 Jul 30, 2021
94aae16
Update kubernetes_asyncio fork to 12.1.2
linkous8 Jul 30, 2021
7b4d8cf
Fix rollout permissions not being checked
linkous8 Aug 5, 2021
b6f2507
Merge branch 'main' into fred/eng-101-argo-rollout-support
linkous8 Aug 9, 2021
7a7e44a
Address PR feedback:
linkous8 Aug 10, 2021
0026a97
ops dev whitespace (kick off gh adctions)
linkous8 Aug 11, 2021
fef0433
Merge branch 'main' into fred/eng-101-argo-rollout-support
linkous8 Aug 11, 2021
66d910a
Refactor k8s checks, fix integration tests
linkous8 Aug 11, 2021
b448ab0
Update cascade log, fix integration tests
linkous8 Aug 11, 2021
7b7f944
Bump timeout for flakey test
linkous8 Aug 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ typer = "^0.3.0"
bullet = "^2.1.0"
jsonschema = "^3.2.0"
timeago = "^1.0.14"
kubernetes_asyncio = ">=11.3,<13.0"
orjson = "^3.5.0"
uvloop = "^0.15.2"
statesman = "^1.0.0"
Expand All @@ -37,6 +36,7 @@ toml = "^0.10.2"
colorama = "^0.4.4"
pyfiglet = "^0.8.post1"
curlify2 = "^1.0.0"
kubernetes-asyncio = {git = "https://github.com/opsani/kubernetes_asyncio", rev = "v12.1.2-custom-resource-patch-fix"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we sent this back upstream as a PR? Starting to carry around our own custom fork of the Kubernetes library is sorta heavy. Knowing if we can get a patch landed and get back on a release is significant given how foundational this library is

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch I'm using in the fork is not upstreamable as it was applied to the generated code rather than updating the code generation models. The upstream library maintainer has PRed a fix for this issue into the standard kubernetes python client but its unclear when that will be landed and the fork is mainly a temporary workaround.

The library does not release very frequently so keeping up with patching the fork should not be too burdensome and I've also thrown together some automation on the fork to let us know when we need to rebase it: https://github.com/opsani/kubernetes_asyncio/blob/master/.github/workflows/check-upstream-release.yaml

See ENG-148 for discussion pertaining to this workaround


[tool.poetry.dev-dependencies]
pytest = "^6.2.4"
Expand Down Expand Up @@ -81,6 +81,7 @@ pytest-vscodedebug = "^0.1.0"
pytest-html = "^3.1.1"
bandit = "^1.7.0"
watchgod = "^0.7"
filelock = "^3.0.12"

[tool.poetry.scripts]
servo = "servo.entry_points:run_cli"
Expand Down
2 changes: 1 addition & 1 deletion servo/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ async def run_all(
spec = getattr(method, "__check__", None)
if spec:
# once all filtered methods are removed, only run non-decorated
if not spec.critical or not filtered_methods:
if not spec.critical or not filtered_methods or (matching and matching.exclusive):
continue

check = await method() if asyncio.iscoroutinefunction(method) else method()
Expand Down
17 changes: 15 additions & 2 deletions servo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,8 +1729,8 @@ def inject_sidecar(
"""
Inject an Envoy sidecar to capture metrics
"""
if not target.startswith(("deploy/", "deployment/", "pod/")):
raise typer.BadParameter("target must prefixed with Kubernetes object kind of \"deployment\" or \"pod\"")
if not target.startswith(("deploy/", "deployment/", "pod/", "rollout/")):
raise typer.BadParameter("target must prefixed with Kubernetes object kind of \"deployment\", \"rollout\" or \"pod\"")

if not (service or port):
raise typer.BadParameter("service or port must be given")
Expand Down Expand Up @@ -1759,6 +1759,19 @@ def inject_sidecar(
)
typer.echo(f"Envoy sidecar injected to Deployment {deployment.name} in {namespace}")

elif target.startswith("rollout"):
rollout = run_async(
servo.connectors.kubernetes.Rollout.read(
target.split('/', 1)[1], namespace
)
)
run_async(
rollout.inject_sidecar(
'opsani-envoy', ENVOY_SIDECAR_IMAGE_TAG, service=service, port=port
)
)
typer.echo(f"Envoy sidecar injected to Rollout {rollout.name} in {namespace}")

elif target.startswith("pod"):
raise typer.BadParameter("Pod sidecar injection is not yet implemented")
else:
Expand Down
Loading