Skip to content

Commit

Permalink
Merge pull request #7575 from omerap12/logging-patch
Browse files Browse the repository at this point in the history
fix: remove newlines from VPA recommendations
  • Loading branch information
k8s-ci-robot authored Dec 6, 2024
2 parents c88f72f + 55b2b1e commit a994301
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ func (calc *UpdatePriorityCalculator) GetProcessedRecommendationTargets(r *vpa_t
sb.WriteString(fmt.Sprintf("%vm;", cr.UncappedTarget.Cpu().MilliValue()))
}
}
sb.WriteString("\n")
}
return sb.String()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,60 @@ func TestAddPodLogs(t *testing.T) {
{
name: "container with target and uncappedTarget",
givenRec: test.Recommendation().WithContainer(containerName).WithTarget("4", "10M").Get(),
expectedLog: "container1: target: 10000k 4000m; uncappedTarget: 10000k 4000m;\n",
expectedLog: "container1: target: 10000k 4000m; uncappedTarget: 10000k 4000m;",
},
{
name: "container with cpu only",
givenRec: test.Recommendation().WithContainer(containerName).WithTarget("8", "").Get(),
expectedLog: "container1: target: 8000m; uncappedTarget: 8000m;\n",
expectedLog: "container1: target: 8000m; uncappedTarget: 8000m;",
},
{
name: "container with memory only",
givenRec: test.Recommendation().WithContainer(containerName).WithTarget("", "10M").Get(),
expectedLog: "container1: target: 10000k uncappedTarget: 10000k \n",
expectedLog: "container1: target: 10000k uncappedTarget: 10000k ",
},
{
name: "multi-container with different resources",
givenRec: &vpa_types.RecommendedPodResources{
ContainerRecommendations: []vpa_types.RecommendedContainerResources{
{
ContainerName: "container-1",
Target: test.Resources("4", "10M"),
},
{
ContainerName: "container-2",
Target: test.Resources("8", ""),
},
{
ContainerName: "container-3",
Target: test.Resources("", "10m"),
},
},
},
expectedLog: "container-1: target: 10000k 4000m; container-2: target: 8000m; container-3: target: 1k ",
},
{
name: "multi-containers with uncappedTarget",
givenRec: &vpa_types.RecommendedPodResources{
ContainerRecommendations: []vpa_types.RecommendedContainerResources{
{
ContainerName: "container-1",
Target: test.Resources("4", "10M"),
UncappedTarget: test.Resources("4", "10M"),
},
{
ContainerName: "container-2",
Target: test.Resources("8", ""),
UncappedTarget: test.Resources("8", ""),
},
{
ContainerName: "container-3",
Target: test.Resources("", "10m"),
UncappedTarget: test.Resources("", "10m"),
},
},
},
expectedLog: "container-1: target: 10000k 4000m; uncappedTarget: 10000k 4000m;container-2: target: 8000m; uncappedTarget: 8000m;container-3: target: 1k uncappedTarget: 1k ",
},
}
for _, tc := range testCases {
Expand Down

0 comments on commit a994301

Please sign in to comment.