pinned cadvisor to a latest commit

Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
This commit is contained in:
Tarun Pothulapati
2019-08-08 17:56:37 +05:30
parent 6d49d69c91
commit ce31366baf
28 changed files with 165 additions and 525 deletions

View File

@@ -16,7 +16,6 @@ package cloudinfo
import (
"io/ioutil"
"os"
"strings"
"github.com/aws/aws-sdk-go/aws"
@@ -28,9 +27,10 @@ import (
)
const (
productVerFileName = "/sys/class/dmi/id/product_version"
biosVerFileName = "/sys/class/dmi/id/bios_vendor"
amazon = "amazon"
productVerFileName = "/sys/class/dmi/id/product_version"
biosVerFileName = "/sys/class/dmi/id/bios_vendor"
systemdOSReleaseFileName = "/etc/os-release"
amazon = "amazon"
)
func init() {
@@ -42,23 +42,18 @@ type provider struct{}
var _ cloudinfo.CloudProvider = provider{}
func (provider) IsActiveProvider() bool {
var dataProduct []byte
var dataBios []byte
if _, err := os.Stat(productVerFileName); err == nil {
dataProduct, err = ioutil.ReadFile(productVerFileName)
if err != nil {
return false
}
return fileContainsAmazonIdentifier(productVerFileName) ||
fileContainsAmazonIdentifier(biosVerFileName) ||
fileContainsAmazonIdentifier(systemdOSReleaseFileName)
}
func fileContainsAmazonIdentifier(filename string) bool {
fileContent, err := ioutil.ReadFile(filename)
if err != nil {
return false
}
if _, err := os.Stat(biosVerFileName); err == nil {
dataBios, err = ioutil.ReadFile(biosVerFileName)
if err != nil {
return false
}
}
return strings.Contains(string(dataProduct), amazon) || strings.Contains(strings.ToLower(string(dataBios)), amazon)
return strings.Contains(string(fileContent), amazon)
}
func getAwsMetadata(name string) string {

View File

@@ -4,16 +4,15 @@ go_library(
name = "go_default_library",
srcs = [
"conn.go",
"defs.go",
"netlink.go",
"reader.go",
],
cgo = True,
importmap = "k8s.io/kubernetes/vendor/github.com/google/cadvisor/utils/cpuload/netlink",
importpath = "github.com/google/cadvisor/utils/cpuload/netlink",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/golang.org/x/sys/unix:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@@ -1,26 +0,0 @@
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package netlink
/*
#include <linux/taskstats.h>
*/
import "C"
type TaskStats C.struct_taskstats
const (
__TASKSTATS_CMD_MAX = C.__TASKSTATS_CMD_MAX
)

View File

@@ -22,16 +22,7 @@ import (
"syscall"
info "github.com/google/cadvisor/info/v1"
)
const (
// Kernel constants for tasks stats.
genlIdCtrl = syscall.NLMSG_MIN_TYPE // GENL_ID_CTRL
taskstatsGenlName = "TASKSTATS" // TASKSTATS_GENL_NAME
cgroupStatsCmdAttrFd = 0x1 // CGROUPSTATS_CMD_ATTR_FD
ctrlAttrFamilyId = 0x1 // CTRL_ATTR_FAMILY_ID
ctrlAttrFamilyName = 0x2 // CTRL_ATTR_FAMILY_NAME
ctrlCmdGetFamily = 0x3 // CTRL_CMD_GETFAMILY
"golang.org/x/sys/unix"
)
var (
@@ -124,15 +115,15 @@ func prepareMessage(headerType uint16, cmd uint8, attributes []byte) (msg netlin
// Prepares message to query family id for task stats.
func prepareFamilyMessage() (msg netlinkMessage) {
buf := bytes.NewBuffer([]byte{})
addAttribute(buf, ctrlAttrFamilyName, taskstatsGenlName, len(taskstatsGenlName)+1)
return prepareMessage(genlIdCtrl, ctrlCmdGetFamily, buf.Bytes())
addAttribute(buf, unix.CTRL_ATTR_FAMILY_NAME, unix.TASKSTATS_GENL_NAME, len(unix.TASKSTATS_GENL_NAME)+1)
return prepareMessage(unix.GENL_ID_CTRL, unix.CTRL_CMD_GETFAMILY, buf.Bytes())
}
// Prepares message to query task stats for a task group.
func prepareCmdMessage(id uint16, cfd uintptr) (msg netlinkMessage) {
buf := bytes.NewBuffer([]byte{})
addAttribute(buf, cgroupStatsCmdAttrFd, uint32(cfd), 4)
return prepareMessage(id, __TASKSTATS_CMD_MAX+1, buf.Bytes())
addAttribute(buf, unix.CGROUPSTATS_CMD_ATTR_FD, uint32(cfd), 4)
return prepareMessage(id, unix.CGROUPSTATS_CMD_GET, buf.Bytes())
}
// Extracts returned family id from the response.
@@ -158,7 +149,7 @@ func parseFamilyResp(msg syscall.NetlinkMessage) (uint16, error) {
if err != nil {
return 0, err
}
if attr.Type == ctrlAttrFamilyId {
if attr.Type == unix.CTRL_ATTR_FAMILY_ID {
err = binary.Read(buf, Endian, &id)
if err != nil {
return 0, err