Skip to content

Commit

Permalink
Change mem value to kilobyte
Browse files Browse the repository at this point in the history
  • Loading branch information
nikimanoledaki committed May 29, 2024
1 parent 390b061 commit 9a57ecd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/sets"
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/annotations"
Expand Down Expand Up @@ -174,7 +175,7 @@ func (calc *UpdatePriorityCalculator) GetProcessedRecommendationTargets(r *vpa_t
if cr.Target != nil {
sb.WriteString("target: ")
if !cr.Target.Memory().IsZero() {
sb.WriteString(fmt.Sprintf("%sK ", cr.Target.Memory().AsDec()))
sb.WriteString(fmt.Sprintf("%dk ", cr.Target.Memory().ScaledValue(resource.Kilo)))
}
if !cr.Target.Cpu().IsZero() {
sb.WriteString(fmt.Sprintf("%vm; ", cr.Target.Cpu().MilliValue()))
Expand All @@ -183,7 +184,7 @@ func (calc *UpdatePriorityCalculator) GetProcessedRecommendationTargets(r *vpa_t
if cr.UncappedTarget != nil {
sb.WriteString("uncappedTarget: ")
if !cr.UncappedTarget.Memory().IsZero() {
sb.WriteString(fmt.Sprintf("%sK ", cr.UncappedTarget.Memory().AsDec()))
sb.WriteString(fmt.Sprintf("%dk ", cr.UncappedTarget.Memory().ScaledValue(resource.Kilo)))
}
if !cr.UncappedTarget.Cpu().IsZero() {
sb.WriteString(fmt.Sprintf("%vm;", cr.UncappedTarget.Cpu().MilliValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ func TestAddPodLogs(t *testing.T) {
{
name: "container with target and uncappedTarget",
givenRec: test.Recommendation().WithContainer(containerName).WithTarget("4", "10M").Get(),
expectedLog: "container1: target: 10000000K 4000m; uncappedTarget: 10000000K 4000m;\n",
expectedLog: "container1: target: 10000k 4000m; uncappedTarget: 10000k 4000m;\n",
},
{
name: "container with cpu only",
Expand All @@ -575,7 +575,7 @@ func TestAddPodLogs(t *testing.T) {
{
name: "container with memory only",
givenRec: test.Recommendation().WithContainer(containerName).WithTarget("", "10M").Get(),
expectedLog: "container1: target: 10000000K uncappedTarget: 10000000K \n",
expectedLog: "container1: target: 10000k uncappedTarget: 10000k \n",
},
}
for _, tc := range testCases {
Expand Down

0 comments on commit 9a57ecd

Please sign in to comment.