mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
fix: bump log level for autogen debug logs (#5687)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
682afc8e0f
commit
84a5b0d0bc
3 changed files with 12 additions and 9 deletions
|
@ -75,30 +75,30 @@ func CanAutoGen(spec *kyvernov1.Spec) (applyAutoGen bool, controllers string) {
|
||||||
}
|
}
|
||||||
match, exclude := rule.MatchResources, rule.ExcludeResources
|
match, exclude := rule.MatchResources, rule.ExcludeResources
|
||||||
if !checkAutogenSupport(&needed, match.ResourceDescription, exclude.ResourceDescription) {
|
if !checkAutogenSupport(&needed, match.ResourceDescription, exclude.ResourceDescription) {
|
||||||
logger.V(3).Info("skip generating rule on pod controllers: Name / Selector in resource description may not be applicable.", "rule", rule.Name)
|
debug.Info("skip generating rule on pod controllers: Name / Selector in resource description may not be applicable.", "rule", rule.Name)
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
for _, value := range match.Any {
|
for _, value := range match.Any {
|
||||||
if !checkAutogenSupport(&needed, value.ResourceDescription) {
|
if !checkAutogenSupport(&needed, value.ResourceDescription) {
|
||||||
logger.V(3).Info("skip generating rule on pod controllers: Name / Selector in match any block is not applicable.", "rule", rule.Name)
|
debug.Info("skip generating rule on pod controllers: Name / Selector in match any block is not applicable.", "rule", rule.Name)
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, value := range match.All {
|
for _, value := range match.All {
|
||||||
if !checkAutogenSupport(&needed, value.ResourceDescription) {
|
if !checkAutogenSupport(&needed, value.ResourceDescription) {
|
||||||
logger.V(3).Info("skip generating rule on pod controllers: Name / Selector in match all block is not applicable.", "rule", rule.Name)
|
debug.Info("skip generating rule on pod controllers: Name / Selector in match all block is not applicable.", "rule", rule.Name)
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, value := range exclude.Any {
|
for _, value := range exclude.Any {
|
||||||
if !checkAutogenSupport(&needed, value.ResourceDescription) {
|
if !checkAutogenSupport(&needed, value.ResourceDescription) {
|
||||||
logger.V(3).Info("skip generating rule on pod controllers: Name / Selector in exclude any block is not applicable.", "rule", rule.Name)
|
debug.Info("skip generating rule on pod controllers: Name / Selector in exclude any block is not applicable.", "rule", rule.Name)
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, value := range exclude.All {
|
for _, value := range exclude.All {
|
||||||
if !checkAutogenSupport(&needed, value.ResourceDescription) {
|
if !checkAutogenSupport(&needed, value.ResourceDescription) {
|
||||||
logger.V(3).Info("skip generating rule on pod controllers: Name / Selector in exclud all block is not applicable.", "rule", rule.Name)
|
debug.Info("skip generating rule on pod controllers: Name / Selector in exclud all block is not applicable.", "rule", rule.Name)
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,7 @@ package autogen
|
||||||
|
|
||||||
import "github.com/kyverno/kyverno/pkg/logging"
|
import "github.com/kyverno/kyverno/pkg/logging"
|
||||||
|
|
||||||
var logger = logging.WithName("autogen")
|
var (
|
||||||
|
logger = logging.WithName("autogen")
|
||||||
|
debug = logger.V(5)
|
||||||
|
)
|
||||||
|
|
|
@ -227,10 +227,10 @@ func getAnyAllAutogenRule(v kyvernov1.ResourceFilters, match string, kinds []str
|
||||||
|
|
||||||
func generateRuleForControllers(rule *kyvernov1.Rule, controllers string) *kyvernov1.Rule {
|
func generateRuleForControllers(rule *kyvernov1.Rule, controllers string) *kyvernov1.Rule {
|
||||||
if isAutogenRuleName(rule.Name) || controllers == "" {
|
if isAutogenRuleName(rule.Name) || controllers == "" {
|
||||||
logger.V(5).Info("skip generateRuleForControllers")
|
debug.Info("skip generateRuleForControllers")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
logger.V(3).Info("processing rule", "rulename", rule.Name)
|
debug.Info("processing rule", "rulename", rule.Name)
|
||||||
match, exclude := rule.MatchResources, rule.ExcludeResources
|
match, exclude := rule.MatchResources, rule.ExcludeResources
|
||||||
matchKinds, excludeKinds := match.GetKinds(), exclude.GetKinds()
|
matchKinds, excludeKinds := match.GetKinds(), exclude.GetKinds()
|
||||||
if !kubeutils.ContainsKind(matchKinds, "Pod") || (len(excludeKinds) != 0 && !kubeutils.ContainsKind(excludeKinds, "Pod")) {
|
if !kubeutils.ContainsKind(matchKinds, "Pod") || (len(excludeKinds) != 0 && !kubeutils.ContainsKind(excludeKinds, "Pod")) {
|
||||||
|
@ -283,7 +283,7 @@ func generateCronJobRule(rule *kyvernov1.Rule, controllers string) *kyvernov1.Ru
|
||||||
if !hasCronJob {
|
if !hasCronJob {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
logger.V(3).Info("generating rule for cronJob")
|
debug.Info("generating rule for cronJob")
|
||||||
return generateRule(
|
return generateRule(
|
||||||
getAutogenRuleName("autogen-cronjob", rule.Name),
|
getAutogenRuleName("autogen-cronjob", rule.Name),
|
||||||
generateRuleForControllers(rule, controllers),
|
generateRuleForControllers(rule, controllers),
|
||||||
|
|
Loading…
Add table
Reference in a new issue