You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/09/13 06:20:39 UTC

[GitHub] [incubator-uniffle] wangao1236 opened a new pull request, #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

wangao1236 opened a new pull request, #214:
URL: https://github.com/apache/incubator-uniffle/pull/214

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://github.com/Tencent/Firestorm/blob/master/CONTRIBUTING.md
     2. Ensure you have added or run the appropriate tests for your PR
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]XXXX Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
   -->
   
   ### What changes were proposed in this pull request?
   For issue #48 
   I add some codes about controller module, and I'll add more unit tests in next PR.
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on pull request #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

Posted by GitBox <gi...@apache.org>.
jerqi commented on PR #214:
URL: https://github.com/apache/incubator-uniffle/pull/214#issuecomment-1244965898

   @czy006 @zuston @thousandhu Could you help me review this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] codecov-commenter commented on pull request #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #214:
URL: https://github.com/apache/incubator-uniffle/pull/214#issuecomment-1244968569

   # [Codecov](https://codecov.io/gh/apache/incubator-uniffle/pull/214?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#214](https://codecov.io/gh/apache/incubator-uniffle/pull/214?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (08a002c) into [master](https://codecov.io/gh/apache/incubator-uniffle/commit/07f70ed872b87107fc7028577bd9e66d8349fd6c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (07f70ed) will **decrease** coverage by `0.62%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #214      +/-   ##
   ============================================
   - Coverage     58.48%   57.86%   -0.63%     
   + Complexity     1277     1247      -30     
   ============================================
     Files           158      151       -7     
     Lines          8463     8229     -234     
     Branches        785      786       +1     
   ============================================
   - Hits           4950     4762     -188     
   + Misses         3259     3212      -47     
   - Partials        254      255       +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-uniffle/pull/214?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...storage/handler/impl/DataSkippableReadHandler.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmFnZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvdW5pZmZsZS9zdG9yYWdlL2hhbmRsZXIvaW1wbC9EYXRhU2tpcHBhYmxlUmVhZEhhbmRsZXIuamF2YQ==) | `81.25% <0.00%> (-3.13%)` | :arrow_down: |
   | [...he/uniffle/client/impl/ShuffleWriteClientImpl.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL2NsaWVudC9pbXBsL1NodWZmbGVXcml0ZUNsaWVudEltcGwuamF2YQ==) | `22.97% <0.00%> (-2.41%)` | :arrow_down: |
   | [...orage/handler/impl/LocalFileServerReadHandler.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmFnZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvdW5pZmZsZS9zdG9yYWdlL2hhbmRsZXIvaW1wbC9Mb2NhbEZpbGVTZXJ2ZXJSZWFkSGFuZGxlci5qYXZh) | `77.96% <0.00%> (-2.40%)` | :arrow_down: |
   | [...pache/uniffle/server/ShuffleServerGrpcService.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL3NlcnZlci9TaHVmZmxlU2VydmVyR3JwY1NlcnZpY2UuamF2YQ==) | `0.91% <0.00%> (-0.07%)` | :arrow_down: |
   | [.../storage/handler/impl/HdfsShuffleWriteHandler.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmFnZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvdW5pZmZsZS9zdG9yYWdlL2hhbmRsZXIvaW1wbC9IZGZzU2h1ZmZsZVdyaXRlSGFuZGxlci5qYXZh) | `85.07% <0.00%> (ø)` | |
   | [.../java/org/apache/spark/shuffle/RssSparkConfig.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50LXNwYXJrL2NvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc3Bhcmsvc2h1ZmZsZS9Sc3NTcGFya0NvbmZpZy5qYXZh) | | |
   | [...k/shuffle/writer/WrappedByteArrayOutputStream.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50LXNwYXJrL2NvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc3Bhcmsvc2h1ZmZsZS93cml0ZXIvV3JhcHBlZEJ5dGVBcnJheU91dHB1dFN0cmVhbS5qYXZh) | | |
   | [...che/spark/shuffle/writer/BufferManagerOptions.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50LXNwYXJrL2NvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc3Bhcmsvc2h1ZmZsZS93cml0ZXIvQnVmZmVyTWFuYWdlck9wdGlvbnMuamF2YQ==) | | |
   | [...pache/spark/shuffle/writer/WriteBufferManager.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50LXNwYXJrL2NvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc3Bhcmsvc2h1ZmZsZS93cml0ZXIvV3JpdGVCdWZmZXJNYW5hZ2VyLmphdmE=) | | |
   | [...org/apache/spark/shuffle/writer/AddBlockEvent.java](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50LXNwYXJrL2NvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc3Bhcmsvc2h1ZmZsZS93cml0ZXIvQWRkQmxvY2tFdmVudC5qYXZh) | | |
   | ... and [17 more](https://codecov.io/gh/apache/incubator-uniffle/pull/214/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

Posted by GitBox <gi...@apache.org>.
jerqi commented on code in PR #214:
URL: https://github.com/apache/incubator-uniffle/pull/214#discussion_r970262280


##########
deploy/kubernetes/operator/pkg/controller/constants/constants.go:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package constants
+
+const (
+	// ContainerShuffleServerRPCPort indicates rpc port used in shuffle server containers.
+	ContainerShuffleServerRPCPort int32 = 19997
+	// ContainerShuffleServerHTTPPort indicates http port used in shuffle server containers.
+	ContainerShuffleServerHTTPPort int32 = 19996
+	// ContainerCoordinatorRPCPort indicates rpc port used in coordinator containers.
+	ContainerCoordinatorRPCPort int32 = 19997
+	// ContainerCoordinatorHTTPPort indicates http port used in coordinator containers.
+	ContainerCoordinatorHTTPPort int32 = 19996
+
+	// ShuffleServerRPCPortEnv indicates environment name of rpc port used by shuffle servers.
+	ShuffleServerRPCPortEnv = "SERVER_RPC_PORT"
+	// ShuffleServerHTTPPortEnv indicates environment name of http port used by shuffle servers.
+	ShuffleServerHTTPPortEnv = "SERVER_HTTP_PORT"
+	// CoordinatorRPCPortEnv indicates environment name of rpc port used by coordinators.
+	CoordinatorRPCPortEnv = "COORDINATOR_RPC_PORT"
+	// CoordinatorHTTPPortEnv indicates environment name of http port used by coordinators.
+	CoordinatorHTTPPortEnv = "COORDINATOR_HTTP_PORT"
+	// RSSCoordinatorQuorumEnv indicates environment name of rss coordinator quorum used by shuffle servers.
+	RSSCoordinatorQuorumEnv = "RSS_COORDINATOR_QUORUM"
+	// XmxSizeEnv indicates environment name of xmx size used by coordinators or shuffle servers.
+	XmxSizeEnv = "XMX_SIZE"
+	// ServiceNameEnv indicates environment name of service name used by coordinators or shuffle servers.
+	ServiceNameEnv = "SERVICE_NAME"
+	// NodeNameEnv indicates environment name of physical node name used by coordinators or shuffle servers.
+	NodeNameEnv = "NODE_NAME"
+	// RssIPEnv indicates environment name of shuffle servers' ip addresses.
+	RssIPEnv = "RSS_IP"
+
+	// CoordinatorServiceName defines environment variable value of "SERVICE_NAME" used by coordinators.
+	CoordinatorServiceName = "coordinator"
+	// ShuffleServerServiceName defines environment variable value of "SERVICE_NAME" used by shuffle servers.
+	ShuffleServerServiceName = "server"
+
+	// ExcludeNodesFile indicates volume mounting name of exclude nodes file
+	ExcludeNodesFile = "exclude-nodes-file"
+
+	// UpdateStatusError means reason of updating status of rss error
+	UpdateStatusError = "UpdateStatusError"
+
+	// OwnerLabel is the label of configMap's owner.
+	OwnerLabel = "data.tencent.io/owner-label"

Review Comment:
   Should we change this from `data.tencent.io` to `org.apache.uniffle`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] thousandhu commented on a diff in pull request #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

Posted by GitBox <gi...@apache.org>.
thousandhu commented on code in PR #214:
URL: https://github.com/apache/incubator-uniffle/pull/214#discussion_r974150643


##########
deploy/kubernetes/operator/pkg/controller/controller/rss.go:
##########
@@ -0,0 +1,925 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package controller
+
+import (
+	"context"
+	"fmt"
+	"strings"
+	"sync"
+	"time"
+
+	appsv1 "k8s.io/api/apps/v1"
+	corev1 "k8s.io/api/core/v1"
+	apierrors "k8s.io/apimachinery/pkg/api/errors"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/labels"
+	"k8s.io/apimachinery/pkg/util/sets"
+	"k8s.io/apimachinery/pkg/util/wait"
+	"k8s.io/client-go/informers"
+	"k8s.io/client-go/kubernetes"
+	appslister "k8s.io/client-go/listers/apps/v1"
+	corelisters "k8s.io/client-go/listers/core/v1"
+	"k8s.io/client-go/tools/cache"
+	"k8s.io/client-go/tools/record"
+	"k8s.io/client-go/util/retry"
+	"k8s.io/client-go/util/workqueue"
+	"k8s.io/klog/v2"
+	"k8s.io/utils/pointer"
+	"sigs.k8s.io/controller-runtime/pkg/manager"
+
+	unifflev1alpha1 "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/api/uniffle/v1alpha1"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/constants"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/config"
+	controllerconstants "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/constants"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/sync/coordinator"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util"
+	kubeutil "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util/kubernetes"
+	propertiestutil "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util/properties"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/clientset/versioned"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/informers/externalversions"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/listers/uniffle/v1alpha1"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/utils"
+)
+
+var _ RSSController = &rssController{}
+
+const (
+	controllerName = "rss-controller"
+	appNameIndexer = "AppNameIndexer"
+)
+
+// RSSController is responsible for synchronizing rss objects.
+type RSSController interface {
+	manager.Runnable
+}
+
+// NewRSSController creates a RSSController.
+func NewRSSController(cfg *config.Config) RSSController {
+	return newRSSController(cfg)
+}
+
+// newRSSController creates a rssController.
+func newRSSController(cfg *config.Config) *rssController {
+	rc := &rssController{
+		workers:                      cfg.Workers,
+		kubeClient:                   cfg.KubeClient,
+		rssClient:                    cfg.RSSClient,
+		rssInformerFactory:           externalversions.NewSharedInformerFactory(cfg.RSSClient, 0),
+		shuffleServerInformerFactory: utils.BuildShuffleServerInformerFactory(cfg.KubeClient),
+		coordinatorInformerFactory:   utils.BuildCoordinatorInformerFactory(cfg.KubeClient),
+		rssQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(),
+			"rss-queue"),
+		shuffleServerQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(),
+			"pod-queue"),
+		eventRecorder: util.CreateRecorder(cfg.KubeClient, "rss-controller"),
+	}
+
+	rssInformer := rc.rssInformerFactory.Uniffle().V1alpha1().RemoteShuffleServices().Informer()
+	rssInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
+		AddFunc:    rc.addRSS,
+		UpdateFunc: rc.updateRSS,
+	})
+	rc.rssInformer = rssInformer
+	rc.rssLister = rc.rssInformerFactory.Uniffle().V1alpha1().RemoteShuffleServices().Lister()
+
+	rc.stsInformer = rc.shuffleServerInformerFactory.Apps().V1().StatefulSets().Informer()
+	rc.stsLister = rc.shuffleServerInformerFactory.Apps().V1().StatefulSets().Lister()
+
+	rc.podInformer = rc.shuffleServerInformerFactory.Core().V1().Pods().Informer()
+	rc.podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
+		DeleteFunc: rc.deleteShuffleServer,
+	})
+	if err := rc.podInformer.AddIndexers(cache.Indexers{appNameIndexer: getAppName}); err != nil {
+		klog.Fatalf("add app name indexer failed: %v", err)
+	}
+	rc.podIndexer = rc.podInformer.GetIndexer()
+	rc.podLister = rc.shuffleServerInformerFactory.Core().V1().Pods().Lister()
+
+	rc.cmInformer = rc.coordinatorInformerFactory.Core().V1().ConfigMaps().Informer()
+	rc.cmLister = rc.coordinatorInformerFactory.Core().V1().ConfigMaps().Lister()
+
+	return rc
+}
+
+// rssController implements the RSSController interface.
+type rssController struct {
+	workers                      int
+	kubeClient                   kubernetes.Interface
+	rssClient                    versioned.Interface
+	rssInformerFactory           externalversions.SharedInformerFactory
+	rssInformer                  cache.SharedIndexInformer
+	rssLister                    v1alpha1.RemoteShuffleServiceLister
+	shuffleServerInformerFactory informers.SharedInformerFactory
+	stsInformer                  cache.SharedIndexInformer
+	stsLister                    appslister.StatefulSetLister
+	podInformer                  cache.SharedIndexInformer
+	podIndexer                   cache.Indexer
+	podLister                    corelisters.PodLister
+	coordinatorInformerFactory   informers.SharedInformerFactory
+	cmInformer                   cache.SharedIndexInformer
+	cmLister                     corelisters.ConfigMapLister
+	rssQueue                     workqueue.RateLimitingInterface
+	shuffleServerQueue           workqueue.RateLimitingInterface
+	eventRecorder                record.EventRecorder
+}
+
+// Start starts the RSSController.
+func (r *rssController) Start(ctx context.Context) error {
+	klog.V(2).Infof("%v is starting", controllerName)
+	r.rssInformerFactory.Start(ctx.Done())
+	r.shuffleServerInformerFactory.Start(ctx.Done())
+	r.coordinatorInformerFactory.Start(ctx.Done())
+	if !cache.WaitForCacheSync(ctx.Done(), r.rssInformer.HasSynced, r.stsInformer.HasSynced,
+		r.podInformer.HasSynced, r.cmInformer.HasSynced) {
+		return fmt.Errorf("wait for cache synced failed")
+	}
+	klog.V(2).Infof("%v started", controllerName)
+	for i := 0; i < r.workers; i++ {
+		go wait.Until(r.runRssWorker, time.Second, ctx.Done())
+	}
+	for i := 0; i < r.workers; i++ {
+		go wait.Until(r.runShuffleServerWorker, time.Second, ctx.Done())
+	}
+	<-ctx.Done()
+	return nil
+}
+
+// runRssWorker runs a thread that dequeues rss objects, handles them, and marks them done.
+func (r *rssController) runRssWorker() {
+	for r.processNextWorkRss() {
+	}
+}
+
+// processNextWorkRss deals with one rss key off the rssQueue, it returns false when it's time to quit.
+func (r *rssController) processNextWorkRss() bool {
+	rssKey, quit := r.rssQueue.Get()
+	if quit {
+		return false
+	}
+	defer r.rssQueue.Done(rssKey)
+
+	pvcNamespace, pvcName, err := cache.SplitMetaNamespaceKey(rssKey.(string))

Review Comment:
   why using pvcName here



##########
deploy/kubernetes/operator/pkg/controller/controller/rss.go:
##########
@@ -0,0 +1,925 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package controller
+
+import (
+	"context"
+	"fmt"
+	"strings"
+	"sync"
+	"time"
+
+	appsv1 "k8s.io/api/apps/v1"
+	corev1 "k8s.io/api/core/v1"
+	apierrors "k8s.io/apimachinery/pkg/api/errors"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/labels"
+	"k8s.io/apimachinery/pkg/util/sets"
+	"k8s.io/apimachinery/pkg/util/wait"
+	"k8s.io/client-go/informers"
+	"k8s.io/client-go/kubernetes"
+	appslister "k8s.io/client-go/listers/apps/v1"
+	corelisters "k8s.io/client-go/listers/core/v1"
+	"k8s.io/client-go/tools/cache"
+	"k8s.io/client-go/tools/record"
+	"k8s.io/client-go/util/retry"
+	"k8s.io/client-go/util/workqueue"
+	"k8s.io/klog/v2"
+	"k8s.io/utils/pointer"
+	"sigs.k8s.io/controller-runtime/pkg/manager"
+
+	unifflev1alpha1 "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/api/uniffle/v1alpha1"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/constants"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/config"
+	controllerconstants "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/constants"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/sync/coordinator"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util"
+	kubeutil "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util/kubernetes"
+	propertiestutil "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util/properties"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/clientset/versioned"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/informers/externalversions"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/listers/uniffle/v1alpha1"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/utils"
+)
+
+var _ RSSController = &rssController{}
+
+const (
+	controllerName = "rss-controller"
+	appNameIndexer = "AppNameIndexer"
+)
+
+// RSSController is responsible for synchronizing rss objects.
+type RSSController interface {
+	manager.Runnable
+}
+
+// NewRSSController creates a RSSController.
+func NewRSSController(cfg *config.Config) RSSController {
+	return newRSSController(cfg)
+}
+
+// newRSSController creates a rssController.
+func newRSSController(cfg *config.Config) *rssController {
+	rc := &rssController{
+		workers:                      cfg.Workers,
+		kubeClient:                   cfg.KubeClient,
+		rssClient:                    cfg.RSSClient,
+		rssInformerFactory:           externalversions.NewSharedInformerFactory(cfg.RSSClient, 0),
+		shuffleServerInformerFactory: utils.BuildShuffleServerInformerFactory(cfg.KubeClient),
+		coordinatorInformerFactory:   utils.BuildCoordinatorInformerFactory(cfg.KubeClient),
+		rssQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(),
+			"rss-queue"),
+		shuffleServerQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(),
+			"pod-queue"),
+		eventRecorder: util.CreateRecorder(cfg.KubeClient, "rss-controller"),
+	}
+
+	rssInformer := rc.rssInformerFactory.Uniffle().V1alpha1().RemoteShuffleServices().Informer()
+	rssInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
+		AddFunc:    rc.addRSS,
+		UpdateFunc: rc.updateRSS,
+	})
+	rc.rssInformer = rssInformer
+	rc.rssLister = rc.rssInformerFactory.Uniffle().V1alpha1().RemoteShuffleServices().Lister()
+
+	rc.stsInformer = rc.shuffleServerInformerFactory.Apps().V1().StatefulSets().Informer()
+	rc.stsLister = rc.shuffleServerInformerFactory.Apps().V1().StatefulSets().Lister()
+
+	rc.podInformer = rc.shuffleServerInformerFactory.Core().V1().Pods().Informer()
+	rc.podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
+		DeleteFunc: rc.deleteShuffleServer,
+	})
+	if err := rc.podInformer.AddIndexers(cache.Indexers{appNameIndexer: getAppName}); err != nil {
+		klog.Fatalf("add app name indexer failed: %v", err)
+	}
+	rc.podIndexer = rc.podInformer.GetIndexer()
+	rc.podLister = rc.shuffleServerInformerFactory.Core().V1().Pods().Lister()
+
+	rc.cmInformer = rc.coordinatorInformerFactory.Core().V1().ConfigMaps().Informer()
+	rc.cmLister = rc.coordinatorInformerFactory.Core().V1().ConfigMaps().Lister()
+
+	return rc
+}
+
+// rssController implements the RSSController interface.
+type rssController struct {
+	workers                      int
+	kubeClient                   kubernetes.Interface
+	rssClient                    versioned.Interface
+	rssInformerFactory           externalversions.SharedInformerFactory
+	rssInformer                  cache.SharedIndexInformer
+	rssLister                    v1alpha1.RemoteShuffleServiceLister
+	shuffleServerInformerFactory informers.SharedInformerFactory
+	stsInformer                  cache.SharedIndexInformer
+	stsLister                    appslister.StatefulSetLister
+	podInformer                  cache.SharedIndexInformer
+	podIndexer                   cache.Indexer
+	podLister                    corelisters.PodLister
+	coordinatorInformerFactory   informers.SharedInformerFactory
+	cmInformer                   cache.SharedIndexInformer
+	cmLister                     corelisters.ConfigMapLister
+	rssQueue                     workqueue.RateLimitingInterface
+	shuffleServerQueue           workqueue.RateLimitingInterface
+	eventRecorder                record.EventRecorder
+}
+
+// Start starts the RSSController.
+func (r *rssController) Start(ctx context.Context) error {
+	klog.V(2).Infof("%v is starting", controllerName)
+	r.rssInformerFactory.Start(ctx.Done())
+	r.shuffleServerInformerFactory.Start(ctx.Done())
+	r.coordinatorInformerFactory.Start(ctx.Done())
+	if !cache.WaitForCacheSync(ctx.Done(), r.rssInformer.HasSynced, r.stsInformer.HasSynced,
+		r.podInformer.HasSynced, r.cmInformer.HasSynced) {
+		return fmt.Errorf("wait for cache synced failed")
+	}
+	klog.V(2).Infof("%v started", controllerName)
+	for i := 0; i < r.workers; i++ {
+		go wait.Until(r.runRssWorker, time.Second, ctx.Done())
+	}
+	for i := 0; i < r.workers; i++ {
+		go wait.Until(r.runShuffleServerWorker, time.Second, ctx.Done())
+	}
+	<-ctx.Done()
+	return nil
+}
+
+// runRssWorker runs a thread that dequeues rss objects, handles them, and marks them done.
+func (r *rssController) runRssWorker() {
+	for r.processNextWorkRss() {
+	}
+}
+
+// processNextWorkRss deals with one rss key off the rssQueue, it returns false when it's time to quit.
+func (r *rssController) processNextWorkRss() bool {
+	rssKey, quit := r.rssQueue.Get()
+	if quit {
+		return false
+	}
+	defer r.rssQueue.Done(rssKey)
+
+	pvcNamespace, pvcName, err := cache.SplitMetaNamespaceKey(rssKey.(string))
+	if err != nil {
+		klog.Errorf("parsed rss key (%v) failed: %v", rssKey, err)
+		return true
+	}
+
+	var retryChecking bool
+	retryChecking, err = r.processRss(pvcNamespace, pvcName)
+	if err != nil {
+		klog.Errorf("processed rss %v failed : %v", rssKey, err)
+		r.rssQueue.AddRateLimited(rssKey)
+	} else if retryChecking {
+		klog.V(4).Infof("we will retry checking rss (%v) for upgrading or terminating", rssKey)
+		r.rssQueue.AddAfter(rssKey, time.Second*3)
+	} else {
+		r.rssQueue.Forget(rssKey)
+	}
+	return true
+}
+
+// runShuffleServerWorker runs a thread that dequeues shuffle server pods, handles them, and marks them done.
+func (r *rssController) runShuffleServerWorker() {
+	for r.processNextWorkShuffleServer() {
+	}
+}
+
+// processNextWorkShuffleServer deals with one shuffle server pod key off the shuffleServerQueue,
+// it returns false when it's time to quit.
+func (r *rssController) processNextWorkShuffleServer() bool {
+	key, quit := r.shuffleServerQueue.Get()
+	if quit {
+		return false
+	}
+	defer r.shuffleServerQueue.Done(key)
+
+	err := r.processShuffleServer(key.(string))
+	if err == nil {
+		r.shuffleServerQueue.Forget(key)
+		return true
+	}
+
+	klog.Errorf("processed shuffle server %v failed : %v", key, err)
+	r.shuffleServerQueue.AddRateLimited(key)
+	return true
+}
+
+// processShuffleServer process current shuffle server pod key.
+func (r *rssController) processShuffleServer(key string) error {
+	klog.V(4).Infof("processing shuffle server (%v)", key)
+	namespace, rssName, currentKey := parsePodCacheKey(key)
+	rss, err := r.rssLister.RemoteShuffleServices(namespace).Get(rssName)
+	if err != nil {
+		klog.Errorf("get rss by key (%v) failed: %v", key, err)
+		if !apierrors.IsNotFound(err) {
+			return err
+		}
+		return nil
+	}
+
+	return r.updateTargetAndDeletedKeys(rss, currentKey)
+}
+
+// updateTargetAndDeletedKeys updates target and deleted keys in status of rss objects.
+func (r *rssController) updateTargetAndDeletedKeys(rss *unifflev1alpha1.RemoteShuffleService, shuffleServerKey string) error {
+	deletedKeys := sets.NewString(rss.Status.DeletedKeys...)
+	if deletedKeys.Has(shuffleServerKey) {
+		klog.V(3).Infof("shuffle server (%v) has already been deleted for rss (%v)",
+			shuffleServerKey, utils.UniqueName(rss))
+		return nil
+	}
+
+	deletedKeys.Insert(shuffleServerKey)
+	oldTargetKeys := sets.NewString(rss.Status.TargetKeys...)
+	newTargetKeys := oldTargetKeys.Difference(deletedKeys)
+
+	cm, err := r.getExcludeNodesCM(rss)
+	if err != nil {
+		klog.Errorf("get exclude nodes in configMap for rss (%v) failed: %v",
+			utils.UniqueName(rss), err)
+		return err
+	}
+
+	// calculate new exclude nodes.
+	excludeNodesFileKey := utils.GetExcludeNodesConfigMapKey(rss)
+	oldExcludeNodes := sets.NewString(strings.Split(
+		cm.Data[excludeNodesFileKey], "\n")...)
+	newExcludeNodes := utils.ConvertShuffleServerKeysToNodes(newTargetKeys)
+	if !newExcludeNodes.Equal(oldExcludeNodes) {
+		cmCopy := cm.DeepCopy()
+		cmCopy.Data[excludeNodesFileKey] = strings.Join(
+			utils.GetSortedList(newExcludeNodes), "\n")
+		if _, err = r.kubeClient.CoreV1().ConfigMaps(cmCopy.Namespace).
+			Update(context.Background(), cmCopy, metav1.UpdateOptions{}); err != nil {
+			klog.Errorf("update exclude nodes in configMap (%v) for rss (%v) failed: %v",
+				cmCopy.Name, utils.UniqueName(rss), err)
+			return err
+		}
+	}
+
+	if err = r.updateDeletedKeys(rss, shuffleServerKey); err != nil {
+		klog.Errorf("add (%v) to deleted keys of rss (%v) failed: %v",
+			shuffleServerKey, utils.UniqueName(rss), err)
+		return err
+	}
+	return nil
+}
+
+func (r *rssController) clearExcludeNodes(rss *unifflev1alpha1.RemoteShuffleService) error {
+	cm, err := r.getExcludeNodesCM(rss)
+	if err != nil {
+		klog.Errorf("get exclude nodes in configMap for rss (%v) failed: %v",
+			utils.UniqueName(rss), err)
+		return err
+	}
+	cmCopy := cm.DeepCopy()
+	cmCopy.Data[utils.GetExcludeNodesConfigMapKey(rss)] = ""
+	if _, err = r.kubeClient.CoreV1().ConfigMaps(cmCopy.Namespace).
+		Update(context.Background(), cmCopy, metav1.UpdateOptions{}); err != nil {
+		klog.Errorf("update exclude nodes in configMap (%v) for rss (%v) failed: %v",
+			cmCopy.Name, utils.UniqueName(rss), err)
+		return err
+	}
+	return nil
+}
+
+// getExcludeNodesCM returns configMap records exclude nodes.
+func (r *rssController) getExcludeNodesCM(rss *unifflev1alpha1.RemoteShuffleService) (
+	*corev1.ConfigMap, error) {
+	namespace := rss.Namespace
+	name := utils.GenerateCoordinatorName(rss)
+	cm, err := r.cmLister.ConfigMaps(namespace).Get(name)
+	if err != nil {
+		klog.Errorf("get configMap (%v) for rss failed: %v", name, utils.UniqueName(rss), err)
+		return nil, err
+	}
+	return cm, nil
+}
+
+// updateDeletedKeys updates deleted keys in status of rss.
+func (r *rssController) updateDeletedKeys(rss *unifflev1alpha1.RemoteShuffleService,
+	key string) error {
+	if rss.Status.Phase != unifflev1alpha1.RSSUpgrading && rss.Status.Phase != unifflev1alpha1.RSSTerminating {
+		return nil
+	}
+	rssStatus := rss.Status.DeepCopy()
+	rssStatus.DeletedKeys = utils.GetSortedList(sets.NewString(rssStatus.DeletedKeys...).Insert(key))
+	return r.updateRssStatus(rss, rssStatus)
+}
+
+// processRss process current rss by its namespace and name, and returns if we need to try again to check upgrading.
+func (r *rssController) processRss(namespace, name string) (bool, error) {
+	klog.V(4).Infof("processing rss (%v/%v)", namespace, name)
+	startTime := time.Now()
+	defer func() {
+		klog.V(4).Infof("finished processing rss (%v/%v) cost %v",
+			namespace, name, time.Since(startTime))
+	}()
+
+	rss, err := r.rssLister.RemoteShuffleServices(namespace).Get(name)
+	if err != nil {
+		if apierrors.IsNotFound(err) {
+			klog.V(5).Infof("ignored deleted rss (%v/%v)", namespace, name)
+			return false, nil
+		}
+		klog.Errorf("get rss (%v/%v) failed: %v", namespace, name, err)
+		return false, err
+	}
+
+	if isDeletionCandidate(rss) {
+		return r.processDeleting(rss)

Review Comment:
   Should we have an else path here when the  rss has deletionTimestamp and doesn't have rss finalizer?
   Otherwise this function may go into  r.processNormal after rss being deleted.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on pull request #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

Posted by GitBox <gi...@apache.org>.
jerqi commented on PR #214:
URL: https://github.com/apache/incubator-uniffle/pull/214#issuecomment-1246586316

   Like discussion at dev mail list, we will freeze the code and cut 0.6 version branch in September 15, we  will not merge this pr before I cut 0.6 version branch, are you ok?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] wangao1236 commented on a diff in pull request #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

Posted by GitBox <gi...@apache.org>.
wangao1236 commented on code in PR #214:
URL: https://github.com/apache/incubator-uniffle/pull/214#discussion_r970264363


##########
deploy/kubernetes/operator/pkg/controller/constants/constants.go:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package constants
+
+const (
+	// ContainerShuffleServerRPCPort indicates rpc port used in shuffle server containers.
+	ContainerShuffleServerRPCPort int32 = 19997
+	// ContainerShuffleServerHTTPPort indicates http port used in shuffle server containers.
+	ContainerShuffleServerHTTPPort int32 = 19996
+	// ContainerCoordinatorRPCPort indicates rpc port used in coordinator containers.
+	ContainerCoordinatorRPCPort int32 = 19997
+	// ContainerCoordinatorHTTPPort indicates http port used in coordinator containers.
+	ContainerCoordinatorHTTPPort int32 = 19996
+
+	// ShuffleServerRPCPortEnv indicates environment name of rpc port used by shuffle servers.
+	ShuffleServerRPCPortEnv = "SERVER_RPC_PORT"
+	// ShuffleServerHTTPPortEnv indicates environment name of http port used by shuffle servers.
+	ShuffleServerHTTPPortEnv = "SERVER_HTTP_PORT"
+	// CoordinatorRPCPortEnv indicates environment name of rpc port used by coordinators.
+	CoordinatorRPCPortEnv = "COORDINATOR_RPC_PORT"
+	// CoordinatorHTTPPortEnv indicates environment name of http port used by coordinators.
+	CoordinatorHTTPPortEnv = "COORDINATOR_HTTP_PORT"
+	// RSSCoordinatorQuorumEnv indicates environment name of rss coordinator quorum used by shuffle servers.
+	RSSCoordinatorQuorumEnv = "RSS_COORDINATOR_QUORUM"
+	// XmxSizeEnv indicates environment name of xmx size used by coordinators or shuffle servers.
+	XmxSizeEnv = "XMX_SIZE"
+	// ServiceNameEnv indicates environment name of service name used by coordinators or shuffle servers.
+	ServiceNameEnv = "SERVICE_NAME"
+	// NodeNameEnv indicates environment name of physical node name used by coordinators or shuffle servers.
+	NodeNameEnv = "NODE_NAME"
+	// RssIPEnv indicates environment name of shuffle servers' ip addresses.
+	RssIPEnv = "RSS_IP"
+
+	// CoordinatorServiceName defines environment variable value of "SERVICE_NAME" used by coordinators.
+	CoordinatorServiceName = "coordinator"
+	// ShuffleServerServiceName defines environment variable value of "SERVICE_NAME" used by shuffle servers.
+	ShuffleServerServiceName = "server"
+
+	// ExcludeNodesFile indicates volume mounting name of exclude nodes file
+	ExcludeNodesFile = "exclude-nodes-file"
+
+	// UpdateStatusError means reason of updating status of rss error
+	UpdateStatusError = "UpdateStatusError"
+
+	// OwnerLabel is the label of configMap's owner.
+	OwnerLabel = "data.tencent.io/owner-label"

Review Comment:
   Sorry, I miss it, I have modified.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] wangao1236 commented on a diff in pull request #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

Posted by GitBox <gi...@apache.org>.
wangao1236 commented on code in PR #214:
URL: https://github.com/apache/incubator-uniffle/pull/214#discussion_r974827263


##########
deploy/kubernetes/operator/pkg/controller/controller/rss.go:
##########
@@ -0,0 +1,925 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package controller
+
+import (
+	"context"
+	"fmt"
+	"strings"
+	"sync"
+	"time"
+
+	appsv1 "k8s.io/api/apps/v1"
+	corev1 "k8s.io/api/core/v1"
+	apierrors "k8s.io/apimachinery/pkg/api/errors"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/labels"
+	"k8s.io/apimachinery/pkg/util/sets"
+	"k8s.io/apimachinery/pkg/util/wait"
+	"k8s.io/client-go/informers"
+	"k8s.io/client-go/kubernetes"
+	appslister "k8s.io/client-go/listers/apps/v1"
+	corelisters "k8s.io/client-go/listers/core/v1"
+	"k8s.io/client-go/tools/cache"
+	"k8s.io/client-go/tools/record"
+	"k8s.io/client-go/util/retry"
+	"k8s.io/client-go/util/workqueue"
+	"k8s.io/klog/v2"
+	"k8s.io/utils/pointer"
+	"sigs.k8s.io/controller-runtime/pkg/manager"
+
+	unifflev1alpha1 "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/api/uniffle/v1alpha1"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/constants"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/config"
+	controllerconstants "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/constants"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/sync/coordinator"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util"
+	kubeutil "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util/kubernetes"
+	propertiestutil "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util/properties"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/clientset/versioned"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/informers/externalversions"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/listers/uniffle/v1alpha1"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/utils"
+)
+
+var _ RSSController = &rssController{}
+
+const (
+	controllerName = "rss-controller"
+	appNameIndexer = "AppNameIndexer"
+)
+
+// RSSController is responsible for synchronizing rss objects.
+type RSSController interface {
+	manager.Runnable
+}
+
+// NewRSSController creates a RSSController.
+func NewRSSController(cfg *config.Config) RSSController {
+	return newRSSController(cfg)
+}
+
+// newRSSController creates a rssController.
+func newRSSController(cfg *config.Config) *rssController {
+	rc := &rssController{
+		workers:                      cfg.Workers,
+		kubeClient:                   cfg.KubeClient,
+		rssClient:                    cfg.RSSClient,
+		rssInformerFactory:           externalversions.NewSharedInformerFactory(cfg.RSSClient, 0),
+		shuffleServerInformerFactory: utils.BuildShuffleServerInformerFactory(cfg.KubeClient),
+		coordinatorInformerFactory:   utils.BuildCoordinatorInformerFactory(cfg.KubeClient),
+		rssQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(),
+			"rss-queue"),
+		shuffleServerQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(),
+			"pod-queue"),
+		eventRecorder: util.CreateRecorder(cfg.KubeClient, "rss-controller"),
+	}
+
+	rssInformer := rc.rssInformerFactory.Uniffle().V1alpha1().RemoteShuffleServices().Informer()
+	rssInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
+		AddFunc:    rc.addRSS,
+		UpdateFunc: rc.updateRSS,
+	})
+	rc.rssInformer = rssInformer
+	rc.rssLister = rc.rssInformerFactory.Uniffle().V1alpha1().RemoteShuffleServices().Lister()
+
+	rc.stsInformer = rc.shuffleServerInformerFactory.Apps().V1().StatefulSets().Informer()
+	rc.stsLister = rc.shuffleServerInformerFactory.Apps().V1().StatefulSets().Lister()
+
+	rc.podInformer = rc.shuffleServerInformerFactory.Core().V1().Pods().Informer()
+	rc.podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
+		DeleteFunc: rc.deleteShuffleServer,
+	})
+	if err := rc.podInformer.AddIndexers(cache.Indexers{appNameIndexer: getAppName}); err != nil {
+		klog.Fatalf("add app name indexer failed: %v", err)
+	}
+	rc.podIndexer = rc.podInformer.GetIndexer()
+	rc.podLister = rc.shuffleServerInformerFactory.Core().V1().Pods().Lister()
+
+	rc.cmInformer = rc.coordinatorInformerFactory.Core().V1().ConfigMaps().Informer()
+	rc.cmLister = rc.coordinatorInformerFactory.Core().V1().ConfigMaps().Lister()
+
+	return rc
+}
+
+// rssController implements the RSSController interface.
+type rssController struct {
+	workers                      int
+	kubeClient                   kubernetes.Interface
+	rssClient                    versioned.Interface
+	rssInformerFactory           externalversions.SharedInformerFactory
+	rssInformer                  cache.SharedIndexInformer
+	rssLister                    v1alpha1.RemoteShuffleServiceLister
+	shuffleServerInformerFactory informers.SharedInformerFactory
+	stsInformer                  cache.SharedIndexInformer
+	stsLister                    appslister.StatefulSetLister
+	podInformer                  cache.SharedIndexInformer
+	podIndexer                   cache.Indexer
+	podLister                    corelisters.PodLister
+	coordinatorInformerFactory   informers.SharedInformerFactory
+	cmInformer                   cache.SharedIndexInformer
+	cmLister                     corelisters.ConfigMapLister
+	rssQueue                     workqueue.RateLimitingInterface
+	shuffleServerQueue           workqueue.RateLimitingInterface
+	eventRecorder                record.EventRecorder
+}
+
+// Start starts the RSSController.
+func (r *rssController) Start(ctx context.Context) error {
+	klog.V(2).Infof("%v is starting", controllerName)
+	r.rssInformerFactory.Start(ctx.Done())
+	r.shuffleServerInformerFactory.Start(ctx.Done())
+	r.coordinatorInformerFactory.Start(ctx.Done())
+	if !cache.WaitForCacheSync(ctx.Done(), r.rssInformer.HasSynced, r.stsInformer.HasSynced,
+		r.podInformer.HasSynced, r.cmInformer.HasSynced) {
+		return fmt.Errorf("wait for cache synced failed")
+	}
+	klog.V(2).Infof("%v started", controllerName)
+	for i := 0; i < r.workers; i++ {
+		go wait.Until(r.runRssWorker, time.Second, ctx.Done())
+	}
+	for i := 0; i < r.workers; i++ {
+		go wait.Until(r.runShuffleServerWorker, time.Second, ctx.Done())
+	}
+	<-ctx.Done()
+	return nil
+}
+
+// runRssWorker runs a thread that dequeues rss objects, handles them, and marks them done.
+func (r *rssController) runRssWorker() {
+	for r.processNextWorkRss() {
+	}
+}
+
+// processNextWorkRss deals with one rss key off the rssQueue, it returns false when it's time to quit.
+func (r *rssController) processNextWorkRss() bool {
+	rssKey, quit := r.rssQueue.Get()
+	if quit {
+		return false
+	}
+	defer r.rssQueue.Done(rssKey)
+
+	pvcNamespace, pvcName, err := cache.SplitMetaNamespaceKey(rssKey.(string))

Review Comment:
   Ok, I have modified this place.



##########
deploy/kubernetes/operator/pkg/controller/controller/rss.go:
##########
@@ -0,0 +1,925 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package controller
+
+import (
+	"context"
+	"fmt"
+	"strings"
+	"sync"
+	"time"
+
+	appsv1 "k8s.io/api/apps/v1"
+	corev1 "k8s.io/api/core/v1"
+	apierrors "k8s.io/apimachinery/pkg/api/errors"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/labels"
+	"k8s.io/apimachinery/pkg/util/sets"
+	"k8s.io/apimachinery/pkg/util/wait"
+	"k8s.io/client-go/informers"
+	"k8s.io/client-go/kubernetes"
+	appslister "k8s.io/client-go/listers/apps/v1"
+	corelisters "k8s.io/client-go/listers/core/v1"
+	"k8s.io/client-go/tools/cache"
+	"k8s.io/client-go/tools/record"
+	"k8s.io/client-go/util/retry"
+	"k8s.io/client-go/util/workqueue"
+	"k8s.io/klog/v2"
+	"k8s.io/utils/pointer"
+	"sigs.k8s.io/controller-runtime/pkg/manager"
+
+	unifflev1alpha1 "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/api/uniffle/v1alpha1"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/constants"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/config"
+	controllerconstants "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/constants"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/sync/coordinator"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util"
+	kubeutil "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util/kubernetes"
+	propertiestutil "github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/controller/util/properties"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/clientset/versioned"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/informers/externalversions"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/generated/listers/uniffle/v1alpha1"
+	"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/utils"
+)
+
+var _ RSSController = &rssController{}
+
+const (
+	controllerName = "rss-controller"
+	appNameIndexer = "AppNameIndexer"
+)
+
+// RSSController is responsible for synchronizing rss objects.
+type RSSController interface {
+	manager.Runnable
+}
+
+// NewRSSController creates a RSSController.
+func NewRSSController(cfg *config.Config) RSSController {
+	return newRSSController(cfg)
+}
+
+// newRSSController creates a rssController.
+func newRSSController(cfg *config.Config) *rssController {
+	rc := &rssController{
+		workers:                      cfg.Workers,
+		kubeClient:                   cfg.KubeClient,
+		rssClient:                    cfg.RSSClient,
+		rssInformerFactory:           externalversions.NewSharedInformerFactory(cfg.RSSClient, 0),
+		shuffleServerInformerFactory: utils.BuildShuffleServerInformerFactory(cfg.KubeClient),
+		coordinatorInformerFactory:   utils.BuildCoordinatorInformerFactory(cfg.KubeClient),
+		rssQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(),
+			"rss-queue"),
+		shuffleServerQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(),
+			"pod-queue"),
+		eventRecorder: util.CreateRecorder(cfg.KubeClient, "rss-controller"),
+	}
+
+	rssInformer := rc.rssInformerFactory.Uniffle().V1alpha1().RemoteShuffleServices().Informer()
+	rssInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
+		AddFunc:    rc.addRSS,
+		UpdateFunc: rc.updateRSS,
+	})
+	rc.rssInformer = rssInformer
+	rc.rssLister = rc.rssInformerFactory.Uniffle().V1alpha1().RemoteShuffleServices().Lister()
+
+	rc.stsInformer = rc.shuffleServerInformerFactory.Apps().V1().StatefulSets().Informer()
+	rc.stsLister = rc.shuffleServerInformerFactory.Apps().V1().StatefulSets().Lister()
+
+	rc.podInformer = rc.shuffleServerInformerFactory.Core().V1().Pods().Informer()
+	rc.podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
+		DeleteFunc: rc.deleteShuffleServer,
+	})
+	if err := rc.podInformer.AddIndexers(cache.Indexers{appNameIndexer: getAppName}); err != nil {
+		klog.Fatalf("add app name indexer failed: %v", err)
+	}
+	rc.podIndexer = rc.podInformer.GetIndexer()
+	rc.podLister = rc.shuffleServerInformerFactory.Core().V1().Pods().Lister()
+
+	rc.cmInformer = rc.coordinatorInformerFactory.Core().V1().ConfigMaps().Informer()
+	rc.cmLister = rc.coordinatorInformerFactory.Core().V1().ConfigMaps().Lister()
+
+	return rc
+}
+
+// rssController implements the RSSController interface.
+type rssController struct {
+	workers                      int
+	kubeClient                   kubernetes.Interface
+	rssClient                    versioned.Interface
+	rssInformerFactory           externalversions.SharedInformerFactory
+	rssInformer                  cache.SharedIndexInformer
+	rssLister                    v1alpha1.RemoteShuffleServiceLister
+	shuffleServerInformerFactory informers.SharedInformerFactory
+	stsInformer                  cache.SharedIndexInformer
+	stsLister                    appslister.StatefulSetLister
+	podInformer                  cache.SharedIndexInformer
+	podIndexer                   cache.Indexer
+	podLister                    corelisters.PodLister
+	coordinatorInformerFactory   informers.SharedInformerFactory
+	cmInformer                   cache.SharedIndexInformer
+	cmLister                     corelisters.ConfigMapLister
+	rssQueue                     workqueue.RateLimitingInterface
+	shuffleServerQueue           workqueue.RateLimitingInterface
+	eventRecorder                record.EventRecorder
+}
+
+// Start starts the RSSController.
+func (r *rssController) Start(ctx context.Context) error {
+	klog.V(2).Infof("%v is starting", controllerName)
+	r.rssInformerFactory.Start(ctx.Done())
+	r.shuffleServerInformerFactory.Start(ctx.Done())
+	r.coordinatorInformerFactory.Start(ctx.Done())
+	if !cache.WaitForCacheSync(ctx.Done(), r.rssInformer.HasSynced, r.stsInformer.HasSynced,
+		r.podInformer.HasSynced, r.cmInformer.HasSynced) {
+		return fmt.Errorf("wait for cache synced failed")
+	}
+	klog.V(2).Infof("%v started", controllerName)
+	for i := 0; i < r.workers; i++ {
+		go wait.Until(r.runRssWorker, time.Second, ctx.Done())
+	}
+	for i := 0; i < r.workers; i++ {
+		go wait.Until(r.runShuffleServerWorker, time.Second, ctx.Done())
+	}
+	<-ctx.Done()
+	return nil
+}
+
+// runRssWorker runs a thread that dequeues rss objects, handles them, and marks them done.
+func (r *rssController) runRssWorker() {
+	for r.processNextWorkRss() {
+	}
+}
+
+// processNextWorkRss deals with one rss key off the rssQueue, it returns false when it's time to quit.
+func (r *rssController) processNextWorkRss() bool {
+	rssKey, quit := r.rssQueue.Get()
+	if quit {
+		return false
+	}
+	defer r.rssQueue.Done(rssKey)
+
+	pvcNamespace, pvcName, err := cache.SplitMetaNamespaceKey(rssKey.(string))
+	if err != nil {
+		klog.Errorf("parsed rss key (%v) failed: %v", rssKey, err)
+		return true
+	}
+
+	var retryChecking bool
+	retryChecking, err = r.processRss(pvcNamespace, pvcName)
+	if err != nil {
+		klog.Errorf("processed rss %v failed : %v", rssKey, err)
+		r.rssQueue.AddRateLimited(rssKey)
+	} else if retryChecking {
+		klog.V(4).Infof("we will retry checking rss (%v) for upgrading or terminating", rssKey)
+		r.rssQueue.AddAfter(rssKey, time.Second*3)
+	} else {
+		r.rssQueue.Forget(rssKey)
+	}
+	return true
+}
+
+// runShuffleServerWorker runs a thread that dequeues shuffle server pods, handles them, and marks them done.
+func (r *rssController) runShuffleServerWorker() {
+	for r.processNextWorkShuffleServer() {
+	}
+}
+
+// processNextWorkShuffleServer deals with one shuffle server pod key off the shuffleServerQueue,
+// it returns false when it's time to quit.
+func (r *rssController) processNextWorkShuffleServer() bool {
+	key, quit := r.shuffleServerQueue.Get()
+	if quit {
+		return false
+	}
+	defer r.shuffleServerQueue.Done(key)
+
+	err := r.processShuffleServer(key.(string))
+	if err == nil {
+		r.shuffleServerQueue.Forget(key)
+		return true
+	}
+
+	klog.Errorf("processed shuffle server %v failed : %v", key, err)
+	r.shuffleServerQueue.AddRateLimited(key)
+	return true
+}
+
+// processShuffleServer process current shuffle server pod key.
+func (r *rssController) processShuffleServer(key string) error {
+	klog.V(4).Infof("processing shuffle server (%v)", key)
+	namespace, rssName, currentKey := parsePodCacheKey(key)
+	rss, err := r.rssLister.RemoteShuffleServices(namespace).Get(rssName)
+	if err != nil {
+		klog.Errorf("get rss by key (%v) failed: %v", key, err)
+		if !apierrors.IsNotFound(err) {
+			return err
+		}
+		return nil
+	}
+
+	return r.updateTargetAndDeletedKeys(rss, currentKey)
+}
+
+// updateTargetAndDeletedKeys updates target and deleted keys in status of rss objects.
+func (r *rssController) updateTargetAndDeletedKeys(rss *unifflev1alpha1.RemoteShuffleService, shuffleServerKey string) error {
+	deletedKeys := sets.NewString(rss.Status.DeletedKeys...)
+	if deletedKeys.Has(shuffleServerKey) {
+		klog.V(3).Infof("shuffle server (%v) has already been deleted for rss (%v)",
+			shuffleServerKey, utils.UniqueName(rss))
+		return nil
+	}
+
+	deletedKeys.Insert(shuffleServerKey)
+	oldTargetKeys := sets.NewString(rss.Status.TargetKeys...)
+	newTargetKeys := oldTargetKeys.Difference(deletedKeys)
+
+	cm, err := r.getExcludeNodesCM(rss)
+	if err != nil {
+		klog.Errorf("get exclude nodes in configMap for rss (%v) failed: %v",
+			utils.UniqueName(rss), err)
+		return err
+	}
+
+	// calculate new exclude nodes.
+	excludeNodesFileKey := utils.GetExcludeNodesConfigMapKey(rss)
+	oldExcludeNodes := sets.NewString(strings.Split(
+		cm.Data[excludeNodesFileKey], "\n")...)
+	newExcludeNodes := utils.ConvertShuffleServerKeysToNodes(newTargetKeys)
+	if !newExcludeNodes.Equal(oldExcludeNodes) {
+		cmCopy := cm.DeepCopy()
+		cmCopy.Data[excludeNodesFileKey] = strings.Join(
+			utils.GetSortedList(newExcludeNodes), "\n")
+		if _, err = r.kubeClient.CoreV1().ConfigMaps(cmCopy.Namespace).
+			Update(context.Background(), cmCopy, metav1.UpdateOptions{}); err != nil {
+			klog.Errorf("update exclude nodes in configMap (%v) for rss (%v) failed: %v",
+				cmCopy.Name, utils.UniqueName(rss), err)
+			return err
+		}
+	}
+
+	if err = r.updateDeletedKeys(rss, shuffleServerKey); err != nil {
+		klog.Errorf("add (%v) to deleted keys of rss (%v) failed: %v",
+			shuffleServerKey, utils.UniqueName(rss), err)
+		return err
+	}
+	return nil
+}
+
+func (r *rssController) clearExcludeNodes(rss *unifflev1alpha1.RemoteShuffleService) error {
+	cm, err := r.getExcludeNodesCM(rss)
+	if err != nil {
+		klog.Errorf("get exclude nodes in configMap for rss (%v) failed: %v",
+			utils.UniqueName(rss), err)
+		return err
+	}
+	cmCopy := cm.DeepCopy()
+	cmCopy.Data[utils.GetExcludeNodesConfigMapKey(rss)] = ""
+	if _, err = r.kubeClient.CoreV1().ConfigMaps(cmCopy.Namespace).
+		Update(context.Background(), cmCopy, metav1.UpdateOptions{}); err != nil {
+		klog.Errorf("update exclude nodes in configMap (%v) for rss (%v) failed: %v",
+			cmCopy.Name, utils.UniqueName(rss), err)
+		return err
+	}
+	return nil
+}
+
+// getExcludeNodesCM returns configMap records exclude nodes.
+func (r *rssController) getExcludeNodesCM(rss *unifflev1alpha1.RemoteShuffleService) (
+	*corev1.ConfigMap, error) {
+	namespace := rss.Namespace
+	name := utils.GenerateCoordinatorName(rss)
+	cm, err := r.cmLister.ConfigMaps(namespace).Get(name)
+	if err != nil {
+		klog.Errorf("get configMap (%v) for rss failed: %v", name, utils.UniqueName(rss), err)
+		return nil, err
+	}
+	return cm, nil
+}
+
+// updateDeletedKeys updates deleted keys in status of rss.
+func (r *rssController) updateDeletedKeys(rss *unifflev1alpha1.RemoteShuffleService,
+	key string) error {
+	if rss.Status.Phase != unifflev1alpha1.RSSUpgrading && rss.Status.Phase != unifflev1alpha1.RSSTerminating {
+		return nil
+	}
+	rssStatus := rss.Status.DeepCopy()
+	rssStatus.DeletedKeys = utils.GetSortedList(sets.NewString(rssStatus.DeletedKeys...).Insert(key))
+	return r.updateRssStatus(rss, rssStatus)
+}
+
+// processRss process current rss by its namespace and name, and returns if we need to try again to check upgrading.
+func (r *rssController) processRss(namespace, name string) (bool, error) {
+	klog.V(4).Infof("processing rss (%v/%v)", namespace, name)
+	startTime := time.Now()
+	defer func() {
+		klog.V(4).Infof("finished processing rss (%v/%v) cost %v",
+			namespace, name, time.Since(startTime))
+	}()
+
+	rss, err := r.rssLister.RemoteShuffleServices(namespace).Get(name)
+	if err != nil {
+		if apierrors.IsNotFound(err) {
+			klog.V(5).Infof("ignored deleted rss (%v/%v)", namespace, name)
+			return false, nil
+		}
+		klog.Errorf("get rss (%v/%v) failed: %v", namespace, name, err)
+		return false, err
+	}
+
+	if isDeletionCandidate(rss) {
+		return r.processDeleting(rss)

Review Comment:
   Ok, I have modified this place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi merged pull request #214: [ISSUE-48][FEATURE][FOLLOW UP] Add controller component

Posted by GitBox <gi...@apache.org>.
jerqi merged PR #214:
URL: https://github.com/apache/incubator-uniffle/pull/214


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org