Merge pull request #117198 from charles-chenzz/deprecated_function
replace ioutil with os, update doc in kubelet
This commit is contained in:
@@ -91,7 +91,7 @@ func WriteTmpFile(fs utilfs.Filesystem, path string, data []byte) (tmpPath strin
|
||||
}
|
||||
}()
|
||||
|
||||
// Name() will be an absolute path when using utilfs.DefaultFS, because ioutil.TempFile passes
|
||||
// Name() will be an absolute path when using utilfs.DefaultFS, because os.CreateTemp passes
|
||||
// an absolute path to os.Open, and we ensure similar behavior in utilfs.FakeFS for testing.
|
||||
tmpPath = tmpFile.Name()
|
||||
|
||||
|
@@ -293,7 +293,7 @@ func (cgc *containerGC) evictSandboxes(ctx context.Context, evictNonDeletedPods
|
||||
sandboxIDs.Insert(container.PodSandboxId)
|
||||
}
|
||||
|
||||
sandboxesByPod := make(sandboxesByPodUID)
|
||||
sandboxesByPod := make(sandboxesByPodUID, len(sandboxes))
|
||||
for _, sandbox := range sandboxes {
|
||||
podUID := types.UID(sandbox.Metadata.Uid)
|
||||
sandboxInfo := sandboxGCInfo{
|
||||
@@ -301,13 +301,8 @@ func (cgc *containerGC) evictSandboxes(ctx context.Context, evictNonDeletedPods
|
||||
createTime: time.Unix(0, sandbox.CreatedAt),
|
||||
}
|
||||
|
||||
// Set ready sandboxes to be active.
|
||||
if sandbox.State == runtimeapi.PodSandboxState_SANDBOX_READY {
|
||||
sandboxInfo.active = true
|
||||
}
|
||||
|
||||
// Set sandboxes that still have containers to be active.
|
||||
if sandboxIDs.Has(sandbox.Id) {
|
||||
// Set ready sandboxes and sandboxes that still have containers to be active.
|
||||
if sandbox.State == runtimeapi.PodSandboxState_SANDBOX_READY || sandboxIDs.Has(sandbox.Id) {
|
||||
sandboxInfo.active = true
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -407,7 +406,7 @@ func TestReadLogsLimitsWithTimestamps(t *testing.T) {
|
||||
logLineFmt := "2022-10-29T16:10:22.592603036-05:00 stdout P %v\n"
|
||||
logLineNewLine := "2022-10-29T16:10:22.592603036-05:00 stdout F \n"
|
||||
|
||||
tmpfile, err := ioutil.TempFile("", "log.*.txt")
|
||||
tmpfile, err := os.CreateTemp("", "log.*.txt")
|
||||
assert.NoError(t, err)
|
||||
|
||||
count := 10000
|
||||
|
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package prober
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
@@ -111,7 +111,7 @@ func newTestManager() *manager {
|
||||
// Add test pod to pod manager, so that status manager can get the pod from pod manager if needed.
|
||||
podManager.AddPod(getTestPod())
|
||||
testRootDir := ""
|
||||
if tempDir, err := ioutil.TempDir("", "kubelet_test."); err != nil {
|
||||
if tempDir, err := os.MkdirTemp("", "kubelet_test."); err != nil {
|
||||
return nil
|
||||
} else {
|
||||
testRootDir = tempDir
|
||||
|
@@ -19,9 +19,9 @@ package prober
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
@@ -82,7 +82,7 @@ func TestTCPPortExhaustion(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(fmt.Sprintf(tt.name), func(t *testing.T) {
|
||||
testRootDir := ""
|
||||
if tempDir, err := ioutil.TempDir("", "kubelet_test."); err != nil {
|
||||
if tempDir, err := os.MkdirTemp("", "kubelet_test."); err != nil {
|
||||
t.Fatalf("can't make a temp rootdir: %v", err)
|
||||
} else {
|
||||
testRootDir = tempDir
|
||||
|
@@ -19,7 +19,7 @@ package prober
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -155,7 +155,7 @@ func TestDoProbe(t *testing.T) {
|
||||
|
||||
// Clean up.
|
||||
testRootDir := ""
|
||||
if tempDir, err := ioutil.TempDir("", "kubelet_test."); err != nil {
|
||||
if tempDir, err := os.MkdirTemp("", "kubelet_test."); err != nil {
|
||||
t.Fatalf("can't make a temp rootdir: %v", err)
|
||||
} else {
|
||||
testRootDir = tempDir
|
||||
|
@@ -18,8 +18,8 @@ package status
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -89,7 +89,7 @@ func newTestManager(kubeClient clientset.Interface) *manager {
|
||||
podManager.AddPod(getTestPod())
|
||||
podStartupLatencyTracker := util.NewPodStartupLatencyTracker()
|
||||
testRootDir := ""
|
||||
if tempDir, err := ioutil.TempDir("", "kubelet_test."); err != nil {
|
||||
if tempDir, err := os.MkdirTemp("", "kubelet_test."); err != nil {
|
||||
return nil
|
||||
} else {
|
||||
testRootDir = tempDir
|
||||
|
Reference in New Issue
Block a user