mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-12-12 05:12:39 +00:00
endpointslice: reduce visibility of vars/funcs
Reduce the visibility of various public identifiers that are only used within the scope of a package. This was originally motivated by KEP-3685 in order to reduce the public API surface and improve supportability.
This commit is contained in:
@@ -128,7 +128,7 @@ func redistributeHints(slices []*discovery.EndpointSlice, givingZones, receiving
|
||||
// give to other zones along with the number of endpoints each zone should
|
||||
// receive from other zones. This is calculated with the provided allocations
|
||||
// (desired state) and allocatedHintsByZone (current state).
|
||||
func getGivingAndReceivingZones(allocations map[string]Allocation, allocatedHintsByZone map[string]int) (map[string]int, map[string]int) {
|
||||
func getGivingAndReceivingZones(allocations map[string]allocation, allocatedHintsByZone map[string]int) (map[string]int, map[string]int) {
|
||||
// 1. Determine the precise number of additional endpoints each zone has
|
||||
// (giving) or needs (receiving).
|
||||
givingZonesDesired := map[string]float64{}
|
||||
@@ -136,7 +136,7 @@ func getGivingAndReceivingZones(allocations map[string]Allocation, allocatedHint
|
||||
|
||||
for zone, allocation := range allocations {
|
||||
allocatedHints, _ := allocatedHintsByZone[zone]
|
||||
target := allocation.Desired
|
||||
target := allocation.desired
|
||||
if float64(allocatedHints) > target {
|
||||
givingZonesDesired[zone] = float64(allocatedHints) - target
|
||||
} else if float64(allocatedHints) < target {
|
||||
@@ -193,7 +193,7 @@ func getMost(zones map[string]float64) (string, float64) {
|
||||
// - A hint for a zone that no longer requires any allocations.
|
||||
// - An endpoint with no hints.
|
||||
// - Hints that would make minimum allocations impossible.
|
||||
func getHintsByZone(slice *discovery.EndpointSlice, allocatedHintsByZone EndpointZoneInfo, allocations map[string]Allocation) map[string]int {
|
||||
func getHintsByZone(slice *discovery.EndpointSlice, allocatedHintsByZone EndpointZoneInfo, allocations map[string]allocation) map[string]int {
|
||||
hintsByZone := map[string]int{}
|
||||
for _, endpoint := range slice.Endpoints {
|
||||
if !endpointsliceutil.EndpointReady(endpoint) {
|
||||
@@ -215,7 +215,7 @@ func getHintsByZone(slice *discovery.EndpointSlice, allocatedHintsByZone Endpoin
|
||||
for zone, numHints := range hintsByZone {
|
||||
alreadyAllocated, _ := allocatedHintsByZone[zone]
|
||||
allocation, ok := allocations[zone]
|
||||
if !ok || (numHints+alreadyAllocated) > allocation.Maximum {
|
||||
if !ok || (numHints+alreadyAllocated) > allocation.maximum {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ func serviceOverloaded(ezi EndpointZoneInfo, zoneRatios map[string]float64) bool
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
minEndpoints := math.Ceil(totalEndpoints * ratio * (1 / (1 + OverloadThreshold)))
|
||||
minEndpoints := math.Ceil(totalEndpoints * ratio * (1 / (1 + overloadThreshold)))
|
||||
if svcEndpoints < int(minEndpoints) {
|
||||
return true
|
||||
}
|
||||
@@ -252,12 +252,11 @@ func serviceOverloaded(ezi EndpointZoneInfo, zoneRatios map[string]float64) bool
|
||||
return false
|
||||
}
|
||||
|
||||
// NodeReady returns true if the Node has a status condition of type "NodeReady"
|
||||
// with a status of "True".
|
||||
func NodeReady(nodeStatus v1.NodeStatus) bool {
|
||||
for _, cond := range nodeStatus.Conditions {
|
||||
if cond.Type == v1.NodeReady {
|
||||
return cond.Status == v1.ConditionTrue
|
||||
// isNodeReady returns true if a node is ready; false otherwise.
|
||||
func isNodeReady(node *v1.Node) bool {
|
||||
for _, c := range node.Status.Conditions {
|
||||
if c.Type == v1.NodeReady {
|
||||
return c.Status == v1.ConditionTrue
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user