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

Use a persistent container for ov #4491

Merged
merged 5 commits into from
Jun 19, 2024
Merged

Use a persistent container for ov #4491

merged 5 commits into from
Jun 19, 2024

Conversation

sarayourfriend
Copy link
Collaborator

Fixes

Fixes #4490 by @sarayourfriend

Description

Implements the solution described in the issue for using a persistent container to run ov. I've also added support on Linux for running commands as root (macOS already always runs commands in the container as root).

Anecdotally, ov commands do run noticeably faster for me. It's a matter of maybe 50-100ms at most, which is less so faster and moreso just plain responsive feeling. If you happen to notice a change here one way or the other, please let me know. I'm curious to know how fast docker ps is on macOS hosts that have the virtual machine to contend with (my impression is they should be plenty fast?).

Testing Instructions

To test this change:

  1. Run ov clean && ov init to get a brand new environment set up
  2. Make sure things still work, like ov just api/up, ov just api/test, ov nuxt, etc. Just pick some things you'd normally do with the development environment and try them out.
  3. Prove the environment's persistence by running ov sudo dnf update --downloadonly. dnf should list some updates (hopefully some exist) and ask if you want to download them. Respond yes (type y, then return), and let them download. Now run the same command again, and respond yes again. dnf should report that all the packages are already downloaded. If you try the same process on main, the second time dnf will download the packages again, because the container environment was not persisted.

I will make sure the pinged reviewers include at least one macOS user and one Linux user. In doing so, the changes to accommodate sudo exercised in step 3 will be sufficiently tested cross platform.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • [N/A] I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • [N/A] I ran the DAG documentation generator (just catalog/generate-docs for catalog
    PRs) or the media properties generator (just catalog/generate-docs media-props
    for the catalog or just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend added 🟨 priority: medium Not blocking but should be addressed soon 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🧱 stack: infra Related to the Terraform config and other infrastructure labels Jun 14, 2024
@sarayourfriend sarayourfriend requested a review from a team as a code owner June 14, 2024 01:19
@sarayourfriend sarayourfriend changed the title Add/persistent ov Use a persistent container for ov Jun 14, 2024
Copy link
Collaborator

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

Works for me 👍

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

I'm not getting into a formal review because I don't have enough concentration/time but I have a small suggestion.

Comment on lines 63 to 67
COPY entrypoint.sh /entrypoint.sh
# Infinite sleep loop so that we create a persistent environment
# Everything runs in the same container, rather than new one-off containers for each command
ENTRYPOINT /bin/bash -c 'while true; do sleep 1; done;'

ENTRYPOINT ["/entrypoint.sh"]

CMD ["/bin/sh"]
CMD ["/bin/bash"]
Copy link
Member

@dhruvkb dhruvkb Jun 15, 2024

Choose a reason for hiding this comment

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

We can theoretically drop the ENTRYPOINT and CMD directives. The fedora image runs continuously with

docker run -itd fedora
Screenshot 2024-06-15 at 1 54 14 PM

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, good to know! I will remove those entries for sure 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I think I'd rather leave these explicit, both entrypoint and command, because it documents the behaviour we expect without relying on the base image "incidentally" behaving that way. I'd rather explicitly instruct our image to loop and sleep. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I'll leave that up to you then. I personally would like to avoid instructions that can be omitted without altering the end experience but I can also get behind the value of being explicit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've pushed it. Part of why I was reluctant is because I felt the need to explain that we wanted that behaviour, so it was documented in the Dockerfile. It's just as many lines as the explicit implementation, so I don't see a difference, really, but I suppose it's nice to use the default configuration as you said. It just doesn't make anything more concise or easier to understand overall, at least not to me.

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

LGTM, looking forward to faster ov commands!

@sarayourfriend sarayourfriend merged commit b4dd8a5 into main Jun 19, 2024
44 checks passed
@sarayourfriend sarayourfriend deleted the add/persistent-ov branch June 19, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: infra Related to the Terraform config and other infrastructure
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Refactor ov to create a persistent container
3 participants