use version.Program

Signed-off-by: Chris Kim <oats87g@gmail.com>
This commit is contained in:
Chris Kim 2020-12-09 12:32:27 -08:00
parent 48925fcb88
commit 61ef2ce95e

View File

@ -11,6 +11,7 @@ import (
"github.com/opencontainers/runc/libcontainer/system" "github.com/opencontainers/runc/libcontainer/system"
"github.com/rancher/k3s/pkg/daemons/config" "github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/daemons/executor" "github.com/rancher/k3s/pkg/daemons/executor"
"github.com/rancher/k3s/pkg/version"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/net"
"k8s.io/component-base/logs" "k8s.io/component-base/logs"
@ -20,8 +21,6 @@ import (
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration _ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration
) )
const k3sCgroupRoot = "/k3s"
func Agent(config *config.Agent) error { func Agent(config *config.Agent) error {
rand.Seed(time.Now().UTC().UnixNano()) rand.Seed(time.Now().UTC().UnixNano())
@ -210,7 +209,7 @@ func checkCgroups() (kubeletRoot, runtimeRoot string, hasCFS, hasPIDs bool) {
last := parts[len(parts)-1] last := parts[len(parts)-1]
i := strings.LastIndex(last, ".scope") i := strings.LastIndex(last, ".scope")
if i > 0 { if i > 0 {
kubeletRoot = k3sCgroupRoot kubeletRoot = "/" + version.Program
} }
} }
} }
@ -238,8 +237,8 @@ func checkCgroups() (kubeletRoot, runtimeRoot string, hasCFS, hasPIDs bool) {
if system == "name=systemd" { if system == "name=systemd" {
last := parts[len(parts)-1] last := parts[len(parts)-1]
if last != "/" && last != "/init.scope" { if last != "/" && last != "/init.scope" {
kubeletRoot = k3sCgroupRoot kubeletRoot = "/" + version.Program
runtimeRoot = k3sCgroupRoot runtimeRoot = "/" + version.Program
} }
} }
} }