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_containerd.go
58 lines (52 loc) · 1.71 KB
/
binary_containerd.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
// 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) extractContainerd() error {
glog.V(2).Infof("Extracting %s", e.binaryContainerd.archivePath)
b, err := exec.Command("tar", "-C", e.binABSPath, "-xzvf", e.binaryContainerd.archivePath, "--strip-components=1").CombinedOutput()
output := string(b)
if err != nil {
glog.Errorf("Cannot untar %s, %s: %v", e.binaryEtcd.archivePath, output, err)
_ = e.binaryContainerd.removeArchive()
return err
}
_, err = os.Stat(e.binaryContainerd.binaryABSPath)
if err != nil {
glog.Errorf("Unexpected error: %v after untar %s", err, output)
return err
}
glog.V(2).Infof("Successfully untar %s: %s", e.binaryContainerd.archivePath, output)
return err
}
func (e *Environment) setupBinaryContainerd() error {
if e.containerRuntimeInterface != config.CRIContainerd {
glog.V(2).Infof("Skipping the download of containerd: using %q", e.containerRuntimeInterface)
return nil
}
_, err := os.Stat(e.binaryContainerd.binaryABSPath)
if err == nil && e.binaryContainerd.isUpToDate() {
glog.V(4).Infof("Containerd already setup and up to date: %s", e.binaryContainerd.binaryABSPath)
return nil
}
err = e.binaryContainerd.download()
if err != nil {
return err
}
err = e.extractContainerd()
if err != nil {
return err
}
if !e.binaryContainerd.isUpToDate() {
return fmt.Errorf("containerd %s is outdated", e.binaryEtcd.binaryABSPath)
}
return nil
}