mirror of
https://github.com/containers/podman.git
synced 2026-04-04 23:13:34 -04:00
Fix F30-F31 migration for Podman 1.7.0
The earlier attempt to re-add config migration only worked with user-specified configs (podman run --config). This version works more in line with that we want - the first rootless config file will be changed from runc to crun. Verified on my system after an F31 migration - everything seems to be working well. Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
@@ -448,20 +448,27 @@ func NewConfig(userConfigPath string) (*Config, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error reading user config %q", userConfigPath)
|
||||
}
|
||||
if err := cgroupV2Check(userConfigPath, config); err != nil {
|
||||
return nil, errors.Wrapf(err, "error rewriting configuration file %s", userConfigPath)
|
||||
}
|
||||
}
|
||||
|
||||
// Now, check if the user can access system configs and merge them if needed.
|
||||
if configs, err := systemConfigs(); err != nil {
|
||||
return nil, errors.Wrapf(err, "error finding config on system")
|
||||
} else {
|
||||
migrated := false
|
||||
for _, path := range configs {
|
||||
systemConfig, err := readConfigFromFile(path)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error reading system config %q", path)
|
||||
}
|
||||
// Handle CGroups v2 configuration migration.
|
||||
// Migrate only the first config, and do it before
|
||||
// merging.
|
||||
if !migrated {
|
||||
if err := cgroupV2Check(path, systemConfig); err != nil {
|
||||
return nil, errors.Wrapf(err, "error rewriting configuration file %s", userConfigPath)
|
||||
}
|
||||
migrated = true
|
||||
}
|
||||
// Merge the it into the config. Any unset field in config will be
|
||||
// over-written by the systemConfig.
|
||||
if err := config.mergeConfig(systemConfig); err != nil {
|
||||
@@ -564,6 +571,7 @@ func (c *Config) checkCgroupsAndLogger() {
|
||||
// TODO Once runc has support for cgroups, this function should be removed.
|
||||
func cgroupV2Check(configPath string, tmpConfig *Config) error {
|
||||
if !tmpConfig.CgroupCheck && rootless.IsRootless() {
|
||||
logrus.Debugf("Rewriting %s for CGroup v2 upgrade", configPath)
|
||||
cgroupsV2, err := cgroups.IsCgroup2UnifiedMode()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user