Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cns/kubecontroller/nodenetworkconfig/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,26 @@ var (
Help: "Unused IP count.",
},
)
hasNNC = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "nnc_has_nodenetworkconfig",
Help: "Has received a NodeNetworkConfig",
},
)
ncs = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "nnc_ncs",
Help: "Network Container count in the NodeNetworkConfig",
},
)
)

func init() {
metrics.Registry.MustRegister(
allocatedIPs,
requestedIPs,
unusedIPs,
hasNNC,
ncs,
)
}
7 changes: 5 additions & 2 deletions cns/kubecontroller/nodenetworkconfig/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,24 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
nnc, err := r.nnccli.Get(ctx, req.NamespacedName)
if err != nil {
if apierrors.IsNotFound(err) {
hasNNC.Set(0)
logger.Printf("[cns-rc] CRD not found, ignoring %v", err)
return reconcile.Result{}, errors.Wrapf(client.IgnoreNotFound(err), "NodeNetworkConfig %v not found", req.NamespacedName)
}
logger.Errorf("[cns-rc] Error retrieving CRD from cache : %v", err)
return reconcile.Result{}, errors.Wrapf(err, "failed to get NodeNetworkConfig %v", req.NamespacedName)
}

hasNNC.Set(1)
logger.Printf("[cns-rc] CRD Spec: %+v", nnc.Spec)

ipAssignments := 0

// during node upgrades, an nnc may be updated with new ncs. at any given time, only the ncs
// that exist in the nnc are valid. any others that may have been previously created and no
// longer exist in the nnc should be considered stale.
validNCIDs := make([]string, len(nnc.Status.NetworkContainers))
ncCount := len(nnc.Status.NetworkContainers)
ncs.Set(float64(ncCount))
validNCIDs := make([]string, ncCount)
for i := range nnc.Status.NetworkContainers {
validNCIDs[i] = nnc.Status.NetworkContainers[i].ID
}
Expand Down
1 change: 1 addition & 0 deletions cns/restserver/internalapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func (service *HTTPRestService) syncHostNCVersion(ctx context.Context, channelMo
for _, nc := range ncVersionListResp.Containers {
nmaNCs[strings.ToLower(nc.NetworkContainerID)] = nc.Version
}
hasNC.Set(float64(len(nmaNCs)))
for ncID := range outdatedNCs {
nmaNCVersionStr, ok := nmaNCs[ncID]
if !ok {
Expand Down
7 changes: 7 additions & 0 deletions cns/restserver/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ var (
},
[]string{"ok"},
)
hasNC = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "has_networkcontainer",
Help: "Number of Network Containers retrieved from NMA",
},
)
allocatedIPCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cx_allocated_ips_v2",
Expand Down Expand Up @@ -114,6 +120,7 @@ func init() {
ipConfigStatusStateTransitionTime,
syncHostNCVersionCount,
syncHostNCVersionLatency,
hasNC,
allocatedIPCount,
assignedIPCount,
availableIPCount,
Expand Down
Loading