mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
fix review.
This commit is contained in:
parent
1895eec684
commit
164b89bce4
@ -161,6 +161,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
|
||||
ContainerRuntimeEndpoint: envInfo.ContainerRuntimeEndpoint,
|
||||
}
|
||||
nodeConfig.LocalAddress = localAddress(controlConfig)
|
||||
nodeConfig.Images = "/var/lib/rancher/k3s/agent/images"
|
||||
nodeConfig.AgentConfig.NodeIP = nodeIP
|
||||
nodeConfig.AgentConfig.NodeName = nodeName
|
||||
nodeConfig.AgentConfig.ClusterDNS = controlConfig.ClusterDNS
|
||||
|
@ -1,7 +1,6 @@
|
||||
package containerd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/containerd/containerd"
|
||||
@ -127,15 +126,14 @@ func Run(ctx context.Context, cfg *config.Node) error {
|
||||
}
|
||||
}
|
||||
|
||||
imageDir := "/var/lib/rancher/k3s/agent/images"
|
||||
fileInfo, err := os.Stat(imageDir)
|
||||
fileInfo, err := os.Stat(cfg.Images)
|
||||
if err != nil {
|
||||
logrus.Infof("Cannot find images in %s: %v", imageDir, err)
|
||||
logrus.Infof("Cannot find images in %s: %v", cfg.Images, err)
|
||||
} else {
|
||||
if fileInfo.IsDir() {
|
||||
fileInfos, err := ioutil.ReadDir(imageDir)
|
||||
fileInfos, err := ioutil.ReadDir(cfg.Images)
|
||||
if err != nil {
|
||||
logrus.Infof("Cannot read images in %s: %v", imageDir, err)
|
||||
logrus.Infof("Cannot read images in %s: %v", cfg.Images, err)
|
||||
}
|
||||
client, err := containerd.New(cfg.Containerd.Address)
|
||||
if err != nil {
|
||||
@ -147,14 +145,14 @@ func Run(ctx context.Context, cfg *config.Node) error {
|
||||
|
||||
for _, fileInfo := range fileInfos {
|
||||
if !fileInfo.IsDir() {
|
||||
filePath := filepath.Join(imageDir, fileInfo.Name())
|
||||
fileContent, err := ioutil.ReadFile(filePath)
|
||||
filePath := filepath.Join(cfg.Images, fileInfo.Name())
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
logrus.Errorf("Unable to read %s: %v", filePath, err)
|
||||
continue
|
||||
}
|
||||
logrus.Debugf("Import %s", filePath)
|
||||
_, err = client.Import(ctxContainerD, bytes.NewReader(fileContent))
|
||||
_, err = client.Import(ctxContainerD, file)
|
||||
if err != nil {
|
||||
logrus.Errorf("Unable to import %s: %v", filePath, err)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ type Node struct {
|
||||
FlannelConf string
|
||||
LocalAddress string
|
||||
Containerd Containerd
|
||||
Images string
|
||||
AgentConfig Agent
|
||||
CACerts []byte
|
||||
ServerAddress string
|
||||
|
Loading…
Reference in New Issue
Block a user