Skip to content

Commit

Permalink
libcontainer/intelrdt: privatize some ids
Browse files Browse the repository at this point in the history
These are not used anywhere outside of the package
(I have also checked the only external user of the package
(github.com/google/cadvisor).

No changes other than changing the case. The following
identifiers are now private:

 * IntelRdtTasks
 * NewLastCmdError
 * NewStats

Brought to you by gorename.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Jun 28, 2021
1 parent 8f8dfc4 commit 0229a77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions libcontainer/intelrdt/intelrdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func NewManager(config *configs.Config, id string, path string) Manager {
}

const (
IntelRdtTasks = "tasks"
intelRdtTasks = "tasks"
)

var (
Expand Down Expand Up @@ -400,7 +400,7 @@ func writeFile(dir, file, data string) error {
return fmt.Errorf("no such directory for %s", file)
}
if err := ioutil.WriteFile(filepath.Join(dir, file), []byte(data+"\n"), 0o600); err != nil {
return NewLastCmdError(fmt.Errorf("intelrdt: unable to write %v: %w", data, err))
return newLastCmdError(fmt.Errorf("intelrdt: unable to write %v: %w", data, err))
}
return nil
}
Expand Down Expand Up @@ -501,13 +501,13 @@ func getLastCmdStatus() (string, error) {
// WriteIntelRdtTasks writes the specified pid into the "tasks" file
func WriteIntelRdtTasks(dir string, pid int) error {
if dir == "" {
return fmt.Errorf("no such directory for %s", IntelRdtTasks)
return fmt.Errorf("no such directory for %s", intelRdtTasks)
}

// Don't attach any pid if -1 is specified as a pid
if pid != -1 {
if err := ioutil.WriteFile(filepath.Join(dir, IntelRdtTasks), []byte(strconv.Itoa(pid)), 0o600); err != nil {
return NewLastCmdError(fmt.Errorf("intelrdt: unable to add pid %d: %w", pid, err))
if err := ioutil.WriteFile(filepath.Join(dir, intelRdtTasks), []byte(strconv.Itoa(pid)), 0o600); err != nil {
return newLastCmdError(fmt.Errorf("intelrdt: unable to add pid %d: %w", pid, err))
}
}
return nil
Expand Down Expand Up @@ -593,7 +593,7 @@ func (m *intelRdtManager) GetStats() (*Stats, error) {

m.mu.Lock()
defer m.mu.Unlock()
stats := NewStats()
stats := newStats()

rootPath, err := getIntelRdtRoot()
if err != nil {
Expand Down Expand Up @@ -750,7 +750,7 @@ func (m *intelRdtManager) Set(container *configs.Config) error {
func (raw *intelRdtData) join(id string) (string, error) {
path := filepath.Join(raw.root, id)
if err := os.MkdirAll(path, 0o755); err != nil {
return "", NewLastCmdError(err)
return "", newLastCmdError(err)
}

if err := WriteIntelRdtTasks(path, raw.pid); err != nil {
Expand All @@ -759,7 +759,7 @@ func (raw *intelRdtData) join(id string) (string, error) {
return path, nil
}

func NewLastCmdError(err error) error {
func newLastCmdError(err error) error {
status, err1 := getLastCmdStatus()
if err1 == nil {
return fmt.Errorf("%w, last_cmd_status: %s", err, status)
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/intelrdt/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ type Stats struct {
CMTStats *[]CMTNumaNodeStats `json:"cmt_stats,omitempty"`
}

func NewStats() *Stats {
func newStats() *Stats {
return &Stats{}
}

0 comments on commit 0229a77

Please sign in to comment.