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 layer locking in CreateContainer #1387

Merged
merged 1 commit into from
Oct 14, 2022

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Oct 14, 2022

  • imageTopLayerForMapping, in the cParentLayer loop, was reading all additional layer stores, although only some of them might have been locked at that point.
  • getAutoUserNSgetMaxSizeFromImage was assuming that all layer stores are locked, but in fact the additional layer stores were all unlocked at that point
  • getMaxSizeFromImage was calling store.getLayerStore() and the like, which could potentially trigger a reload via graphLock and return a different store than the one that was locked

So, lock all layer stores in CreateContainer (at least on the path where images are involved), and pass the locked layer stores down the call stack.

Also, document a bit more explicitly what's going on.

- imageTopLayerForMapping, in the cParentLayer loop, was reading all
  additional layer stores, although only some of them might have been
  locked at that point.
- getAutoUserNS -> getMaxSizeFromImage was assuming that all layer stores
  are locked, but in fact the additional layer stores were all unlocked
  at that point
- getMaxSizeFromImage was calling store.getLayerStore() and the like,
  which could potentially trigger a reload via graphLock and return
  a _different_ store than the one that was locked

So, lock _all_ layer stores in CreateContainer (at least on the path
where images are involved), and pass the locked layer stores down the
call stack.

Also, document a bit more explicitly what's going on.

Signed-off-by: Miloslav Trmač <[email protected]>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Nice catch, LGTM

Copy link
Member

@rhatdan rhatdan left a comment

Choose a reason for hiding this comment

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

LGTM

@rhatdan rhatdan merged commit 8d8d6be into containers:main Oct 14, 2022
@mtrmac
Copy link
Collaborator Author

mtrmac commented Oct 14, 2022

For the record, I would never just find this at staring at the code. (I don’t have that kind of patience and focus, for starters.) This is an outcome of prototyping lock tokens per #1389 .

@mtrmac mtrmac deleted the lock-all-layer-stores branch October 14, 2022 15:17
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