Rework method of updating atomic-updated data volumes
This change affects the way that secret, configmap, downwardAPI and projected volumes (which all use the same underlying code) implement their data update functionality. * Instead of creating a subdirectory hierarchy that itself will contain symlinks to each actual data file, create only symlinks to items in the root of the volume, whether they be files or directories. * Rather than comparing the user-visible data directory to see if an update is needed, compare with the current version of the data directory. * Fix data dir timestamp format year * Create ..data symlink even when a data volume has no data so consumers can have simplified update watch logic.
This commit is contained in:
@@ -466,13 +466,35 @@ func TestPluginOptional(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
datadirSymlink := path.Join(volumePath, "..data")
|
||||
datadir, err := os.Readlink(datadirSymlink)
|
||||
if err != nil && os.IsNotExist(err) {
|
||||
t.Fatalf("couldn't find volume path's data dir, %s", datadirSymlink)
|
||||
} else if err != nil {
|
||||
t.Fatalf("couldn't read symlink, %s", datadirSymlink)
|
||||
}
|
||||
datadirPath := path.Join(volumePath, datadir)
|
||||
|
||||
infos, err := ioutil.ReadDir(volumePath)
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't find volume path, %s", volumePath)
|
||||
}
|
||||
if len(infos) != 0 {
|
||||
t.Errorf("empty directory, %s, not found", volumePath)
|
||||
for _, fi := range infos {
|
||||
if fi.Name() != "..data" && fi.Name() != datadir {
|
||||
t.Errorf("empty data directory, %s, is not empty. Contains: %s", datadirSymlink, fi.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
infos, err = ioutil.ReadDir(datadirPath)
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't find volume data path, %s", datadirPath)
|
||||
}
|
||||
if len(infos) != 0 {
|
||||
t.Errorf("empty data directory, %s, is not empty. Contains: %s", datadirSymlink, infos[0].Name())
|
||||
}
|
||||
|
||||
doTestCleanAndTeardown(plugin, testPodUID, testVolumeName, volumePath, t)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user