Skip to content

Commit

Permalink
Merge pull request kubernetes#5897 from jbartosik/revert-subresource
Browse files Browse the repository at this point in the history
Revert "Add subresource status for vpa"
  • Loading branch information
jbartosik authored Jun 28, 2023
2 parents 1dd1e3d + b24a41d commit 1c8ec5c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 67 deletions.
26 changes: 1 addition & 25 deletions vertical-pod-autoscaler/deploy/vpa-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ rules:
- get
- list
- watch
- patch
- apiGroups:
- "autoscaling.k8s.io"
resources:
Expand All @@ -52,18 +53,6 @@ rules:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: system:vpa-status-actor
rules:
- apiGroups:
- "autoscaling.k8s.io"
resources:
- verticalpodautoscalers/status
verbs:
- get
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -151,19 +140,6 @@ subjects:
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:vpa-status-actor
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:vpa-status-actor
subjects:
- kind: ServiceAccount
name: vpa-recommender
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:vpa-checkpoint-actor
roleRef:
Expand Down
3 changes: 1 addition & 2 deletions vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ spec:
type: object
served: true
storage: true
subresources:
status: {}
subresources: {}
- deprecated: true
deprecationWarning: autoscaling.k8s.io/v1beta2 API is deprecated
name: v1beta2
Expand Down
19 changes: 1 addition & 18 deletions vertical-pod-autoscaler/e2e/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,23 +372,6 @@ func InstallVPA(f *framework.Framework, vpa *vpa_types.VerticalPodAutoscaler) {
vpaClientSet := getVpaClientSet(f)
_, err := vpaClientSet.AutoscalingV1().VerticalPodAutoscalers(f.Namespace.Name).Create(context.TODO(), vpa, metav1.CreateOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error creating VPA")
// apiserver ignore status in vpa create, so need to update status
if !isStatusEmpty(&vpa.Status) {
if vpa.Status.Recommendation != nil {
PatchVpaRecommendation(f, vpa, vpa.Status.Recommendation)
}
}
}

func isStatusEmpty(status *vpa_types.VerticalPodAutoscalerStatus) bool {
if status == nil {
return true
}

if len(status.Conditions) == 0 && status.Recommendation == nil {
return true
}
return false
}

// InstallRawVPA installs a VPA object passed in as raw json in the test cluster.
Expand All @@ -413,7 +396,7 @@ func PatchVpaRecommendation(f *framework.Framework, vpa *vpa_types.VerticalPodAu
Value: *newStatus,
}})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
_, err = getVpaClientSet(f).AutoscalingV1().VerticalPodAutoscalers(f.Namespace.Name).Patch(context.TODO(), vpa.Name, types.JSONPatchType, bytes, metav1.PatchOptions{}, "status")
_, err = getVpaClientSet(f).AutoscalingV1().VerticalPodAutoscalers(f.Namespace.Name).Patch(context.TODO(), vpa.Name, types.JSONPatchType, bytes, metav1.PatchOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to patch VPA.")
}

Expand Down
19 changes: 1 addition & 18 deletions vertical-pod-autoscaler/e2e/v1beta2/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,23 +360,6 @@ func InstallVPA(f *framework.Framework, vpa *vpa_types.VerticalPodAutoscaler) {
vpaClientSet := getVpaClientSet(f)
_, err := vpaClientSet.AutoscalingV1beta2().VerticalPodAutoscalers(f.Namespace.Name).Create(context.TODO(), vpa, metav1.CreateOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error creating VPA")
// apiserver ignore status in vpa create, so need to update status
if !isStatusEmpty(&vpa.Status) {
if vpa.Status.Recommendation != nil {
PatchVpaRecommendation(f, vpa, vpa.Status.Recommendation)
}
}
}

func isStatusEmpty(status *vpa_types.VerticalPodAutoscalerStatus) bool {
if status == nil {
return true
}

if len(status.Conditions) == 0 && status.Recommendation == nil {
return true
}
return false
}

// InstallRawVPA installs a VPA object passed in as raw json in the test cluster.
Expand All @@ -401,7 +384,7 @@ func PatchVpaRecommendation(f *framework.Framework, vpa *vpa_types.VerticalPodAu
Value: *newStatus,
}})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
_, err = getVpaClientSet(f).AutoscalingV1beta2().VerticalPodAutoscalers(f.Namespace.Name).Patch(context.TODO(), vpa.Name, types.JSONPatchType, bytes, metav1.PatchOptions{}, "status")
_, err = getVpaClientSet(f).AutoscalingV1beta2().VerticalPodAutoscalers(f.Namespace.Name).Patch(context.TODO(), vpa.Name, types.JSONPatchType, bytes, metav1.PatchOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to patch VPA.")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type VerticalPodAutoscalerList struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:storageversion
// +kubebuilder:resource:shortName=vpa
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Mode",type="string",JSONPath=".spec.updatePolicy.updateMode"
// +kubebuilder:printcolumn:name="CPU",type="string",JSONPath=".status.recommendation.containerRecommendations[0].target.cpu"
// +kubebuilder:printcolumn:name="Mem",type="string",JSONPath=".status.recommendation.containerRecommendations[0].target.memory"
Expand Down
6 changes: 3 additions & 3 deletions vertical-pod-autoscaler/pkg/utils/vpa/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ type patchRecord struct {
Value interface{} `json:"value"`
}

func patchVpaStatus(vpaClient vpa_api.VerticalPodAutoscalerInterface, vpaName string, patches []patchRecord) (result *vpa_types.VerticalPodAutoscaler, err error) {
func patchVpa(vpaClient vpa_api.VerticalPodAutoscalerInterface, vpaName string, patches []patchRecord) (result *vpa_types.VerticalPodAutoscaler, err error) {
bytes, err := json.Marshal(patches)
if err != nil {
klog.Errorf("Cannot marshal VPA status patches %+v. Reason: %+v", patches, err)
return
}

return vpaClient.Patch(context.TODO(), vpaName, types.JSONPatchType, bytes, meta.PatchOptions{}, "status")
return vpaClient.Patch(context.TODO(), vpaName, types.JSONPatchType, bytes, meta.PatchOptions{})
}

// UpdateVpaStatusIfNeeded updates the status field of the VPA API object.
Expand All @@ -69,7 +69,7 @@ func UpdateVpaStatusIfNeeded(vpaClient vpa_api.VerticalPodAutoscalerInterface, v
}}

if !apiequality.Semantic.DeepEqual(*oldStatus, *newStatus) {
return patchVpaStatus(vpaClient, vpaName, patches)
return patchVpa(vpaClient, vpaName, patches)
}
return nil, nil
}
Expand Down

0 comments on commit 1c8ec5c

Please sign in to comment.