Skip to content

Commit

Permalink
replace daemonset in kruise daemonset controller
Browse files Browse the repository at this point in the history
  • Loading branch information
daimaxiaxie committed Aug 3, 2024
1 parent a7033c9 commit 1ab7ba4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions pkg/controllers/state/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package state
import (
"context"
"fmt"
kruise "github.com/openkruise/kruise/apis/apps/v1alpha1"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -376,6 +377,10 @@ func (c *Cluster) UpdateDaemonSet(ctx context.Context, daemonset *appsv1.DaemonS
return nil
}

func (c *Cluster) UpdateKruiseDaemonSet(ctx context.Context, daemonset *kruise.DaemonSet) error {
return nil
}

func (c *Cluster) DeleteDaemonSet(key types.NamespacedName) {
c.daemonSetPods.Delete(key)
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/controllers/state/informer/kruisedaemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"time"

kruise "github.com/openkruise/kruise/apis/apps/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/errors"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -47,18 +46,17 @@ func NewKruiseDaemonSetController(kubeClient client.Client, cluster *state.Clust
}

func (c *KruiseDaemonSetController) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
ctx = injection.WithControllerName(ctx, "state.daemonset")
ctx = injection.WithControllerName(ctx, "state.kruise-daemonset")

// TODO replace
daemonSet := appsv1.DaemonSet{}
daemonSet := kruise.DaemonSet{}
if err := c.kubeClient.Get(ctx, req.NamespacedName, &daemonSet); err != nil {
if errors.IsNotFound(err) {
// notify cluster state of the daemonset deletion
c.cluster.DeleteDaemonSet(req.NamespacedName)
}
return reconcile.Result{}, client.IgnoreNotFound(err)
}
if err := c.cluster.UpdateDaemonSet(ctx, &daemonSet); err != nil {
if err := c.cluster.UpdateKruiseDaemonSet(ctx, &daemonSet); err != nil {
return reconcile.Result{}, err
}
return reconcile.Result{RequeueAfter: time.Minute}, nil
Expand Down

0 comments on commit 1ab7ba4

Please sign in to comment.