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
15 changes: 7 additions & 8 deletions vertical-pod-autoscaler/e2e/utils/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package utils

import (
"crypto/x509"
"io/ioutil"
"os"

"k8s.io/client-go/util/cert"
Expand All @@ -38,7 +37,7 @@ type certContext struct {
// SetupWebhookCert sets up the server cert. For example, user, apiservers and admission webhooks
// can use the cert to prove their identity to the kube-apiserver.
func SetupWebhookCert(namespaceName string) *certContext {
certDir, err := ioutil.TempDir("", "test-e2e-server-cert")
certDir, err := os.MkdirTemp("", "test-e2e-server-cert")
if err != nil {
framework.Failf("Failed to create a temp dir for cert generation %v", err)
}
Expand All @@ -51,11 +50,11 @@ func SetupWebhookCert(namespaceName string) *certContext {
if err != nil {
framework.Failf("Failed to create CA cert for apiserver %v", err)
}
caCertFile, err := ioutil.TempFile(certDir, "ca.crt")
caCertFile, err := os.CreateTemp(certDir, "ca.crt")
if err != nil {
framework.Failf("Failed to create a temp file for ca cert generation %v", err)
}
if err := ioutil.WriteFile(caCertFile.Name(), utils.EncodeCertPEM(signingCert), 0644); err != nil {
if err := os.WriteFile(caCertFile.Name(), utils.EncodeCertPEM(signingCert), 0644); err != nil {
framework.Failf("Failed to write CA cert %v", err)
}
key, err := utils.NewPrivateKey()
Expand All @@ -73,22 +72,22 @@ func SetupWebhookCert(namespaceName string) *certContext {
if err != nil {
framework.Failf("Failed to create cert%v", err)
}
certFile, err := ioutil.TempFile(certDir, "server.crt")
certFile, err := os.CreateTemp(certDir, "server.crt")
if err != nil {
framework.Failf("Failed to create a temp file for cert generation %v", err)
}
keyFile, err := ioutil.TempFile(certDir, "server.key")
keyFile, err := os.CreateTemp(certDir, "server.key")
if err != nil {
framework.Failf("Failed to create a temp file for key generation %v", err)
}
if err = ioutil.WriteFile(certFile.Name(), utils.EncodeCertPEM(signedCert), 0600); err != nil {
if err = os.WriteFile(certFile.Name(), utils.EncodeCertPEM(signedCert), 0600); err != nil {
framework.Failf("Failed to write cert file %v", err)
}
privateKeyPEM, err := keyutil.MarshalPrivateKeyToPEM(key)
if err != nil {
framework.Failf("Failed to marshal key %v", err)
}
if err = ioutil.WriteFile(keyFile.Name(), privateKeyPEM, 0644); err != nil {
if err = os.WriteFile(keyFile.Name(), privateKeyPEM, 0644); err != nil {
framework.Failf("Failed to write key file %v", err)
}
return &certContext{
Expand Down
12 changes: 5 additions & 7 deletions vertical-pod-autoscaler/e2e/utils/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
e2edeploy "k8s.io/kubernetes/test/e2e/framework/deployment"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have the appetite to update these everywhere so we can remove the k8s.io/utils/pointer package from the dependency graph altogether? (less value doing the same for io/ioutil as that's part of the standard lib, but you could do the same there as well if you're starved for dopamine)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change removes the last one, from what I can tell. Which other k8s.io/utils/pointer references are left?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I would expect vertical-pod-autoscaler/e2e/vendor/modules.txt would have been updated when the final in-code reference is removed

)

const (
Expand All @@ -49,8 +49,6 @@ const (
deploymentName = "sample-webhook-deployment"
)

func strPtr(s string) *string { return &s }

// LabelNamespace applies unique label to the namespace.
func LabelNamespace(f *framework.Framework, namespace string) {
client := f.ClientSet
Expand Down Expand Up @@ -107,8 +105,8 @@ func RegisterMutatingWebhookForPod(f *framework.Framework, configName string, ce
Service: &admissionregistrationv1.ServiceReference{
Namespace: namespace,
Name: WebhookServiceName,
Path: strPtr("/mutating-pods-sidecar"),
Port: pointer.Int32Ptr(servicePort),
Path: ptr.To("/mutating-pods-sidecar"),
Port: ptr.To(servicePort),
},
CABundle: certContext.signingCert,
},
Expand Down Expand Up @@ -167,8 +165,8 @@ func newMutatingIsReadyWebhookFixture(f *framework.Framework, certContext *certC
Service: &admissionregistrationv1.ServiceReference{
Namespace: f.Namespace.Name,
Name: WebhookServiceName,
Path: strPtr("/always-deny"),
Port: pointer.Int32Ptr(servicePort),
Path: ptr.To("/always-deny"),
Port: ptr.To(servicePort),
},
CABundle: certContext.signingCert,
},
Expand Down
10 changes: 2 additions & 8 deletions vertical-pod-autoscaler/e2e/v1/actuation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"

"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

appsv1 "k8s.io/api/apps/v1"
autoscaling "k8s.io/api/autoscaling/v1"
Expand Down Expand Up @@ -884,7 +884,7 @@ func testEvictsSingletonPodWhenConfigured(f *framework.Framework, controller *au
WithName("hamster-vpa").
WithNamespace(f.Namespace.Name).
WithTargetRef(controller).
WithMinReplicas(pointer.Int32(1)).
WithMinReplicas(ptr.To(int32(1))).
WithContainer(containerName).
AppendRecommendation(
test.Recommendation().
Expand Down Expand Up @@ -1003,12 +1003,6 @@ func setupPDB(f *framework.Framework, name string, maxUnavailable int) *policyv1
return pdb
}

func getCurrentPodSetForDeployment(c clientset.Interface, d *appsv1.Deployment) PodSet {
podList, err := framework_deployment.GetPodsForDeployment(context.TODO(), c, d)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
return MakePodSet(podList)
}

func createReplicaSetWithRetries(c clientset.Interface, namespace string, obj *appsv1.ReplicaSet) error {
if obj == nil {
return fmt.Errorf("object provided to create is empty")
Expand Down
4 changes: 2 additions & 2 deletions vertical-pod-autoscaler/e2e/v1/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package autoscaling
import (
"context"
"fmt"
"io/ioutil"
"os"
"path"
"testing"
"time"
Expand Down Expand Up @@ -334,7 +334,7 @@ func gatherTestSuiteMetrics() error {
metricsJSON := metricsForE2E.PrintJSON()
if framework.TestContext.ReportDir != "" {
filePath := path.Join(framework.TestContext.ReportDir, "MetricsForE2ESuite_"+time.Now().Format(time.RFC3339)+".json")
if err := ioutil.WriteFile(filePath, []byte(metricsJSON), 0644); err != nil {
if err := os.WriteFile(filePath, []byte(metricsJSON), 0644); err != nil {
return fmt.Errorf("error writing to %q: %v", filePath, err)
}
} else {
Expand Down
5 changes: 0 additions & 5 deletions vertical-pod-autoscaler/e2e/v1/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ package autoscaling
import (
"flag"
"fmt"
"math/rand"
"os"
"testing"
"time"

// Never, ever remove the line with "/ginkgo". Without it,
// the ginkgo test runner will not detect that this
Expand All @@ -36,8 +34,6 @@ import (
"k8s.io/kubernetes/test/utils/image"
)

var viperConfig = flag.String("viper-config", "", "The name of a viper config file (https://github.com/spf13/viper#what-is-viper). All e2e command line parameters can also be configured in such a file. May contain a path and may or may not contain the file suffix. The default is to look for an optional file with `e2e` as base name. If a file is specified explicitly, it must be present.")

// handleFlags sets up all flags and parses the command line.
func handleFlags() {
config.CopyFlags(config.Flags, flag.CommandLine)
Expand Down Expand Up @@ -68,7 +64,6 @@ func TestMain(m *testing.M) {
testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
}

rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())
}

Expand Down
Loading