Skip to content

Commit

Permalink
style: fix style
Browse files Browse the repository at this point in the history
Signed-off-by: wangyizhi1 <[email protected]>
  • Loading branch information
wangyizhi1 committed Oct 27, 2023
1 parent 106a93d commit 204fbf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
6 changes: 3 additions & 3 deletions cmd/clustertree/cluster-manager/app/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ func run(ctx context.Context, opts *options.Options) error {
}

// init Kosmos client
kosmosRootClient, err := utils.NewKosmosClientFromConfigPath(opts.KubernetesOptions.KubeConfig, configOptFunc)
rootKosmosClient, err := utils.NewKosmosClientFromConfigPath(opts.KubernetesOptions.KubeConfig, configOptFunc)
if err != nil {
return fmt.Errorf("could not build kosmos clientset for root cluster: %v", err)
}

rootResourceManager := utils.NewResourceManager(rootClient, kosmosRootClient)
rootResourceManager := utils.NewResourceManager(rootClient, rootKosmosClient)
mgr, err := controllerruntime.NewManager(config, controllerruntime.Options{
Logger: klog.Background(),
Scheme: scheme.NewSchema(),
Expand Down Expand Up @@ -135,7 +135,7 @@ func run(ctx context.Context, opts *options.Options) error {
rootResourceManager.InformerFactory.Start(ctx.Done())
rootResourceManager.KosmosInformerFactory.Start(ctx.Done())
if !cache.WaitForCacheSync(ctx.Done(), rootResourceManager.EndpointSliceInformer.HasSynced) {
klog.Fatal("Knode manager: wait for informer factory failed")
klog.Fatal("cluster manager: wait for informer factory failed")
}

<-ctx.Done()
Expand Down
4 changes: 2 additions & 2 deletions pkg/clustertree/cluster-manager/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const (
RootClusterAnnotationValue = "root"

DefaultLeafKubeQPS = 40.0
DefalutLeafKubeBurst = 60
DefaultLeafKubeBurst = 60
)

type ClusterController struct {
Expand Down Expand Up @@ -134,7 +134,7 @@ func (c *ClusterController) Reconcile(ctx context.Context, request reconcile.Req

config, err := utils.NewConfigFromBytes(cluster.Spec.Kubeconfig, func(config *rest.Config) {
config.QPS = DefaultLeafKubeQPS
config.Burst = DefalutLeafKubeBurst
config.Burst = DefaultLeafKubeBurst
})
if err != nil {
return reconcile.Result{}, fmt.Errorf("could not build kubeconfig for cluster %s: %v", cluster.Name, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ func (c *NodeResourcesController) Reconcile(ctx context.Context, request reconci
klog.V(4).Infof("============ %s has been reconciled =============", request.Name)
}()

node := &corev1.Node{}
if err := c.Leaf.Get(ctx, request.NamespacedName, node); err != nil {
return controllerruntime.Result{}, err
}

nodes := corev1.NodeList{}
if err := c.Leaf.List(ctx, &nodes); err != nil {
return controllerruntime.Result{}, err
Expand All @@ -110,23 +105,20 @@ func (c *NodeResourcesController) Reconcile(ctx context.Context, request reconci

clusterResources := utils.CalculateClusterResources(&nodes, &pods)

curr := &corev1.Node{}
namespacedName := types.NamespacedName{
Name: c.Node.Name,
}
err := c.Root.Get(ctx, namespacedName, curr)
node := &corev1.Node{}
err := c.Root.Get(ctx, types.NamespacedName{Name: c.Node.Name}, node)
if err != nil {
return reconcile.Result{
RequeueAfter: RequeueTime,
}, fmt.Errorf("cannot get node while update node resources %s, err: %v", c.Node.Name, err)
}

clone := curr.DeepCopy()
clone := node.DeepCopy()
clone.Status.Allocatable = clusterResources
clone.Status.Capacity = clusterResources
clone.Status.Conditions = utils.NodeConditions()

patch, err := utils.CreateMergePatch(curr, clone)
patch, err := utils.CreateMergePatch(node, clone)
if err != nil {
return reconcile.Result{}, err
}
Expand Down

0 comments on commit 204fbf7

Please sign in to comment.