/
daemonsetstatuses.go
52 lines (40 loc) · 1.12 KB
/
daemonsetstatuses.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cluster
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"context"
"strconv"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/Azure/ARO-RP/pkg/util/namespace"
)
func (mon *Monitor) emitDaemonsetStatuses(ctx context.Context) error {
var cont string
var count int64
for {
dss, err := mon.cli.AppsV1().DaemonSets("").List(ctx, metav1.ListOptions{Limit: 500, Continue: cont})
if err != nil {
return err
}
count += int64(len(dss.Items))
for _, ds := range dss.Items {
if !namespace.IsOpenShiftNamespace(ds.Namespace) {
continue
}
if ds.Status.DesiredNumberScheduled == ds.Status.NumberAvailable {
continue
}
mon.emitGauge("daemonset.statuses", 1, map[string]string{
"desiredNumberScheduled": strconv.Itoa(int(ds.Status.DesiredNumberScheduled)),
"name": ds.Name,
"namespace": ds.Namespace,
"numberAvailable": strconv.Itoa(int(ds.Status.NumberAvailable)),
})
}
cont = dss.Continue
if cont == "" {
break
}
}
mon.emitGauge("daemonset.count", count, nil)
return nil
}