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

[Backport release-1.28] feat: implement watcher for oci bundles #4428

Merged

Conversation

ricardomaraschini
Copy link
Contributor

Description

Implements an OCI bundle watcher. This allows k0s to load new OCI bundles without requiring a restart of the process. The watcher acts upon Create() or Write() operations happening in the OCI bundles directory and events are debounced with a timeout of 10 seconds.

Fixes # 4316

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

At this stage I have updated k0s locally and created/deleted/updated bundles manually in the OCI bundles directory. I have been checking the results by inspecting the logs (as follow) and with k0s ctr i ls:

root@ec:/usr/local/bin# journalctl -u k0scontroller.service -f | grep -i component=OCIBundleReconciler
Apr 22 10:49:44 ec k0s[2014911]: time="2024-04-22 10:49:44" level=info msg="started to watch events on /var/lib/k0s/images" component=OCIBundleReconciler
Apr 22 10:50:06 ec k0s[2014911]: time="2024-04-22 10:50:06" level=info msg="OCI bundle directory changed, reconciling" component=OCIBundleReconciler
Apr 22 10:50:08 ec k0s[2014911]: time="2024-04-22 10:50:08" level=info msg="Imported image docker.io/library/x:latest" component=OCIBundleReconciler
Apr 22 10:50:28 ec k0s[2014911]: time="2024-04-22 10:50:28" level=info msg="OCI bundle directory changed, reconciling" component=OCIBundleReconciler
Apr 22 10:50:29 ec k0s[2014911]: time="2024-04-22 10:50:29" level=info msg="Imported image docker.io/library/x:latest" component=OCIBundleReconciler
Apr 22 10:51:03 ec k0s[2014911]: time="2024-04-22 10:51:03" level=info msg="OCI bundle directory changed, reconciling" component=OCIBundleReconciler
Apr 22 10:51:04 ec k0s[2014911]: time="2024-04-22 10:51:04" level=info msg="Imported image docker.io/library/y:latest" component=OCIBundleReconciler
Apr 22 10:51:40 ec k0s[2014911]: time="2024-04-22 10:51:40" level=info msg="OCI bundle directory changed, reconciling" component=OCIBundleReconciler
Apr 22 10:51:59 ec k0s[2014911]: time="2024-04-22 10:51:59" level=info msg="Imported image docker.io/library/rhel-9-kubernetes-images-1.29.3:latest" component=OCIBundleReconciler
Apr 22 10:51:59 ec k0s[2014911]: time="2024-04-22 10:51:59" level=info msg="Imported image docker.io/kurl/rhel-7-k8s:1.29.3" component=OCIBundleReconciler
Apr 22 10:51:59 ec k0s[2014911]: time="2024-04-22 10:51:59" level=info msg="Imported image docker.io/library/dockerout-containerd-1.6.28-ubuntu-22.04:latest" component=OCIBundleReconciler

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

ricardomaraschini and others added 9 commits May 15, 2024 17:22
implements an oci bundle watcher. this allows k0s to load new bundles
without requiring a restart of the process. the watcher acts upon create
or write operations happening in the oci bundles directory.

events are debounced with a timeout of 10 seconds.

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
create a function to import a single oci bundle. use it in our watcher.

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Co-authored-by: Tom Wieczorek <twz123@users.noreply.github.com>
Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Co-authored-by: Tom Wieczorek <twz123@users.noreply.github.com>
Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Co-authored-by: Tom Wieczorek <twz123@users.noreply.github.com>
Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Co-authored-by: Tom Wieczorek <twz123@users.noreply.github.com>
Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
@ricardomaraschini ricardomaraschini requested a review from a team as a code owner May 16, 2024 09:03
a function used to create a buffered channel does not exist on v1.6.0.

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Copy link
Member

@twz123 twz123 left a comment

Choose a reason for hiding this comment

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

@twz123 twz123 added the backport/release-1.27 PR that needs to be backported/cherrypicked to release-1.27 branch label May 24, 2024
@twz123 twz123 merged commit 2603d3b into k0sproject:release-1.28 May 24, 2024
75 checks passed
@k0s-bot
Copy link

k0s-bot commented May 24, 2024

Backport failed for release-1.27, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin release-1.27
git worktree add -d .worktree/backport-4428-to-release-1.27 origin/release-1.27
cd .worktree/backport-4428-to-release-1.27
git checkout -b backport-4428-to-release-1.27
ancref=$(git merge-base bace82049e94b28d4ca266dc271452106957e52d b7a919960a4f0edccfe61d27f6b9a5250fb3f780)
git cherry-pick -x $ancref..b7a919960a4f0edccfe61d27f6b9a5250fb3f780

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/worker backport/release-1.27 PR that needs to be backported/cherrypicked to release-1.27 branch component/containerd enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants