2022-03-02 23:47:27 +00:00
|
|
|
//go:build linux
|
2021-06-10 19:27:00 +00:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
2023-10-26 09:51:25 +00:00
|
|
|
"errors"
|
|
|
|
"os"
|
2021-06-10 19:27:00 +00:00
|
|
|
"path/filepath"
|
|
|
|
|
2023-10-26 09:51:25 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/cli/cmds"
|
2022-03-02 23:47:27 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/daemons/config"
|
2023-10-26 09:51:25 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2021-06-10 19:27:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func applyContainerdStateAndAddress(nodeConfig *config.Node) {
|
|
|
|
nodeConfig.Containerd.State = "/run/k3s/containerd"
|
|
|
|
nodeConfig.Containerd.Address = filepath.Join(nodeConfig.Containerd.State, "containerd.sock")
|
|
|
|
}
|
2021-12-16 20:00:40 +00:00
|
|
|
|
|
|
|
func applyCRIDockerdAddress(nodeConfig *config.Node) {
|
|
|
|
nodeConfig.CRIDockerd.Address = "unix:///run/k3s/cri-dockerd/cri-dockerd.sock"
|
|
|
|
}
|
2023-10-26 09:51:25 +00:00
|
|
|
|
2024-02-09 19:28:06 +00:00
|
|
|
func applyContainerdQoSClassConfigFileIfPresent(envInfo *cmds.Agent, containerdConfig *config.Containerd) {
|
|
|
|
containerdConfigDir := filepath.Join(envInfo.DataDir, "agent", "etc", "containerd")
|
|
|
|
|
|
|
|
blockioPath := filepath.Join(containerdConfigDir, "blockio_config.yaml")
|
2023-10-26 09:51:25 +00:00
|
|
|
|
|
|
|
// Set containerd config if file exists
|
2024-02-09 19:28:06 +00:00
|
|
|
if fileInfo, err := os.Stat(blockioPath); !errors.Is(err, os.ErrNotExist) {
|
|
|
|
if fileInfo.Mode().IsRegular() {
|
|
|
|
logrus.Infof("BlockIO configuration file found")
|
|
|
|
containerdConfig.BlockIOConfig = blockioPath
|
|
|
|
}
|
2023-10-26 09:51:25 +00:00
|
|
|
}
|
|
|
|
|
2024-02-09 19:28:06 +00:00
|
|
|
rdtPath := filepath.Join(containerdConfigDir, "rdt_config.yaml")
|
2023-10-26 09:51:25 +00:00
|
|
|
|
|
|
|
// Set containerd config if file exists
|
2024-02-09 19:28:06 +00:00
|
|
|
if fileInfo, err := os.Stat(rdtPath); !errors.Is(err, os.ErrNotExist) {
|
|
|
|
if fileInfo.Mode().IsRegular() {
|
|
|
|
logrus.Infof("RDT configuration file found")
|
|
|
|
containerdConfig.RDTConfig = rdtPath
|
|
|
|
}
|
2023-10-26 09:51:25 +00:00
|
|
|
}
|
|
|
|
}
|