mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
daemon: read-copy-update the daemon config
Ensure data-race-free access to the daemon configuration without locking by mutating a deep copy of the config and atomically storing a pointer to the copy into the daemon-wide configStore value. Any operations which need to read from the daemon config must capture the configStore value only once and pass it around to guarantee a consistent view of the config. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
@@ -19,16 +19,18 @@ func TestGetInspectData(t *testing.T) {
|
||||
}
|
||||
|
||||
d := &Daemon{
|
||||
linkIndex: newLinkIndex(),
|
||||
configStore: &config.Config{},
|
||||
linkIndex: newLinkIndex(),
|
||||
}
|
||||
if d.UsesSnapshotter() {
|
||||
t.Skip("does not apply to containerd snapshotters, which don't have RWLayer set")
|
||||
}
|
||||
_, err := d.getInspectData(c)
|
||||
cfg := &config.Config{}
|
||||
d.configStore.Store(cfg)
|
||||
|
||||
_, err := d.getInspectData(cfg, c)
|
||||
assert.Check(t, is.ErrorContains(err, "RWLayer of container inspect-me is unexpectedly nil"))
|
||||
|
||||
c.Dead = true
|
||||
_, err = d.getInspectData(c)
|
||||
_, err = d.getInspectData(cfg, c)
|
||||
assert.Check(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user