Skip to content

Commit a587c55

Browse files
authored
Merge pull request #7669 from jbartosik/rm-dead-code
Remove an unused function and fix a comment
2 parents 998e45a + 87b234f commit a587c55

File tree

2 files changed

+1
-67
lines changed

2 files changed

+1
-67
lines changed

vertical-pod-autoscaler/pkg/recommender/model/types.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ func ResourceNamesApiToModel(resources []apiv1.ResourceName) *[]ResourceName {
125125
return &result
126126
}
127127

128-
// RoundResourceAmount returns the given resource amount rounded down to the
129-
// whole multiple of another resource amount (unit).
130-
func RoundResourceAmount(amount, unit ResourceAmount) ResourceAmount {
131-
return ResourceAmount(int64(amount) - int64(amount)%int64(unit))
132-
}
133-
134128
// ResourceAmountMax returns the larger of two resource amounts.
135129
func ResourceAmountMax(amount1, amount2 ResourceAmount) ResourceAmount {
136130
if amount1 > amount2 {
@@ -149,7 +143,7 @@ func resourceAmountFromFloat(amount float64) ResourceAmount {
149143
}
150144
}
151145

152-
// HumanizeMemoryQuantity converts raw bytes to human-readable string using binary units (KiB, MiB, GiB, TiB) with no decimal places.
146+
// HumanizeMemoryQuantity converts raw bytes to human-readable string using binary units (KiB, MiB, GiB, TiB) with two decimal places.
153147
func HumanizeMemoryQuantity(bytes int64) string {
154148
const (
155149
KiB = 1024

vertical-pod-autoscaler/pkg/recommender/model/types_test.go

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -609,66 +609,6 @@ func TestResourceNamesApiToModel(t *testing.T) {
609609
}
610610
}
611611

612-
type RoundResourceAmountsTestCase struct {
613-
name string
614-
resources Resources
615-
want Resources
616-
}
617-
618-
func TestRoundResourceAmounts(t *testing.T) {
619-
tc := []RoundResourceAmountsTestCase{
620-
{
621-
name: "should round down CPU and memory",
622-
resources: Resources{
623-
ResourceCPU: ResourceAmount(4500), // 4.5 CPU cores
624-
ResourceMemory: ResourceAmount(7168), // 7168MB memory
625-
},
626-
want: Resources{
627-
ResourceCPU: ResourceAmount(4000), // Round down to 4.0 CPU cores
628-
ResourceMemory: ResourceAmount(7000), // Round down to 7000MB
629-
},
630-
},
631-
{
632-
name: "exact multiples should remain unchanged",
633-
resources: Resources{
634-
ResourceCPU: ResourceAmount(2000), // 2.0 CPU cores
635-
ResourceMemory: ResourceAmount(4000), // 4000MB memory
636-
},
637-
want: Resources{
638-
ResourceCPU: ResourceAmount(2000), // Should remain 2.0
639-
ResourceMemory: ResourceAmount(4000), // Should remain 4000
640-
},
641-
},
642-
{
643-
name: "small values should round to zero",
644-
resources: Resources{
645-
ResourceCPU: ResourceAmount(499), // 0.499 CPU cores
646-
ResourceMemory: ResourceAmount(999), // 999MB memory
647-
},
648-
want: Resources{
649-
ResourceCPU: ResourceAmount(0), // Round down to 0
650-
ResourceMemory: ResourceAmount(0), // Round down to 0
651-
},
652-
},
653-
{
654-
name: "empty resources should remain empty",
655-
resources: Resources{},
656-
want: Resources{},
657-
},
658-
}
659-
660-
for _, tc := range tc {
661-
t.Run(tc.name, func(t *testing.T) {
662-
result := tc.resources
663-
for resource, amount := range result {
664-
// Assuming unit of 1000 for both CPU and Memory
665-
result[resource] = RoundResourceAmount(amount, 1000)
666-
}
667-
assert.Equal(t, tc.want, result)
668-
})
669-
}
670-
}
671-
672612
type ResourceAmountFromFloatTestCase struct {
673613
name string
674614
amount float64

0 commit comments

Comments
 (0)