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: 10 additions & 4 deletions npm/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,16 @@ func (npMgr *NetworkPolicyManager) SendClusterMetrics() {

for {
<-heartbeat
clusterState := npMgr.GetClusterState()
podCount.Value = float64(clusterState.PodCount)
nsCount.Value = float64(clusterState.NsCount)
nwPolicyCount.Value = float64(clusterState.NwPolicyCount)
npMgr.Lock()
podCount.Value = float64(len(npMgr.podMap))
//Reducing one to remove all-namespaces ns obj
nsCount.Value = float64(len(npMgr.nsMap) - 1)
nwPolCount := 0
for _, ns := range npMgr.nsMap {
nwPolCount = nwPolCount + len(ns.rawNpMap)
}
nwPolicyCount.Value = float64(nwPolCount)
npMgr.Unlock()

metrics.SendMetric(podCount)
metrics.SendMetric(nsCount)
Expand Down
10 changes: 5 additions & 5 deletions npm/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ func (npMgr *NetworkPolicyManager) UpdatePod(oldPodObj, newPodObj *corev1.Pod) e
return nil
}

if isInvalidPodUpdate(oldPodObj, newPodObj) {
return nil
}

// today K8s does not allow updating HostNetwork flag for an existing Pod. So NPM can safely
// check on the oldPodObj for hostNework value
if isHostNetworkPod(oldPodObj) {
log.Logf(
"POD UPDATING ignored for HostNetwork Pod:\n old pod: [%s/%s/%+v/%s/%s]\n new pod: [%s/%s/%+v/%s/%s]",
"POD UPDATING ignored for HostNetwork Pod:\n old pod: [%s/%s/%s]\n new pod: [%s/%s/%s]",
oldPodObj.ObjectMeta.Namespace, oldPodObj.ObjectMeta.Name, oldPodObj.Status.PodIP,
newPodObj.ObjectMeta.Namespace, newPodObj.ObjectMeta.Name, newPodObj.Status.PodIP,
)
return nil
}

if isInvalidPodUpdate(oldPodObj, newPodObj) {
return nil
}

var (
err error
oldPodObjNs = oldPodObj.ObjectMeta.Namespace
Expand Down