-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IP Usage metrics at Rest server.
- Loading branch information
1 parent
dcd55b3
commit be6ddea
Showing
4 changed files
with
168 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package restserver | ||
|
||
import ( | ||
"github.com/Azure/azure-container-networking/cns/logger" | ||
"github.com/Azure/azure-container-networking/cns/types" | ||
) | ||
|
||
type ipState struct { | ||
// allocatedIPs are all the IPs given to CNS by DNC. | ||
allocatedIPs int64 | ||
// assignedIPs are the IPs CNS gives to Pods. | ||
assignedIPs int64 | ||
// availableIPs are the IPs in state "Available". | ||
availableIPs int64 | ||
// programmingIPs are the IPs in state "PendingProgramming". | ||
programmingIPs int64 | ||
// releasingIPs are the IPs in state "PendingReleasr". | ||
releasingIPs int64 | ||
} | ||
|
||
func (service *HTTPRestService) buildIPState() ipState { | ||
service.Lock() | ||
defer service.Unlock() | ||
|
||
state := ipState{ | ||
allocatedIPs: 0, | ||
assignedIPs: 0, | ||
availableIPs: 0, | ||
} | ||
|
||
for _, ipConfig := range service.PodIPConfigState { | ||
state.allocatedIPs++ | ||
if ipConfig.GetState() == types.Assigned { | ||
state.assignedIPs++ | ||
} | ||
if ipConfig.GetState() == types.Available { | ||
state.availableIPs++ | ||
} | ||
if ipConfig.GetState() == types.PendingProgramming { | ||
state.programmingIPs++ | ||
} | ||
if ipConfig.GetState() == types.PendingRelease { | ||
state.releasingIPs++ | ||
} | ||
} | ||
|
||
logger.Printf("[IP Usage] allocated IPs: %d, assigned IPs: %d, available IPs: %d", state.allocatedIPs, state.assignedIPs, state.availableIPs) | ||
return state | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters