Skip to content

Commit

Permalink
Ignore node when metrics API doesn't work (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
fridim authored Jun 18, 2024
1 parent 1ffeaaf commit e0e7eda
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions internal/models/ocp_sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,11 @@ func (a *OcpSharedClusterConfiguration) CreateRestConfig() (*rest.Config, error)
return clientcmd.RESTConfigFromKubeConfig([]byte(a.Kubeconfig))
}

func includeNodeInUsageCalculation(conditions []v1.NodeCondition) bool {
func includeNodeInUsageCalculation(node v1.Node) bool {
if node.Spec.Unschedulable {
return false
}
conditions := node.Status.Conditions
nodeReady := false
for _, condition := range conditions {
if condition.Type == v1.NodeReady && condition.Status == v1.ConditionTrue {
Expand Down Expand Up @@ -800,7 +804,7 @@ func (a *OcpSandboxProvider) Request(serviceUuid string, cloud_selector map[stri

for _, node := range nodes.Items {

if !includeNodeInUsageCalculation(node.Status.Conditions) {
if !includeNodeInUsageCalculation(node) {
log.Logger.Info("Node not included in calculation",
"node",
node.Name,
Expand All @@ -821,9 +825,11 @@ func (a *OcpSandboxProvider) Request(serviceUuid string, cloud_selector map[stri
Get(context.Background(), node.Name, metav1.GetOptions{})

if err != nil {
log.Logger.Error("Error Get OCP node metrics v1beta1", "error", err)
rnew.SetStatus("error")
continue providerLoop
log.Logger.Error(
"Error Get OCP node metrics v1beta1, ignore the node",
"node", node.Name,
"error", err)
continue
}

mem, _ := nodeMetric.Usage.Memory().AsInt64()
Expand Down

0 comments on commit e0e7eda

Please sign in to comment.