Skip to content

dist: Add distro verify tool #17380

Merged
htuch merged 2 commits intoenvoyproxy:mainfrom
phlax:dist-add-verify-util
Aug 12, 2021
Merged

dist: Add distro verify tool #17380
htuch merged 2 commits intoenvoyproxy:mainfrom
phlax:dist-add-verify-util

Conversation

@phlax
Copy link
Copy Markdown
Member

@phlax phlax commented Jul 16, 2021

Commit Message: dist: Add distro verify tool
Additional Description:

provided with following arguments:

  • path to a yaml file containing distros to test
  • a tarball containing debs/rpms

it will test each of the debs/rpms against the relevant distros

the format for the yaml is:

debian_buster:
  image: debian:buster-slim
  ext: buster.changes

ubuntu_foo:
  image: ubuntu:73.1
  ext: foo.changes

redhat_8.1:
  image: registry.access.redhat.com/ubi8/ubi:8.1

the tarball should have a layout like:

./
./deb/
./deb/envoy-1.19_1.19.0_amd64.bullseye.changes
./deb/envoy-1.19_1.19.0_amd64.buster.changes
./deb/envoy-1.19_1.19.0_amd64.deb
./deb/envoy-1.19_1.19.0_amd64.hirstute.changes
./deb/envoy-1.19_1.19.0_amd64.impish.changes
./deb/envoy_1.19.0_amd64.bullseye.changes
./deb/envoy_1.19.0_amd64.buster.changes
./deb/envoy_1.19.0_amd64.deb
./deb/envoy_1.19.0_amd64.hirstute.changes
./deb/envoy_1.19.0_amd64.impish.changes
./rpm/
./rpm/envoy-1.19_1.19.0_x86_64.rpm
./rpm/envoy_1.19.0_x86_64.rpm

which will be created with bazel packaging rules once we land the relevant code

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]

@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #17380 was opened by phlax.

see: more, trace.

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).

🐱

Caused by: #17380 was opened by phlax.

see: more, trace.

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Jul 16, 2021
@phlax
Copy link
Copy Markdown
Member Author

phlax commented Jul 16, 2021

@phlax phlax force-pushed the dist-add-verify-util branch from 1ec3bd4 to 555a6f9 Compare July 16, 2021 13:18
@phlax phlax force-pushed the dist-add-verify-util branch 24 times, most recently from d5c98c2 to 60763c7 Compare July 20, 2021 08:17
@phlax phlax force-pushed the dist-add-verify-util branch 10 times, most recently from ce4491f to 39fc9db Compare July 23, 2021 14:36
@phlax phlax mentioned this pull request Jul 26, 2021
@phlax
Copy link
Copy Markdown
Member Author

phlax commented Aug 7, 2021

@htuch this is the runner for the distrotest lib that we landed previously

@phlax
Copy link
Copy Markdown
Member Author

phlax commented Aug 7, 2021

momentarily reWIPping to rebase and update with newer main code...

Signed-off-by: Ryan Northey <ryan@synca.io>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks good, just a few comments/questions.
/wait


async def run_test(self, name: str, image: str, package: pathlib.Path, rebuild: bool) -> None:
"""Runs a test for each of the packages against a particular distro"""
if self.exiting:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The need to manual check for exiting here feels fragile.

Copy link
Copy Markdown
Member Author

@phlax phlax Aug 8, 2021

Choose a reason for hiding this comment

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

in the scheme of things this is defensive, and not strictly required

self.exiting is True in response to KeyboardInterrupt - which triggers a cleanup, and this opens a very brief window where other coroutines can still be running - this basically prevents it starting a new test during that window, which would send a notification to the docker api to build or start a container

i think we can ~safely remove, but in the rare occasion that this is hit, it would just make keyboard exiting slower

i think i would rather keep, but ambivalent enough to change it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i have left for now, lmk if that is a blocker

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there no way to add a co-routine start hook to do this more generically? I'm just a little concerned that we have to do this by hand. The reason why it is done makes sense.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

if you mean some kind of mechanism to prevent any new coroutines being fired, that would be closing the loop

we dont want to close the loop here, we want to let any existing coroutines run or get caught and we want any cleanup to occur (in fact we sometimes even need to start a new loop to do so)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm just a little concerned that we have to do this by hand. The reason why it is done makes sense.

yep, to summarize - we are running asychronously and communicating with a rest API that uses a lot of system resources

Copy link
Copy Markdown
Member Author

@phlax phlax Aug 11, 2021

Choose a reason for hiding this comment

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

as a general point working with asyncio its better to have a routine/loop that knows how to exit gracefully when it should, than to have routine that forces cancellation/closure on exit

a good example of this is the submit_task in the parallel pr

in my initial implementation in its cancel method i had

self.submit_task.cancel()
try:
    await self.submit_task
except asyncio.CancellationError:
    # not always hit - deps on timing of tasks created by submit_task
    pass

Nothing i could do seemingly would prevent it from sometimes raising the cancellation error

Then i added a closing lock and told the submit_task to bail gracefully when locked and replaced above code with simply

await self.submit_task

and everything was happy

Copy link
Copy Markdown
Member Author

@phlax phlax Aug 11, 2021

Choose a reason for hiding this comment

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

one thing im wondering from this discussion - whether in the case of async checkers the exiting prop should use an asyncio.Lock

the asyncio locks are not thread-safe (and dont need to be) so its not immediately clear what the advantages of using the asyncio sync primitives are

from my testing it seems like they offer a better guarantee of synchronization in terms of ordering of coroutine execution - so my ~guess is that they are run with higher priority than normal tasks

they can also be used synchronously so we could theoretially just use it for all checkers albeit slightly differently altho im a little uncomfortable with using anything asyncio in non-async code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

actually Lock cant be used synchronously, just queue

Signed-off-by: Ryan Northey <ryan@synca.io>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo the exiting discussion.

@@ -0,0 +1,227 @@
#!/usr/bin/env python3

#
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Python purist might ask for docstring syntax here. I don't feel that strongly (I think I've been using docstring elsewhere FWIW).

Copy link
Copy Markdown
Member Author

@phlax phlax Aug 11, 2021

Choose a reason for hiding this comment

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

ive done it this way in all of the other modules - i forget the reason why now - but this is at least consistent with them (copypasta)

as an aside - ive only included -h and deps instructions up here - i thought about this quite a bit - and came to the conclusion that to do anything else for all these runners/checkers would create a maintenance/review headache

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants