forked from argoproj/argo-workflows
/
kubelet.go
59 lines (48 loc) · 1.52 KB
/
kubelet.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
package kubelet
import (
"io"
log "github.com/sirupsen/logrus"
"github.com/argoproj/argo/errors"
)
type KubeletExecutor struct {
cli *kubeletClient
}
func NewKubeletExecutor() (*KubeletExecutor, error) {
log.Infof("Creating a kubelet executor")
cli, err := newKubeletClient()
if err != nil {
return nil, errors.InternalWrapError(err)
}
return &KubeletExecutor{
cli: cli,
}, nil
}
func (k *KubeletExecutor) GetFileContents(containerID string, sourcePath string) (string, error) {
return "", errors.Errorf(errors.CodeNotImplemented, "GetFileContents() is not implemented in the kubelet executor.")
}
func (k *KubeletExecutor) CopyFile(containerID string, sourcePath string, destPath string) error {
return errors.Errorf(errors.CodeNotImplemented, "CopyFile() is not implemented in the kubelet executor.")
}
func (k *KubeletExecutor) GetOutputStream(containerID string, combinedOutput bool) (io.ReadCloser, error) {
if !combinedOutput {
log.Warn("non combined output unsupported")
}
return k.cli.GetLogStream(containerID)
}
func (k *KubeletExecutor) WaitInit() error {
return nil
}
// Wait for the container to complete
func (k *KubeletExecutor) Wait(containerID string) error {
return k.cli.WaitForTermination(containerID, 0)
}
// Kill kills a list of containerIDs first with a SIGTERM then with a SIGKILL after a grace period
func (k *KubeletExecutor) Kill(containerIDs []string) error {
for _, containerID := range containerIDs {
err := k.cli.KillGracefully(containerID)
if err != nil {
return err
}
}
return nil
}