This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
binary_runc.go
63 lines (57 loc) · 1.73 KB
/
binary_runc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2018 Datadog, Inc.
package setup
import (
"fmt"
"os"
"os/exec"
"github.com/golang/glog"
"github.com/DataDog/pupernetes/pkg/config"
)
func (e *Environment) extractRunc() error {
glog.V(2).Infof("Copying %s", e.binaryRunc.archivePath)
b, err := exec.Command("cp", "-v", e.binaryRunc.archivePath, e.binaryRunc.binaryABSPath).CombinedOutput()
output := string(b)
if err != nil {
glog.Errorf("Cannot cp %s, %s: %v", e.binaryEtcd.archivePath, output, err)
_ = e.binaryRunc.removeArchive()
return err
}
_, err = os.Stat(e.binaryRunc.binaryABSPath)
if err != nil {
glog.Errorf("Unexpected error: %v after cp %s", err, output)
return err
}
err = os.Chmod(e.binaryRunc.binaryABSPath, 0700)
if err != nil {
glog.Errorf("Cannot chmod +x %s: %v", e.binaryRunc.binaryABSPath, err)
return err
}
glog.V(2).Infof("Successfully cp %s: %s", e.binaryRunc.archivePath, output)
return err
}
func (e *Environment) setupBinaryRunc() error {
if e.containerRuntimeInterface != config.CRIContainerd {
glog.V(2).Infof("Skipping the download of runc: using %q", e.containerRuntimeInterface)
return nil
}
_, err := os.Stat(e.binaryRunc.binaryABSPath)
if err == nil && e.binaryRunc.isUpToDate() {
glog.V(4).Infof("Runc already setup and up to date: %s", e.binaryRunc.binaryABSPath)
return nil
}
err = e.binaryRunc.download()
if err != nil {
return err
}
err = e.extractRunc()
if err != nil {
return err
}
if !e.binaryRunc.isUpToDate() {
return fmt.Errorf("runc %s is outdated", e.binaryEtcd.binaryABSPath)
}
return nil
}