Skip to content

Commit

Permalink
still watch ignored pod
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdsteelRail committed Oct 12, 2024
1 parent c31ba25 commit 69773dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: kusionstack/kuperator
newName: coldsteelrail/kusion-kuperator
newTag: test
12 changes: 10 additions & 2 deletions pkg/controllers/collaset/podcontrol/pod_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
"kusionstack.io/kube-api/apps/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/client"

refmanagerutil "kusionstack.io/kuperator/pkg/controllers/utils/refmanager"
"kusionstack.io/kuperator/pkg/utils"
"kusionstack.io/kuperator/pkg/utils/inject"
)

Expand Down Expand Up @@ -136,11 +136,19 @@ func FilterOutIgnoredPod(pods []*corev1.Pod) []*corev1.Pod {
var filteredPod []*corev1.Pod

for i := range pods {
if utils.IgnoredByCollaSet(pods[i]) {
if IgnoredByCollaSet(pods[i]) {
continue
}

filteredPod = append(filteredPod, pods[i])
}
return filteredPod
}

func IgnoredByCollaSet(obj client.Object) bool {
if obj == nil || obj.GetLabels() == nil {
return false
}
_, ok := obj.GetLabels()[v1alpha1.PodIgnoringIndicationLabelKey]
return ok
}
9 changes: 4 additions & 5 deletions pkg/controllers/collaset/predicts.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@ type PodPredicate struct {

// Create returns true if the Create event should be processed
func (p *PodPredicate) Create(e event.CreateEvent) bool {
return utils.ControlledByKusionStack(e.Object) && !utils.IgnoredByCollaSet(e.Object)
return utils.ControlledByKusionStack(e.Object)
}

// Delete returns true if the Delete event should be processed
func (p *PodPredicate) Delete(e event.DeleteEvent) bool {
return utils.ControlledByKusionStack(e.Object) && !utils.IgnoredByCollaSet(e.Object)
return utils.ControlledByKusionStack(e.Object)
}

// Update returns true if the Update event should be processed
func (p *PodPredicate) Update(e event.UpdateEvent) bool {
return (utils.ControlledByKusionStack(e.ObjectNew) && !utils.IgnoredByCollaSet(e.ObjectNew)) ||
(utils.ControlledByKusionStack(e.ObjectOld) && !utils.IgnoredByCollaSet(e.ObjectOld))
return utils.ControlledByKusionStack(e.ObjectNew) || utils.ControlledByKusionStack(e.ObjectOld)
}

// Generic returns true if the Generic event should be processed
func (p *PodPredicate) Generic(e event.GenericEvent) bool {
return utils.ControlledByKusionStack(e.Object) && !utils.IgnoredByCollaSet(e.Object)
return utils.ControlledByKusionStack(e.Object)
}
8 changes: 0 additions & 8 deletions pkg/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,3 @@ func ControlByKusionStack(obj client.Object) {
obj.GetLabels()[v1alpha1.ControlledByKusionStackLabelKey] = "true"
}
}

func IgnoredByCollaSet(obj client.Object) bool {
if obj == nil || obj.GetLabels() == nil {
return false
}
_, ok := obj.GetLabels()[v1alpha1.PodIgnoringIndicationLabelKey]
return ok
}

0 comments on commit 69773dc

Please sign in to comment.