mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
add logging for policy creation and deletion events (#1445)
* add logging for policy creation and deletion events * update log message * update log message kind type Co-authored-by: lengrongfu <lengrongfu@baidu.com>
This commit is contained in:
parent
52d091c5a3
commit
fab777cdd5
2 changed files with 11 additions and 3 deletions
|
@ -181,6 +181,9 @@ func (pc *PolicyController) canBackgroundProcess(p *kyverno.ClusterPolicy) bool
|
|||
func (pc *PolicyController) addPolicy(obj interface{}) {
|
||||
logger := pc.log
|
||||
p := obj.(*kyverno.ClusterPolicy)
|
||||
|
||||
logger.Info("policy created event", "uid", p.UID, "kind", "ClusterPolicy", "policy_name", p.Name)
|
||||
|
||||
if !pc.canBackgroundProcess(p) {
|
||||
return
|
||||
}
|
||||
|
@ -225,7 +228,7 @@ func (pc *PolicyController) deletePolicy(obj interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
logger.V(4).Info("deleting policy", "name", p.Name)
|
||||
logger.Info("policy deleted event", "uid", p.UID, "kind", "ClusterPolicy", "policy_name", p.Name)
|
||||
|
||||
// we process policies that are not set of background processing
|
||||
// as we need to clean up GRs when a policy is deleted
|
||||
|
@ -236,6 +239,9 @@ func (pc *PolicyController) deletePolicy(obj interface{}) {
|
|||
func (pc *PolicyController) addNsPolicy(obj interface{}) {
|
||||
logger := pc.log
|
||||
p := obj.(*kyverno.Policy)
|
||||
|
||||
logger.Info("policy created event", "uid", p.UID, "kind", "Policy", "policy_name", p.Name, "namespaces", p.Namespace)
|
||||
|
||||
pol := ConvertPolicyToClusterPolicy(p)
|
||||
if !pc.canBackgroundProcess(pol) {
|
||||
return
|
||||
|
@ -279,8 +285,10 @@ func (pc *PolicyController) deleteNsPolicy(obj interface{}) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("policy deleted event", "uid", p.UID, "kind", "Policy", "policy_name", p.Name, "namespaces", p.Namespace)
|
||||
|
||||
pol := ConvertPolicyToClusterPolicy(p)
|
||||
logger.V(4).Info("deleting namespace policy", "namespace", pol.Namespace, "name", pol.Name)
|
||||
|
||||
// we process policies that are not set of background processing
|
||||
// as we need to clean up GRs when a policy is deleted
|
||||
|
|
Loading…
Reference in a new issue