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

cache: fix null pointer access when cachemanager.Disable is true #536

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

jiangliu
Copy link
Contributor

Filesystem.cacheMgr is null when cacheManager.Disable is configured to be true, thus cause null pointer access. Fix it by always create the cacheMgr object no matter cacheManager.Disable is true or false.

@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Merging #536 (fd4be45) into main (0da2966) will decrease coverage by 0.01%.
Report is 1 commits behind head on main.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #536      +/-   ##
==========================================
- Coverage   33.56%   33.56%   -0.01%     
==========================================
  Files          65       65              
  Lines        8175     8176       +1     
==========================================
  Hits         2744     2744              
- Misses       5116     5117       +1     
  Partials      315      315              
Files Changed Coverage Δ
snapshot/snapshot.go 0.00% <0.00%> (ø)

@sctb512
Copy link
Member

sctb512 commented Sep 15, 2023

Why not check if the cacheMgr is nil?
It seems stargzResolver and referrerMgr also have the same problem.

@@ -37,6 +37,7 @@ type Manager struct {
}

type Opt struct {
Disabled bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch! Maybe also update these config.toml:

  • misc/snapshotter/config.toml
  • tests/e2e/k8s/snapshotter-cri.yaml
  • tests/e2e/k8s/snapshotter-kubeconf.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cache_manager.disable is still set to be false for those three files. I'm keeping the configuration item for compatibility though it doesn't take effect. Not sure whether cache_manager.disable will be used to control auto garbage collect in future or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After a second thought, I think we can support recyclebin to keep deleted files for a while. Those configuration item can be used for it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Introducing recyclebin seems to add complexity and doesn't feel necessary, it is better to let kubelet & containerd control the GC policy.

@jiangliu
Copy link
Contributor Author

Why not check if the cacheMgr is nil? It seems stargzResolver and referrerMgr also have the same problem.

With the evolution of nydus-snapshotter, cache manager becomes mandatory instead optional now. On the other hand, stargzResolver and referrerMgr are optional.

Filesystem.cacheMgr is null when cacheManager.Disable is configured
to be true, thus cause null pointer access. Fix it by always create
the cacheMgr object no matter cacheManager.Disable is true or false.

Signed-off-by: Jiang Liu <[email protected]>
Copy link
Member

@sctb512 sctb512 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@changweige changweige left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@changweige changweige left a comment

Choose a reason for hiding this comment

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

LGTM

@changweige changweige merged commit 2cc7d81 into containerd:main Sep 25, 2023
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.

4 participants