Skip to content

Add support for conditional image tarball imports#12237

Merged
brandond merged 1 commit into
k3s-io:masterfrom
brandond:track-imported-files
May 7, 2025
Merged

Add support for conditional image tarball imports#12237
brandond merged 1 commit into
k3s-io:masterfrom
brandond:track-imported-files

Conversation

@brandond

@brandond brandond commented May 2, 2025

Copy link
Copy Markdown
Member

Proposed Changes

Normally K3s will import all tarballs in the image dir on startup, and re-import any tarballs that are created or changed while it is running.

This change allows users to opt into only importing tarballs that have changed since they were last imported, even across restarts.

This behavior is opted into by touching a .cache.json file in the images dir. This file is used to track across restarts the size and mtime of the image files when they are imported.

Types of Changes

enhancement

Verification

  1. mkdir -p /var/lib/rancher/k3s/agent/images/; touch /var/lib/rancher/k3s/agent/images/.cache.json
  2. Copy images into images dir
  3. Start k3s; note that images are imported
  4. Restart k3s; note that images are NOT imported again.
  5. Touch image tarball or replace it with a different file; note that it is imported again.

Testing

Existing tests cover airgap image import

Linked Issues

User-Facing Change


Further Comments

@brandond
brandond requested a review from a team as a code owner May 2, 2025 21:17
@codecov

codecov Bot commented May 2, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 149 lines in your changes missing coverage. Please review.

Project coverage is 19.82%. Comparing base (af51c34) to head (2cb677e).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
pkg/agent/containerd/watcher.go 0.00% 148 Missing ⚠️
pkg/agent/containerd/containerd.go 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (af51c34) and HEAD (2cb677e). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (af51c34) HEAD (2cb677e)
e2etests 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #12237       +/-   ##
===========================================
- Coverage   40.36%   19.82%   -20.54%     
===========================================
  Files         187      184        -3     
  Lines       19211    19136       -75     
===========================================
- Hits         7754     3794     -3960     
- Misses      10273    14912     +4639     
+ Partials     1184      430      -754     
Flag Coverage Δ
e2etests ?
unittests 19.82% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brandond
brandond force-pushed the track-imported-files branch from 45ce4b4 to d0feb20 Compare May 2, 2025 23:12
Normally K3s will import all tarballs in the image dir on startup, and
re-import any tarballs that change while it is running.

This change allows users to opt into only importing tarballs that have
changed since they were last imported, even across restarts.

This behavior is opted into by touching a `.cache.json` file in the
images dir. This file is used to track the size and mtime of the image
files when they are imported.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
@brandond
brandond force-pushed the track-imported-files branch from d0feb20 to 2cb677e Compare May 5, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants