diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-19 12:05:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 12:05:12 +0200 |
commit | 7e2a1b34c30e085275de1c484dc472682876746c (patch) | |
tree | 6d928baafba52d92475a8afebf07d38de39eb8ce /libpod/runtime.go | |
parent | 9d096c1c4ea5308c94f779444b61015eeef2972a (diff) | |
parent | 5b02b69ea81deb06d5dc0acf2005cb3dbb496d4a (diff) | |
download | podman-7e2a1b34c30e085275de1c484dc472682876746c.tar.gz podman-7e2a1b34c30e085275de1c484dc472682876746c.tar.bz2 podman-7e2a1b34c30e085275de1c484dc472682876746c.zip |
Merge pull request #7311 from QiWang19/service-reload
Support sighup reload configuration files
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r-- | libpod/runtime.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 8a7053e33..1d2e624d8 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -10,6 +10,7 @@ import ( "syscall" "github.com/containers/common/pkg/config" + "github.com/containers/image/v5/pkg/sysregistriesv2" is "github.com/containers/image/v5/storage" "github.com/containers/image/v5/types" "github.com/containers/podman/v2/libpod/define" @@ -17,6 +18,7 @@ import ( "github.com/containers/podman/v2/libpod/image" "github.com/containers/podman/v2/libpod/lock" "github.com/containers/podman/v2/pkg/cgroups" + "github.com/containers/podman/v2/pkg/registries" "github.com/containers/podman/v2/pkg/rootless" "github.com/containers/podman/v2/pkg/util" "github.com/containers/storage" @@ -816,3 +818,50 @@ func (r *Runtime) mergeDBConfig(dbConfig *DBConfig) { func (r *Runtime) EnableLabeling() bool { return r.config.Containers.EnableLabeling } + +// Reload reloads the configurations files +func (r *Runtime) Reload() error { + if err := r.reloadContainersConf(); err != nil { + return err + } + if err := r.reloadStorageConf(); err != nil { + return err + } + if err := reloadRegistriesConf(); err != nil { + return err + } + return nil +} + +// reloadContainersConf reloads the containers.conf +func (r *Runtime) reloadContainersConf() error { + config, err := config.Reload() + if err != nil { + return err + } + r.config = config + logrus.Infof("applied new containers configuration: %v", config) + return nil +} + +// reloadRegistries reloads the registries.conf +func reloadRegistriesConf() error { + sysregistriesv2.InvalidateCache() + registries, err := sysregistriesv2.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: registries.SystemRegistriesConfPath()}) + if err != nil { + return err + } + logrus.Infof("applied new registry configuration: %+v", registries) + return nil +} + +// reloadStorageConf reloads the storage.conf +func (r *Runtime) reloadStorageConf() error { + configFile, err := storage.DefaultConfigFile(rootless.IsRootless()) + if err != nil { + return err + } + storage.ReloadConfigurationFile(configFile, &r.storageConfig) + logrus.Infof("applied new storage configuration: %v", r.storageConfig) + return nil +} |