Skip to content

Commit

Permalink
fix: add filtering conditions
Browse files Browse the repository at this point in the history
Signed-off-by: OrangeBao <[email protected]>
  • Loading branch information
OrangeBao committed Nov 28, 2023
1 parent 3dd1de9 commit 4dbad83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/clusterlink/agent/app/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func run(ctx context.Context, opts *options.Options) error {

autoDetectController := linkagent.AutoDetectReconciler{
Client: mgr.GetClient(),
NodeName: os.Getenv(utils.EnvNodeName),
ClusterName: os.Getenv(utils.EnvClusterName),
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/clusterlink/agent-manager/auto_detect_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

kosmosv1alpha1 "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1"
"github.com/kosmos.io/kosmos/pkg/clusterlink/agent-manager/autodetection"
"github.com/kosmos.io/kosmos/pkg/clusterlink/controllers/node"
"github.com/kosmos.io/kosmos/pkg/clusterlink/network"
)

Expand All @@ -29,6 +30,7 @@ const (
type AutoDetectReconciler struct {
client.Client
ClusterName string
NodeName string
}

func (r *AutoDetectReconciler) SetupWithManager(mgr manager.Manager) error {
Expand All @@ -42,7 +44,8 @@ func (r *AutoDetectReconciler) SetupWithManager(mgr manager.Manager) error {
return false
}

if eventObj.Spec.ClusterName != r.ClusterName {
if eventObj.Name != node.ClusterNodeName(r.ClusterName, r.NodeName) {
klog.V(4).Infof("skip event, reconcile node name: %s, current node name: %s-%s", eventObj.Name, r.ClusterName, r.NodeName)
return false
}

Expand Down

0 comments on commit 4dbad83

Please sign in to comment.