Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: List&watch mcs and service, reconcile the work in execution namespace #4323

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import (
"github.com/karmada-io/karmada/pkg/controllers/gracefuleviction"
"github.com/karmada-io/karmada/pkg/controllers/hpareplicassyncer"
"github.com/karmada-io/karmada/pkg/controllers/mcs"
"github.com/karmada-io/karmada/pkg/controllers/multiclusterservice"
"github.com/karmada-io/karmada/pkg/controllers/namespace"
"github.com/karmada-io/karmada/pkg/controllers/status"
"github.com/karmada-io/karmada/pkg/controllers/unifiedauth"
Expand Down Expand Up @@ -224,6 +225,7 @@ func init() {
controllers["federatedHorizontalPodAutoscaler"] = startFederatedHorizontalPodAutoscalerController
controllers["cronFederatedHorizontalPodAutoscaler"] = startCronFederatedHorizontalPodAutoscalerController
controllers["hpaReplicasSyncer"] = startHPAReplicasSyncerController
controllers["multiclusterservice"] = startMCSController
}

func startClusterController(ctx controllerscontext.Context) (enabled bool, err error) {
Expand Down Expand Up @@ -631,6 +633,18 @@ func startHPAReplicasSyncerController(ctx controllerscontext.Context) (enabled b
return true, nil
}

func startMCSController(ctx controllerscontext.Context) (enabled bool, err error) {
mcsController := &multiclusterservice.MCSController{
Client: ctx.Mgr.GetClient(),
EventRecorder: ctx.Mgr.GetEventRecorderFor(multiclusterservice.ControllerName),
RateLimiterOptions: ctx.Opts.RateLimiterOptions,
}
if err = mcsController.SetupWithManager(ctx.Mgr); err != nil {
return false, err
}
return true, nil
}

// setupControllers initialize controllers and setup one by one.
func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stopChan <-chan struct{}) {
restConfig := mgr.GetConfig()
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/networking/v1alpha1/service_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const (
ResourcePluralMultiClusterService = "multiclusterservices"
// ResourceNamespaceScopedMultiClusterService indicates if MultiClusterService is NamespaceScoped.
ResourceNamespaceScopedMultiClusterService = true
// MCSServiceAppliedConditionType is indicates the condition type of mcs service applied.
MCSServiceAppliedConditionType = "ServiceApplied"
Comment on lines +33 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the events to pkg/events/events.go.

@jwcesign In my opinion, if we report a warning event and we need to report another normal event to cancel the event, right?

Copy link
Member

@jwcesign jwcesign Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but we should report the normal event.

)

// +genclient
Expand Down
23 changes: 23 additions & 0 deletions pkg/apis/networking/v1alpha1/well_known_constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2023 The Karmada Authors.
Licensed 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 v1alpha1

const (
// MultiClusterServicePermanentIDLabel is the identifier of a MultiClusterService object.
// Karmada generates a unique identifier, such as metadata.UUID, for each MultiClusterService object.
// This identifier will be used as a label selector to locate corresponding work of service.
// The reason for generating a new unique identifier instead of simply using metadata.UUID is because:
// In backup scenarios, when applying the backup resource manifest in a new cluster, the UUID may change.
MultiClusterServicePermanentIDLabel = "multiclusterservice.karmada.io/permanent-id"
)
Loading
Loading