Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func getListener(addr string) (net.Listener, error) {
func (s *CriDockerService) Start() error {
// Start the internal service.
if err := s.service.Start(); err != nil {
logrus.Error(err, "Unable to start cri-dockerd service")
logrus.Errorf("Unable to start cri-dockerd service: %v", err)
return err
}

Expand All @@ -93,7 +93,7 @@ func (s *CriDockerService) Start() error {

go func() {
if err := s.server.Serve(l); err != nil {
logrus.Error(err, "Failed to serve connections from cri-dockerd")
logrus.Errorf("Failed to serve connections from cri-dockerd: %v", err)
os.Exit(1)
}
}()
Expand Down
2 changes: 1 addition & 1 deletion config/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (RealOS) Pipe() (r *os.File, w *os.File, err error) {
return os.Pipe()
}

// ReadDir will call ioutil.ReadDir to return the files under the directory.
// ReadDir will call os.ReadDir to return the files under the directory.
func (RealOS) ReadDir(dirname string) ([]os.DirEntry, error) {
return os.ReadDir(dirname)
}
Expand Down
4 changes: 2 additions & 2 deletions containermanager/container_manager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package containermanager

import (
"fmt"
"io/ioutil"
"os"
"regexp"
"strconv"
"time"
Expand Down Expand Up @@ -142,7 +142,7 @@ func createCgroupManager(name string) (cgroups.Manager, error) {

// getMemoryCapacity returns the memory capacity on the machine in bytes.
func getMemoryCapacity() (uint64, error) {
out, err := ioutil.ReadFile("/proc/meminfo")
out, err := os.ReadFile("/proc/meminfo")
if err != nil {
return 0, err
}
Expand Down
4 changes: 2 additions & 2 deletions core/imagefs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (ds *dockerService) imageFsInfo() (*runtimeapi.ImageFsInfoResponse, error)
stat := &syscall.Statfs_t{}
err := syscall.Statfs(ds.dockerRootDir, stat)
if err != nil {
logrus.Error(err, "Failed to get filesystem info for %s", ds.dockerRootDir)
logrus.Errorf("Failed to get filesystem info for %s: %v", ds.dockerRootDir, err)
return nil, err
}
usedBytes := (stat.Blocks - stat.Bfree) * uint64(stat.Bsize)
Expand All @@ -45,7 +45,7 @@ func (ds *dockerService) imageFsInfo() (*runtimeapi.ImageFsInfoResponse, error)
// compute total used bytes by docker images
images, err := ds.client.ListImages(image.ListOptions{All: true, SharedSize: true})
if err != nil {
logrus.Error(err, "Failed to get image list from docker")
logrus.Errorf("Failed to get image list from docker: %v", err)
return nil, err
}
var totalImageSize uint64
Expand Down
4 changes: 2 additions & 2 deletions core/security_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"crypto/md5"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -277,7 +277,7 @@ func getSeccompDockerOpts(seccomp *runtimeapi.SecurityProfile, privileged bool)
fname,
)
}
file, err := ioutil.ReadFile(filepath.FromSlash(fname))
file, err := os.ReadFile(filepath.FromSlash(fname))
if err != nil {
return nil, fmt.Errorf("cannot load seccomp profile %q: %v", fname, err)
}
Expand Down
5 changes: 2 additions & 3 deletions libdocker/kube_docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"regexp"
"sync"
"time"
Expand Down Expand Up @@ -650,10 +649,10 @@ func (d *kubeDockerClient) redirectResponseToOutputStream(
resp io.Reader,
) error {
if outputStream == nil {
outputStream = ioutil.Discard
outputStream = io.Discard
}
if errorStream == nil {
errorStream = ioutil.Discard
errorStream = io.Discard
}
var err error
if tty {
Expand Down
10 changes: 5 additions & 5 deletions network/cni/cni_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

/*
Expand All @@ -22,7 +23,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"net"
"os"
Expand Down Expand Up @@ -327,8 +327,8 @@ func TestCNIPlugin(t *testing.T) {
if err != nil {
t.Errorf("Expected nil: %v", err)
}
eo, eerr := ioutil.ReadFile(outputEnv)
output, err := ioutil.ReadFile(outputFile)
eo, eerr := os.ReadFile(outputEnv)
output, err := os.ReadFile(outputFile)
if err != nil || eerr != nil {
t.Errorf("Failed to read output file %s: %v (env %s err %v)", outputFile, err, eo, eerr)
}
Expand All @@ -350,7 +350,7 @@ func TestCNIPlugin(t *testing.T) {
IPRanges [][]map[string]interface{} `json:"IPRanges"`
} `json:"runtimeConfig"`
}{}
inputBytes, inerr := ioutil.ReadFile(inputFile)
inputBytes, inerr := os.ReadFile(inputFile)
parseerr := json.Unmarshal(inputBytes, &inputConfig)
if inerr != nil || parseerr != nil {
t.Errorf(
Expand Down Expand Up @@ -411,7 +411,7 @@ func TestCNIPlugin(t *testing.T) {
if err != nil {
t.Errorf("Expected nil: %v", err)
}
output, err = ioutil.ReadFile(outputFile)
output, err = os.ReadFile(outputFile)
require.NoError(t, err)
expectedOutput = "DEL /proc/12345/ns/net podNamespace podName test_infra_container"
if string(output) != expectedOutput {
Expand Down
3 changes: 1 addition & 2 deletions network/hairpin/hairpin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package hairpin

import (
"fmt"
"io/ioutil"
"net"
"os"
"path"
Expand Down Expand Up @@ -104,5 +103,5 @@ func setUpInterface(ifName string) error {
return nil
}
hairpinModeFile := path.Join(brportPath, hairpinModeRelativePath)
return ioutil.WriteFile(hairpinModeFile, []byte(hairpinEnable), 0644)
return os.WriteFile(hairpinModeFile, []byte(hairpinEnable), 0644)
}
4 changes: 2 additions & 2 deletions network/kubenet/kubenet_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ package kubenet
import (
"context"
"fmt"
"io/ioutil"
"net"
"os"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -744,7 +744,7 @@ func (plugin *kubenetNetworkPlugin) checkRequiredCNIPlugins() bool {

// checkRequiredCNIPluginsInOneDir returns true if all required cni plugins are placed in dir
func (plugin *kubenetNetworkPlugin) checkRequiredCNIPluginsInOneDir(dir string) bool {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions store/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ type Filesystem interface {
Chtimes(name string, atime time.Time, mtime time.Time) error
RemoveAll(path string) error
Remove(name string) error

// from "io/ioutil"
ReadFile(filename string) ([]byte, error)
TempDir(dir, prefix string) (string, error)
TempFile(dir, prefix string) (File, error)

// from "io/ioutil"
ReadDir(dirname string) ([]os.FileInfo, error)
Walk(root string, walkFn filepath.WalkFunc) error
}
Expand Down
12 changes: 6 additions & 6 deletions store/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ func (DefaultFs) Remove(name string) error {
return os.Remove(name)
}

// ReadFile via ioutil.ReadFile
// ReadFile via os.ReadFile
func (DefaultFs) ReadFile(filename string) ([]byte, error) {
return ioutil.ReadFile(filename)
return os.ReadFile(filename)
}

// TempDir via ioutil.TempDir
// TempDir via os.MkdirTemp
func (DefaultFs) TempDir(dir, prefix string) (string, error) {
return ioutil.TempDir(dir, prefix)
return os.MkdirTemp(dir, prefix)
}

// TempFile via ioutil.TempFile
// TempFile via os.CreateTemp
func (DefaultFs) TempFile(dir, prefix string) (File, error) {
file, err := ioutil.TempFile(dir, prefix)
file, err := os.CreateTemp(dir, prefix)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions streaming/remotecommand/errorstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package remotecommand
import (
"fmt"
"io"
"io/ioutil"

"k8s.io/apimachinery/pkg/util/runtime"
)
Expand All @@ -39,7 +38,7 @@ func watchErrorStream(errorStream io.Reader, d errorStreamDecoder) chan error {
go func() {
defer runtime.HandleCrash()

message, err := ioutil.ReadAll(errorStream)
message, err := io.ReadAll(errorStream)
switch {
case err != nil && err != io.EOF:
errorChan <- fmt.Errorf("error reading from error stream: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion utils/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func WriteCloserWrapper(w io.Writer) io.WriteCloser {
return &writeCloserWrapper{w}
}

// LimitWriter is a copy of the standard library ioutils.LimitReader,
// LimitWriter is a copy of the standard library io.LimitReader,
// applied to the writer interface.
// LimitWriter returns a Writer that writes to w
// but stops with EOF after n bytes.
Expand Down
Loading