mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 10:00:11 +00:00
🌱 Send an event for evicting appliedmanifestwork (#1066)
Some checks failed
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Post / coverage (push) Has been cancelled
Post / images (amd64) (push) Has been cancelled
Post / images (arm64) (push) Has been cancelled
Post / image manifest (push) Has been cancelled
Post / trigger clusteradm e2e (push) Has been cancelled
Close stale issues and PRs / stale (push) Successful in 56s
Some checks failed
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Post / coverage (push) Has been cancelled
Post / images (amd64) (push) Has been cancelled
Post / images (arm64) (push) Has been cancelled
Post / image manifest (push) Has been cancelled
Post / trigger clusteradm e2e (push) Has been cancelled
Close stale issues and PRs / stale (push) Successful in 56s
* Increase the log level for evicting appliedmanifestwork Signed-off-by: zhujian <jiazhu@redhat.com> * Add an event for evicting appliedmanifestwork Signed-off-by: zhujian <jiazhu@redhat.com> --------- Signed-off-by: zhujian <jiazhu@redhat.com>
This commit is contained in:
@@ -33,6 +33,7 @@ const (
|
||||
)
|
||||
|
||||
type unmanagedAppliedWorkController struct {
|
||||
recorder events.Recorder
|
||||
manifestWorkLister worklister.ManifestWorkNamespaceLister
|
||||
appliedManifestWorkClient workv1client.AppliedManifestWorkInterface
|
||||
patcher patcher.Patcher[*workapiv1.AppliedManifestWork, workapiv1.AppliedManifestWorkSpec, workapiv1.AppliedManifestWorkStatus]
|
||||
@@ -62,6 +63,7 @@ func NewUnManagedAppliedWorkController(
|
||||
hubHash, agentID string,
|
||||
) factory.Controller {
|
||||
controller := &unmanagedAppliedWorkController{
|
||||
recorder: recorder,
|
||||
manifestWorkLister: manifestWorkLister,
|
||||
appliedManifestWorkClient: appliedManifestWorkClient,
|
||||
patcher: patcher.NewPatcher[
|
||||
@@ -136,8 +138,13 @@ func (m *unmanagedAppliedWorkController) evictAppliedManifestWork(ctx context.Co
|
||||
return nil
|
||||
}
|
||||
|
||||
klog.V(2).Infof("Delete appliedWork %s by agent %s after eviction grace periodby", appliedManifestWork.Name, m.agentID)
|
||||
return m.appliedManifestWorkClient.Delete(ctx, appliedManifestWork.Name, metav1.DeleteOptions{})
|
||||
err := m.appliedManifestWorkClient.Delete(ctx, appliedManifestWork.Name, metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.recorder.Eventf("AppliedManifestWorkEvicted", appliedManifestWork.Name,
|
||||
"AppliedManifestWork %s evicted by agent %s after eviction grace period", appliedManifestWork.Name, m.agentID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *unmanagedAppliedWorkController) stopToEvictAppliedManifestWork(
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/openshift/library-go/pkg/operator/events/eventstesting"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
clienttesting "k8s.io/client-go/testing"
|
||||
@@ -253,6 +254,7 @@ func TestSyncUnamanagedAppliedWork(t *testing.T) {
|
||||
}
|
||||
|
||||
controller := &unmanagedAppliedWorkController{
|
||||
recorder: eventstesting.NewTestingEventRecorder(t),
|
||||
manifestWorkLister: informerFactory.Work().V1().ManifestWorks().Lister().ManifestWorks("test"),
|
||||
appliedManifestWorkClient: fakeClient.WorkV1().AppliedManifestWorks(),
|
||||
patcher: patcher.NewPatcher[
|
||||
|
||||
Reference in New Issue
Block a user