containerd / containerd/overlaybd

Cross-repo refilling is caused by cached fs

Open
#380 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
410
Forks
85
Avg merge
2d 14h
Merged PRs (30d)
10

Description

### What happened in your environment?

```
ICacheStore *ICachePool::open(std::string_view filename, int flags, mode_t mode) {
// ...
auto len = this->fn_trans_func(filename, store_name, sizeof(store_name));
std::string_view store_sv = len ? std::string_view(store_name, len) : filename;
auto ctor = [&]() -> ICacheStore * {
// ...
cache_store->set_src_name(filename);
// ...
};
auto store = cast(m_stores)->acquire(store_sv, ctor);
if (store) {
auto cnt = store->ref_.fetch_add(1, std::memory_order_relaxed);
if (cnt)
cast(m_stores)->release(store_sv);
}
return store;
}
```
If we call `cached_fs->open("/foo/sha256:111")` and `cached_fs->open("/bar/sha256:111")` in sequence, both files will refill from `/foo/sha256:111`. Which means if repository `foo` is deleted at some point, all requests to the layer `sha256:111` will fail. Furthermore, if retries occur frequently, failures may persist indefinitely. (`m_stores` keeps for 10 seconds).

### What did you expect to happen?

The request to `/bar/sha256:111` should succeed or succeed after a retry period.

### How can we reproduce it?

Add following lines at this unit test, which can be used to verify this issue.
```
TEST(CachedFS, fn_trans_func) {
// ...
EXPECT_STREQ("/path_aaa/sha256:test", cs1->get_src_name().data());
EXPECT_STREQ("/path_bbb/sha256:test", cs2->get_src_name().data());
}
```

### What is the version of your Overlaybd?

v1.0.16

### What is your OS environment?

any

### Are you willing to submit PRs to fix it?

- [x] Yes, I am willing to fix it.

Contributor guide

Open the contributing guide

Research direction

Start with ICachePool::open and the CachedFS fn_trans_func unit test shown in the report. Run that test with the added expectations for cs1 and cs2; done means each cached store uses the source path associated with its repository, so the /bar request does not reuse /foo's source.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.