Skip to content

Commit

Permalink
Merge pull request #255 from kubescape/networkmanagerv2
Browse files Browse the repository at this point in the history
Ignore networkmanagerv2
  • Loading branch information
David Wertenteil authored Apr 15, 2024
2 parents 0465b91 + 15fcbeb commit 925555d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
metricprometheus "node-agent/pkg/metricsmanager/prometheus"
"node-agent/pkg/networkmanager"
networkmanagerv1 "node-agent/pkg/networkmanager/v1"
networkmanagerv2 "node-agent/pkg/networkmanager/v2"
"node-agent/pkg/objectcache"
"node-agent/pkg/objectcache/applicationprofilecache"
"node-agent/pkg/objectcache/k8scache"
Expand Down Expand Up @@ -211,7 +210,8 @@ func main() {
dnsManager := dnsmanager.CreateDNSManager()
dnsManagerClient = dnsManager
networkManagerv1Client = networkmanagerv1.CreateNetworkManager(ctx, cfg, k8sClient, storageClient, clusterData.ClusterName, dnsManager, preRunningContainersIDs, k8sObjectCache)
networkManagerClient = networkmanagerv2.CreateNetworkManager(ctx, cfg, clusterData.ClusterName, k8sClient, storageClient, dnsManager, preRunningContainersIDs, k8sObjectCache)
// networkManagerClient = networkmanagerv2.CreateNetworkManager(ctx, cfg, clusterData.ClusterName, k8sClient, storageClient, dnsManager, preRunningContainersIDs, k8sObjectCache)
networkManagerClient = networkmanager.CreateNetworkManagerMock()
} else {
networkManagerv1Client = networkmanagerv1.CreateNetworkManagerMock()
networkManagerClient = networkmanager.CreateNetworkManagerMock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (am *ApplicationProfileManager) saveProfile(ctx context.Context, watchedCon
helpers.String("k8s workload", watchedContainer.K8sContainerID))
}
} else {
logger.L().Ctx(ctx).Warning("ApplicationProfileManager - failed to patch application profile, will get existing one and adjust patch", helpers.Error(err),
logger.L().Ctx(ctx).Debug("ApplicationProfileManager - failed to patch application profile, will get existing one and adjust patch", helpers.Error(err),
helpers.String("slug", slug),
helpers.Int("container index", watchedContainer.ContainerIndex),
helpers.String("container ID", watchedContainer.ContainerID),
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkmanager/v2/network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (nm *NetworkManager) saveNetworkEvents(ctx context.Context, watchedContaine
helpers.String("k8s workload", watchedContainer.K8sContainerID))
}
} else {
logger.L().Ctx(ctx).Warning("NetworkManager - failed to patch network neighborhood, will get existing one and adjust patch", helpers.Error(err),
logger.L().Ctx(ctx).Debug("NetworkManager - failed to patch network neighborhood, will get existing one and adjust patch", helpers.Error(err),
helpers.String("slug", slug),
helpers.Int("container index", watchedContainer.ContainerIndex),
helpers.String("container ID", watchedContainer.ContainerID),
Expand Down
15 changes: 10 additions & 5 deletions pkg/rulebindingmanager/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,16 @@ func (c *RBCache) addRuleBinding(ruleBinding *typesv1.RuntimeAlertRuleBinding) {
c.rbNameToPodNames.Set(rbName, mapset.NewSet[string]())
c.rbNameToRules.Set(rbName, c.createRules(ruleBinding.Spec.Rules))

// get related namespaces
namespaces, err := c.k8sClient.GetKubernetesClient().CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{LabelSelector: nsSelectorStr})
if err != nil {
logger.L().Error("failed to list namespaces", helpers.String("ruleBiding", rbName), helpers.String("nsSelector", nsSelectorStr), helpers.Error(err))
return
var namespaces *corev1.NamespaceList
if ruleBinding.GetNamespace() == "" {
// get related namespaces
namespaces, err = c.k8sClient.GetKubernetesClient().CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{LabelSelector: nsSelectorStr})
if err != nil {
logger.L().Error("failed to list namespaces", helpers.String("ruleBiding", rbName), helpers.String("nsSelector", nsSelectorStr), helpers.Error(err))
return
}
} else {
namespaces = &corev1.NamespaceList{Items: []corev1.Namespace{{ObjectMeta: metav1.ObjectMeta{Name: ruleBinding.GetNamespace()}}}}
}

// get related pods
Expand Down
4 changes: 2 additions & 2 deletions pkg/rulebindingmanager/types/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ type RuntimeAlertRuleBindingSpec struct {
}

type RuntimeAlertRuleBindingRule struct {
Parameters map[string]interface{} `json:"parameters" yaml:"parameters"`
RuleName string `json:"ruleName" yaml:"ruleName"`
RuleID string `json:"ruleID" yaml:"ruleID"`
RuleTags []string `json:"ruleTags" yaml:"ruleTags"`
Severity string `json:"severity" yaml:"severity"`
Parameters map[string]interface{} `json:"parameters" yaml:"parameters"`
RuleTags []string `json:"ruleTags" yaml:"ruleTags"`
}

func (r *RuntimeAlertRuleBindingRule) Equal(other *RuntimeAlertRuleBindingRule) bool {
Expand Down

0 comments on commit 925555d

Please sign in to comment.