1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

compare policy status before actually update it (#1523)

Signed-off-by: Shuting Zhao <shutting06@gmail.com>
This commit is contained in:
shuting 2021-02-05 09:58:24 -08:00 committed by GitHub
parent 39b27a16ed
commit 6953aa86bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@ package policystatus
import (
"context"
"encoding/json"
"reflect"
"strings"
"sync"
"time"
@ -167,6 +168,10 @@ func (s *Sync) updateClusterPolicy(policyName, key string, status v1.PolicyStatu
return
}
if reflect.DeepEqual(status, policy.Status) {
return
}
policy.Status = status
_, err = s.client.KyvernoV1().ClusterPolicies().UpdateStatus(context.TODO(), policy, metav1.UpdateOptions{})
if err != nil {
@ -183,6 +188,10 @@ func (s *Sync) updateNamespacedPolicyStatus(policyName, namespace, key string, s
return
}
if reflect.DeepEqual(status, policy.Status) {
return
}
policy.Status = status
_, err = s.client.KyvernoV1().Policies(namespace).UpdateStatus(context.TODO(), policy, metav1.UpdateOptions{})
if err != nil {