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

fix: update chunkmap suffix #619

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion misc/snapshotter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FROM base AS kubectl-sourcer
ARG TARGETARCH

RUN apk add -q --no-cache curl && \
curl -fsSL -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/"$(curl -L -s https://dl.k8s.io/release/stable.txt)"/bin/linux/"$TARGETARCH"/kubectl && \
curl -fsSL -o /usr/bin/kubectl https://dl.k8s.io/release/"$(curl -L -s https://dl.k8s.io/release/stable.txt)"/bin/linux/"$TARGETARCH"/kubectl && \
chmod +x /usr/bin/kubectl

FROM base
Expand Down
10 changes: 6 additions & 4 deletions pkg/cache/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ func (m *Manager) CacheUsage(ctx context.Context, blobID string) (snapshots.Usag
var usage snapshots.Usage

blobCachePath := path.Join(m.cacheDir, blobID)
blobChunkMap := path.Join(m.cacheDir, blobID+chunkMapFileSuffix)
// For backward compatibility
blobCacheSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix)
blobChunkMap := path.Join(m.cacheDir, blobID+chunkMapFileSuffix)
blobChunkMapSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix+chunkMapFileSuffix)
blobMeta := path.Join(m.cacheDir, blobID+metaFileSuffix)
imageDisk := path.Join(m.cacheDir, blobID+imageDiskFileSuffix)
layerDisk := path.Join(m.cacheDir, blobID+layerDiskFileSuffix)

stuffs := []string{blobCachePath, blobCacheSuffixedPath, blobChunkMap, blobMeta, imageDisk, layerDisk}
stuffs := []string{blobCachePath, blobChunkMap, blobCacheSuffixedPath, blobChunkMapSuffixedPath, blobMeta, imageDisk, layerDisk}

for _, f := range stuffs {
du, err := fs.DiskUsage(ctx, f)
Expand All @@ -97,14 +98,15 @@ func (m *Manager) CacheUsage(ctx context.Context, blobID string) (snapshots.Usag

func (m *Manager) RemoveBlobCache(blobID string) error {
blobCachePath := path.Join(m.cacheDir, blobID)
blobCacheSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix)
blobChunkMap := path.Join(m.cacheDir, blobID+chunkMapFileSuffix)
blobCacheSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix)
blobChunkMapSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix+chunkMapFileSuffix)
blobMeta := path.Join(m.cacheDir, blobID+metaFileSuffix)
imageDisk := path.Join(m.cacheDir, blobID+imageDiskFileSuffix)
layerDisk := path.Join(m.cacheDir, blobID+layerDiskFileSuffix)

// NOTE: Delete chunk bitmap file before data blob
stuffs := []string{blobChunkMap, blobMeta, blobCachePath, blobCacheSuffixedPath, imageDisk, layerDisk}
stuffs := []string{blobChunkMap, blobChunkMapSuffixedPath, blobMeta, blobCachePath, blobCacheSuffixedPath, imageDisk, layerDisk}

for _, f := range stuffs {
err := os.Remove(f)
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ install::kubectl(){
local temp
temp="$(fs::mktemp "install")"

http::get "$temp"/kubectl "https://storage.googleapis.com/kubernetes-release/release/$version/bin/linux/${GOARCH:-amd64}/kubectl"
http::get "$temp"/kubectl "https://dl.k8s.io/release/$version/bin/linux/${GOARCH:-amd64}/kubectl"
host::install "$temp"/kubectl
}

Expand Down