summaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go45
1 files changed, 29 insertions, 16 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index a2279e56d..27885bf5c 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -211,7 +211,7 @@ func newRuntimeFromConfig(ctx context.Context, conf *config.Config, options ...R
os.Exit(1)
return nil
}); err != nil && errors.Cause(err) != shutdown.ErrHandlerExists {
- logrus.Errorf("Error registering shutdown handler for libpod: %v", err)
+ logrus.Errorf("Registering shutdown handler for libpod: %v", err)
}
if err := shutdown.Start(); err != nil {
@@ -344,7 +344,7 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
logrus.Warn(msg)
}
} else {
- logrus.Warn(msg)
+ logrus.Warnf("%s: %v", msg, err)
}
}
}
@@ -388,7 +388,7 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
// Don't forcibly shut down
// We could be opening a store in use by another libpod
if _, err := store.Shutdown(false); err != nil {
- logrus.Errorf("Error removing store for partially-created runtime: %s", err)
+ logrus.Errorf("Removing store for partially-created runtime: %s", err)
}
}
}()
@@ -436,7 +436,7 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
// This will allow us to ship configs including optional
// runtimes that might not be installed (crun, kata).
// Only a infof so default configs don't spec errors.
- logrus.Debugf("configured OCI runtime %s initialization failed: %v", name, err)
+ logrus.Debugf("Configured OCI runtime %s initialization failed: %v", name, err)
continue
}
@@ -706,19 +706,32 @@ func (r *Runtime) TmpDir() (string, error) {
return r.config.Engine.TmpDir, nil
}
-// GetConfig returns a copy of the configuration used by the runtime
-func (r *Runtime) GetConfig() (*config.Config, error) {
+// GetConfig returns the configuration used by the runtime.
+// Note that the returned value is not a copy and must hence
+// only be used in a reading fashion.
+func (r *Runtime) GetConfigNoCopy() (*config.Config, error) {
r.lock.RLock()
defer r.lock.RUnlock()
if !r.valid {
return nil, define.ErrRuntimeStopped
}
+ return r.config, nil
+}
+
+// GetConfig returns a copy of the configuration used by the runtime.
+// Please use GetConfigNoCopy() in case you only want to read from
+// but not write to the returned config.
+func (r *Runtime) GetConfig() (*config.Config, error) {
+ rtConfig, err := r.GetConfigNoCopy()
+ if err != nil {
+ return nil, err
+ }
config := new(config.Config)
// Copy so the caller won't be able to modify the actual config
- if err := JSONDeepCopy(r.config, config); err != nil {
+ if err := JSONDeepCopy(rtConfig, config); err != nil {
return nil, errors.Wrapf(err, "error copying config")
}
@@ -767,7 +780,7 @@ func (r *Runtime) libimageEvents() {
Type: events.Image,
}
if err := r.eventer.Write(e); err != nil {
- logrus.Errorf("unable to write image event: %q", err)
+ logrus.Errorf("Unable to write image event: %q", err)
}
}
@@ -807,11 +820,11 @@ func (r *Runtime) Shutdown(force bool) error {
if force {
ctrs, err := r.state.AllContainers()
if err != nil {
- logrus.Errorf("Error retrieving containers from database: %v", err)
+ logrus.Errorf("Retrieving containers from database: %v", err)
} else {
for _, ctr := range ctrs {
if err := ctr.StopWithTimeout(r.config.Engine.StopTimeout); err != nil {
- logrus.Errorf("Error stopping container %s: %v", ctr.ID(), err)
+ logrus.Errorf("Stopping container %s: %v", ctr.ID(), err)
}
}
}
@@ -833,7 +846,7 @@ func (r *Runtime) Shutdown(force bool) error {
}
if err := r.state.Close(); err != nil {
if lastError != nil {
- logrus.Errorf("%v", lastError)
+ logrus.Error(lastError)
}
lastError = err
}
@@ -879,17 +892,17 @@ func (r *Runtime) refresh(alivePath string) error {
// until this has run.
for _, ctr := range ctrs {
if err := ctr.refresh(); err != nil {
- logrus.Errorf("Error refreshing container %s: %v", ctr.ID(), err)
+ logrus.Errorf("Refreshing container %s: %v", ctr.ID(), err)
}
}
for _, pod := range pods {
if err := pod.refresh(); err != nil {
- logrus.Errorf("Error refreshing pod %s: %v", pod.ID(), err)
+ logrus.Errorf("Refreshing pod %s: %v", pod.ID(), err)
}
}
for _, vol := range vols {
if err := vol.refresh(); err != nil {
- logrus.Errorf("Error refreshing volume %s: %v", vol.Name(), err)
+ logrus.Errorf("Refreshing volume %s: %v", vol.Name(), err)
}
}
@@ -1099,7 +1112,7 @@ func (r *Runtime) reloadContainersConf() error {
return err
}
r.config = config
- logrus.Infof("applied new containers configuration: %v", config)
+ logrus.Infof("Applied new containers configuration: %v", config)
return nil
}
@@ -1110,7 +1123,7 @@ func (r *Runtime) reloadStorageConf() error {
return err
}
storage.ReloadConfigurationFile(configFile, &r.storageConfig)
- logrus.Infof("applied new storage configuration: %v", r.storageConfig)
+ logrus.Infof("Applied new storage configuration: %v", r.storageConfig)
return nil
}