diff --git a/main.go b/main.go index 14bfa557..204f0536 100644 --- a/main.go +++ b/main.go @@ -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" @@ -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() diff --git a/pkg/applicationprofilemanager/v1/applicationprofile_manager.go b/pkg/applicationprofilemanager/v1/applicationprofile_manager.go index c64ac03d..f22411a0 100644 --- a/pkg/applicationprofilemanager/v1/applicationprofile_manager.go +++ b/pkg/applicationprofilemanager/v1/applicationprofile_manager.go @@ -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), diff --git a/pkg/networkmanager/v2/network_manager.go b/pkg/networkmanager/v2/network_manager.go index b9b43c30..26772340 100644 --- a/pkg/networkmanager/v2/network_manager.go +++ b/pkg/networkmanager/v2/network_manager.go @@ -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), diff --git a/pkg/rulebindingmanager/cache/cache.go b/pkg/rulebindingmanager/cache/cache.go index 7261f91e..8221c451 100644 --- a/pkg/rulebindingmanager/cache/cache.go +++ b/pkg/rulebindingmanager/cache/cache.go @@ -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 diff --git a/pkg/rulebindingmanager/types/v1/types.go b/pkg/rulebindingmanager/types/v1/types.go index ab5b6943..6a8f8ec9 100644 --- a/pkg/rulebindingmanager/types/v1/types.go +++ b/pkg/rulebindingmanager/types/v1/types.go @@ -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 {