mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-03-02 17:50:34 +00:00
chore: remove refs to deprecated io/ioutil
This commit is contained in:
@@ -18,7 +18,7 @@ package npd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -32,11 +32,11 @@ import (
|
||||
// SetupNPD installs NPD from the test tarball onto the provided GCE instance.
|
||||
//
|
||||
// Here is how it works:
|
||||
// 1. SetupNPD will SCP the NPD build tarball onto the VM.
|
||||
// 2. SetupNPD will extract the tarball in the VM, to expose the test/e2e-install.sh on the VM.
|
||||
// 3. SetupNPD will then call the e2e-install.sh script, and feed the NPD build tarball as input.
|
||||
// 4. Finally, the e2e-install.sh script will do the heavy lifting of installing NPD (setting up
|
||||
// binary/config directories, setting up systemd config file, etc).
|
||||
// 1. SetupNPD will SCP the NPD build tarball onto the VM.
|
||||
// 2. SetupNPD will extract the tarball in the VM, to expose the test/e2e-install.sh on the VM.
|
||||
// 3. SetupNPD will then call the e2e-install.sh script, and feed the NPD build tarball as input.
|
||||
// 4. Finally, the e2e-install.sh script will do the heavy lifting of installing NPD (setting up
|
||||
// binary/config directories, setting up systemd config file, etc).
|
||||
func SetupNPD(ins gce.Instance, npdBuildTar string) error {
|
||||
tmpDirCmd := ins.RunCommand("mktemp -d")
|
||||
if tmpDirCmd.SSHError != nil || tmpDirCmd.Code != 0 {
|
||||
@@ -152,7 +152,7 @@ func saveCommandResultAsArtifact(ins gce.Instance, artifactDirectory string, tes
|
||||
if result.SSHError != nil || result.Code != 0 {
|
||||
return fmt.Errorf("Error running command: %v\n", result)
|
||||
}
|
||||
if err := ioutil.WriteFile(artifactPath, []byte(result.Stdout), 0644); err != nil {
|
||||
if err := os.WriteFile(artifactPath, []byte(result.Stdout), 0644); err != nil {
|
||||
return fmt.Errorf("Error writing artifact to %v: %v\n", artifactPath, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package makers
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
@@ -30,7 +30,7 @@ const ext4ErrorTrigger = "/sys/fs/ext4/sda1/trigger_fs_error"
|
||||
|
||||
func makeFilesystemError() {
|
||||
msg := []byte("fake filesystem error from problem-maker")
|
||||
err := ioutil.WriteFile(ext4ErrorTrigger, msg, 0200)
|
||||
err := os.WriteFile(ext4ErrorTrigger, msg, 0200)
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed writing log to %q: %v", ext4ErrorTrigger, err)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package makers
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
@@ -38,7 +38,7 @@ Killed process 1012 (heapster) total-vm:327128kB, anon-rss:306328kB, file-rss:11
|
||||
|
||||
func writeKernelMessageOrDie(msg string) {
|
||||
for _, line := range strings.Split(msg, "\n") {
|
||||
err := ioutil.WriteFile(kmsgPath, []byte(line), 0644)
|
||||
err := os.WriteFile(kmsgPath, []byte(line), 0644)
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed writing to %q: %v", kmsgPath, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user