Skip to content

Commit

Permalink
Merge pull request kubernetes#5613 from hezhizhen/chore
Browse files Browse the repository at this point in the history
Fix typo & replace deprecated functions & replace literals with constants
  • Loading branch information
k8s-ci-robot authored Mar 24, 2023
2 parents b8ba233 + f953f5c commit d91bee9
Show file tree
Hide file tree
Showing 28 changed files with 161 additions and 151 deletions.
2 changes: 1 addition & 1 deletion vertical-pod-autoscaler/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ VPA objects that have been defined with `poc.autoscaling.k8s.io/v1alpha1`
apiVersion. Then use `vpa-up.sh` to bring up the new version of VPA and create
your VPA objects from the scratch, passing apiVersion
`autoscaling.k8s.io/v1beta2` and switching from selector to targetRef, as
described in the prevous section.
described in the previous section.
2 changes: 1 addition & 1 deletion vertical-pod-autoscaler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The current default version is Vertical Pod Autoscaler 0.13.0
remove this API version. While for now you can continue to use `v1beta2` API we
recommend using `autoscaling.k8s.io/v1` instead. `v1` and `v1beta2` APIs are
almost identical (`v1` API has some fields which are not present in `v1beta2)
so simply chaning which API version you're calling should be enough in almost
so simply changing which API version you're calling should be enough in almost
all cases.

### Notice on removal of v1beta1 version (>=0.5.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
**WARNING**
:warning: We no longer intend to implemnt this KEP. Instead we recommend using
:warning: We no longer intend to implement this KEP. Instead we recommend using
[Unhealthy Pod Eviction Policy for PDBs](https://github.com/kubernetes/enhancements/blob/master/keps/sig-apps/3017-pod-healthy-policy-for-pdb/README.md).

# KEP-4902: Delete OOM Pods
Expand Down Expand Up @@ -62,7 +62,7 @@ fit their needs.

## Design Details

When the eviction fails the pod will not just get blindy deleted, but further
When the eviction fails the pod will not just get blindly deleted, but further
checks will occur. Which gives us the following checklist:
- [ ] Was at least one container in the Pod terminated due to being OOM
(`OOMKilled`)?
Expand Down
2 changes: 1 addition & 1 deletion vertical-pod-autoscaler/pkg/admission-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- [Intro](#intro)
- [Running](#running)
- [Implementation](#implmentation)
- [Implementation](#implementation)

## Intro

Expand Down
4 changes: 2 additions & 2 deletions vertical-pod-autoscaler/pkg/admission-controller/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package main

import (
"io/ioutil"
"os"

"k8s.io/klog/v2"
)
Expand All @@ -31,7 +31,7 @@ type certsConfig struct {
}

func readFile(filePath string) []byte {
res, err := ioutil.ReadFile(filePath)
res, err := os.ReadFile(filePath)
if err != nil {
klog.Errorf("Error reading certificate file at %s: %v", filePath, err)
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if [[ $? -ne 0 ]]; then
fi
set -o errexit

# Create a server certiticate
# Create a server certificate
openssl genrsa -out ${TMP_DIR}/serverKey.pem 2048
# Note the CN is the DNS name of the service of the webhook.
openssl req -new -key ${TMP_DIR}/serverKey.pem -out ${TMP_DIR}/server.csr -subj "/CN=vpa-webhook.kube-system.svc" -config ${TMP_DIR}/server.conf -addext "subjectAltName = DNS:vpa-webhook.kube-system.svc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package logic
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"

"k8s.io/api/admission/v1"
Expand Down Expand Up @@ -133,7 +133,7 @@ func (s *AdmissionServer) Serve(w http.ResponseWriter, r *http.Request) {

var body []byte
if r.Body != nil {
if data, err := ioutil.ReadAll(r.Body); err == nil {
if data, err := io.ReadAll(r.Body); err == nil {
body = data
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type PodUpdatePolicy struct {
MinReplicas *int32 `json:"minReplicas,omitempty" protobuf:"varint,2,opt,name=minReplicas"`
}

// UpdateMode controls when autoscaler applies changes to the pod resoures.
// UpdateMode controls when autoscaler applies changes to the pod resources.
// +kubebuilder:validation:Enum=Off;Initial;Recreate;Auto
type UpdateMode string

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type PodUpdatePolicy struct {
UpdateMode *UpdateMode `json:"updateMode,omitempty" protobuf:"bytes,1,opt,name=updateMode"`
}

// UpdateMode controls when autoscaler applies changes to the pod resoures.
// UpdateMode controls when autoscaler applies changes to the pod resources.
type UpdateMode string

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type PodUpdatePolicy struct {
UpdateMode *UpdateMode `json:"updateMode,omitempty" protobuf:"bytes,1,opt,name=updateMode"`
}

// UpdateMode controls when autoscaler applies changes to the pod resoures.
// UpdateMode controls when autoscaler applies changes to the pod resources.
// +kubebuilder:validation:Enum=Off;Initial;Recreate;Auto
type UpdateMode string

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type PodUpdatePolicy struct {
UpdateMode *UpdateMode `json:"updateMode,omitempty" protobuf:"bytes,1,opt,name=updateMode"`
}

// UpdateMode controls when autoscaler applies changes to the pod resoures.
// UpdateMode controls when autoscaler applies changes to the pod resources.
type UpdateMode string

const (
Expand Down
10 changes: 5 additions & 5 deletions vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
v1lister "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
klog "k8s.io/klog/v2"
"k8s.io/klog/v2"
resourceclient "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1"
)

Expand Down Expand Up @@ -310,13 +310,13 @@ func (feeder *clusterStateFeeder) GarbageCollectCheckpoints() {
klog.V(3).Info("Starting garbage collection of checkpoints")
feeder.LoadVPAs()

namspaceList, err := feeder.coreClient.Namespaces().List(context.TODO(), metav1.ListOptions{})
namespaceList, err := feeder.coreClient.Namespaces().List(context.TODO(), metav1.ListOptions{})
if err != nil {
klog.Errorf("Cannot list namespaces. Reason: %+v", err)
return
}

for _, namespaceItem := range namspaceList.Items {
for _, namespaceItem := range namespaceList.Items {
namespace := namespaceItem.Name
checkpointList, err := feeder.vpaCheckpointClient.VerticalPodAutoscalerCheckpoints(namespace).List(context.TODO(), metav1.ListOptions{})
if err != nil {
Expand Down Expand Up @@ -375,7 +375,7 @@ func filterVPAs(feeder *clusterStateFeeder, allVpaCRDs []*vpa_types.VerticalPodA
return vpaCRDs
}

// Fetch VPA objects and load them into the cluster state.
// LoadVPAs fetches VPA objects and loads them into the cluster state.
func (feeder *clusterStateFeeder) LoadVPAs() {
// List VPA API objects.
allVpaCRDs, err := feeder.vpaLister.List(labels.Everything())
Expand Down Expand Up @@ -424,7 +424,7 @@ func (feeder *clusterStateFeeder) LoadVPAs() {
feeder.clusterState.ObservedVpas = vpaCRDs
}

// Load pod into the cluster state.
// LoadPods loads pod into the cluster state.
func (feeder *clusterStateFeeder) LoadPods() {
podSpecs, err := feeder.specClient.GetPodSpecs()
if err != nil {
Expand Down
Loading

0 comments on commit d91bee9

Please sign in to comment.