summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-27 12:16:28 +0100
committerGitHub <noreply@github.com>2020-10-27 12:16:28 +0100
commit5c0849534d7bed20ec588d8ec0099a8b60df7e25 (patch)
tree1e8e2a60c1fa0f0c3f7a4743ddb0268e5d53c963 /pkg/util
parentdbbd5987fde0547305bc42a27d355d2de9e08dd3 (diff)
parent32af1be01a37362d81baff47a2bb28e4c863a8c9 (diff)
downloadpodman-5c0849534d7bed20ec588d8ec0099a8b60df7e25.tar.gz
podman-5c0849534d7bed20ec588d8ec0099a8b60df7e25.tar.bz2
podman-5c0849534d7bed20ec588d8ec0099a8b60df7e25.zip
Merge pull request #8094 from rhatdan/cidfile
The cidfile should be created when the container is created
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/utils.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index 91aba9fa7..a9aad657d 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -638,3 +638,18 @@ func ValidateSysctls(strSlice []string) (map[string]string, error) {
func DefaultContainerConfig() *config.Config {
return containerConfig
}
+
+func CreateCidFile(cidfile string, id string) error {
+ cidFile, err := OpenExclusiveFile(cidfile)
+ if err != nil {
+ if os.IsExist(err) {
+ return errors.Errorf("container id file exists. Ensure another container is not using it or delete %s", cidfile)
+ }
+ return errors.Errorf("error opening cidfile %s", cidfile)
+ }
+ if _, err = cidFile.WriteString(id); err != nil {
+ logrus.Error(err)
+ }
+ cidFile.Close()
+ return nil
+}