Skip to content
Open
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
3 changes: 1 addition & 2 deletions benchmark/pkg/metricsfetcher/scraper/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package scraper

import (
"io/ioutil"
"os"
"reflect"
"testing"
Expand Down Expand Up @@ -76,7 +75,7 @@ func TestGetMetricsForRun(t *testing.T) {
var latencyFilesContents [][]byte
latencyFiles := []string{"APIResponsiveness_testA_xyz123.txt", "APIResponsiveness_testB_xy123c.txt", "PodStartupLatency_testA_xyz123.txt"}
for _, latencyFile := range latencyFiles {
fileContents, err := ioutil.ReadFile(wd + "/test-data/" + latencyFile)
fileContents, err := os.ReadFile(wd + "/test-data/" + latencyFile)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions benchmark/pkg/metricsfetcher/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package util

import (
"fmt"
"io/ioutil"
"io"

"k8s.io/contrib/test-utils/utils"
)
Expand Down Expand Up @@ -84,7 +84,7 @@ func (utils GCSLogUtils) GetJobRunFileContents(job string, run int, filepath str
return nil, fmt.Errorf("couldn't read file from GCS: %v", err)
}
defer response.Body.Close()
return ioutil.ReadAll(response.Body)
return io.ReadAll(response.Body)
}

// ListJobRunFilesWithPrefix returns the list of files with a given path prefix in the job run's root dir.
Expand Down
4 changes: 2 additions & 2 deletions clusterloader2/cmd/clusterloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package main

import (
"fmt"
"io/ioutil"
"net/http"
_ "net/http/pprof"
"os"
"path"
"time"

"gopkg.in/yaml.v2"

corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -448,7 +448,7 @@ func dumpTestConfig(ctx test.Context, config *api.Config) error {
return fmt.Errorf("marshaling config error: %w", err)
}
filePath := path.Join(ctx.GetClusterLoaderConfig().ReportDir, "generatedConfig_"+config.Name+".yaml")
if err := ioutil.WriteFile(filePath, b, 0644); err != nil {
if err := os.WriteFile(filePath, b, 0644); err != nil {
return fmt.Errorf("saving file error: %w", err)
}
klog.Infof("Test config successfully dumped to: %s", filePath)
Expand Down
3 changes: 1 addition & 2 deletions clusterloader2/pkg/config/template_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package config
import (
"fmt"
"io/fs"
"io/ioutil"
"math"
"math/rand"
"os"
Expand Down Expand Up @@ -236,7 +235,7 @@ func includeFile(file interface{}) (string, error) {
}
}
fileStr = os.ExpandEnv(fileStr)
data, err := ioutil.ReadFile(fileStr)
data, err := os.ReadFile(fileStr)
if err != nil {
return "", fmt.Errorf("unable to read file: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions clusterloader2/pkg/config/template_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"bytes"
"fmt"
"io/fs"
"io/ioutil"
"os"
"reflect"
"regexp"
Expand All @@ -32,6 +31,7 @@ import (
template "github.com/google/safetext/yamltemplate"

goerrors "github.com/go-errors/errors"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/perf-tests/clusterloader2/api"
"k8s.io/perf-tests/clusterloader2/pkg/errors"
Expand Down Expand Up @@ -169,7 +169,7 @@ func (tp *TemplateProvider) TemplateInto(path string, mapping map[string]interfa

// LoadTestSuite creates test suite config from file specified by the given path.
func LoadTestSuite(path string) (api.TestSuite, error) {
bin, err := ioutil.ReadFile(path)
bin, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("test suite reading error: %v", err)
}
Expand All @@ -196,7 +196,7 @@ func validateTestSuite(suite api.TestSuite) error {
}

func updateMappingFromFile(mapping map[string]interface{}, path string) error {
bin, err := ioutil.ReadFile(path)
bin, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("test overrides reading error: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package executors
import (
"context"
"fmt"
"io/ioutil"
"os"
"time"

Expand Down Expand Up @@ -65,7 +64,7 @@ func (t *testSeries) seriesLoadingString() string {
}

func loadFromFile(filename string) (*testSeries, error) {
b, err := ioutil.ReadFile(filename)
b, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand All @@ -88,7 +87,7 @@ type PromqlExecutor struct {
// NewPromqlExecutor creates a new executor with time series and rules loaded from file
// Samples loaded from test file starts at time.Time.UTC(0,0)
func NewPromqlExecutor(timeSeriesFile string) (*PromqlExecutor, error) {
//Load time series from file
// Load time series from file
f, err := loadFromFile(timeSeriesFile)
if err != nil {
return nil, fmt.Errorf("could not parse time series file: %v", err)
Expand All @@ -104,7 +103,7 @@ func NewPromqlExecutor(timeSeriesFile string) (*PromqlExecutor, error) {
return nil, fmt.Errorf("could not initialize lazy loader: %v", err)
}

//Load rule groups
// Load rule groups
opts := &rules.ManagerOptions{
QueryFunc: rules.EngineQueryFunc(ll.QueryEngine(), ll.Storage()),
Appendable: ll.Storage(),
Expand All @@ -124,7 +123,7 @@ func NewPromqlExecutor(timeSeriesFile string) (*PromqlExecutor, error) {
return nil, fmt.Errorf("could not load rules file: %v", ers)
}

//Load data into ll
// Load data into ll
ll.WithSamplesTill(time.Now(), func(e error) {
if err != nil {
err = e
Expand Down
5 changes: 2 additions & 3 deletions clusterloader2/pkg/measurement/common/executors/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package executors

import (
"io/ioutil"
"os"

"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -45,7 +44,7 @@ type prometheusRuleManifest struct {
}

func createRulesFile(rulesManifestFile string) (*os.File, error) {
r, err := ioutil.ReadFile(rulesManifestFile)
r, err := os.ReadFile(rulesManifestFile)
if err != nil {
return nil, err
}
Expand All @@ -56,7 +55,7 @@ func createRulesFile(rulesManifestFile string) (*os.File, error) {
return nil, err
}

tempFile, err := ioutil.TempFile("", "")
tempFile, err := os.CreateTemp("", "")
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package metrics
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"sort"
"strconv"
Expand Down Expand Up @@ -57,7 +57,7 @@ func GrabKubeletMetricsWithoutProxy(nodeName, path string) (KubeletMetrics, erro
return KubeletMetrics{}, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return KubeletMetrics{}, err
}
Expand Down
4 changes: 2 additions & 2 deletions clusterloader2/pkg/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package metadata

import (
"encoding/json"
"io/ioutil"
"os"

"k8s.io/perf-tests/clusterloader2/pkg/framework"
)
Expand Down Expand Up @@ -49,5 +49,5 @@ func write(obj map[string]string, outputFile string) error {
if err != nil {
return err
}
return ioutil.WriteFile(outputFile, out, 0644)
return os.WriteFile(outputFile, out, 0644)
}
4 changes: 2 additions & 2 deletions clusterloader2/pkg/prometheus/clients/gcp_managed.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package prom
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand All @@ -45,7 +45,7 @@ func (mpc *gcpManagedPrometheusClient) Query(query string, queryTime time.Time)
return nil, err
}
defer res.Body.Close()
resBody, err := ioutil.ReadAll(res.Body)
resBody, err := io.ReadAll(res.Body)
if statusCode := res.StatusCode; statusCode > 299 {
return resBody, fmt.Errorf("response failed with status code %d", statusCode)
}
Expand Down
4 changes: 2 additions & 2 deletions clusterloader2/pkg/test/simple_test_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package test

import (
"fmt"
"io/ioutil"
"os"
"path"
"strings"
"time"
Expand Down Expand Up @@ -103,7 +103,7 @@ func (ste *simpleExecutor) ExecuteTest(ctx Context, conf *api.Config) *errors.Er
// TODO(krzysied): Remember to keep original filename style for backward compatibility.
fileName := strings.Join([]string{summary.SummaryName(), conf.Name + testDistinctor, summary.SummaryTime().Format(time.RFC3339)}, "_")
filePath := path.Join(ctx.GetClusterLoaderConfig().ReportDir, strings.Join([]string{fileName, summary.SummaryExt()}, "."))
if err := ioutil.WriteFile(filePath, []byte(summary.SummaryContent()), 0644); err != nil {
if err := os.WriteFile(filePath, []byte(summary.SummaryContent()), 0644); err != nil {
errList.Append(fmt.Errorf("writing to file %v error: %v", filePath, err))
continue
}
Expand Down
7 changes: 3 additions & 4 deletions dns/jsonify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -134,7 +133,7 @@ func run() error {
// getFileList returns a list of all files with extension .out.
func getFileList(dir string) ([]string, error) {
var fileNames []string
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return fileNames, err
}
Expand All @@ -149,7 +148,7 @@ func getFileList(dir string) ([]string, error) {

func readBenchmarkResult(path string) (*BenchmarkResult, error) {
var result BenchmarkResult
bin, err := ioutil.ReadFile(path)
bin, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("reading error: %v", err)
}
Expand Down Expand Up @@ -234,5 +233,5 @@ func saveMetric(metric *perftype.PerfData, path string) error {
if err := json.Indent(formatted, output.Bytes(), "", " "); err != nil {
return err
}
return ioutil.WriteFile(path, formatted.Bytes(), 0664)
return os.WriteFile(path, formatted.Bytes(), 0664)
}
7 changes: 4 additions & 3 deletions perfdash/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strconv"
"strings"

Expand Down Expand Up @@ -722,15 +723,15 @@ func urlConfigRead(url string) ([]byte, error) {
return nil, fmt.Errorf("error fetching prow config from %s: %v", url, err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("error reading prow config from %s: %v", url, err)
}
return b, nil
}

func fileConfigRead(path string) ([]byte, error) {
return ioutil.ReadFile(path)
return os.ReadFile(path)
}

func getProwConfig(configPaths []string) (Jobs, error) {
Expand Down
5 changes: 3 additions & 2 deletions perfdash/gcs_metrics_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"io"
"strconv"
"strings"

"cloud.google.com/go/storage"
"google.golang.org/api/iterator"
"google.golang.org/api/option"

"k8s.io/klog"
)

Expand Down Expand Up @@ -137,7 +138,7 @@ func (b *GCSMetricsBucket) ReadFile(job string, buildNumber int, path string) ([
}
defer rc.Close()

data, err := ioutil.ReadAll(rc)
data, err := io.ReadAll(rc)
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions perfdash/github-configs-fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strings"

"gopkg.in/yaml.v2"

"k8s.io/klog"
)

Expand Down Expand Up @@ -72,7 +73,7 @@ func getGithubDirContents(url string) ([]githubDirContent, error) {
if err != nil {
return nil, fmt.Errorf("error calling github API %s: %v", url, err)
}
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("error reading github response %s: %v", url, err)
}
Expand Down
4 changes: 2 additions & 2 deletions perfdash/s3_metrics_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"io"
"strconv"
"strings"

Expand Down Expand Up @@ -117,5 +117,5 @@ func (s *S3MetricsBucket) ReadFile(job string, buildNumber int, path string) ([]
}

defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}
Loading