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

1909 #2016

Merged
merged 2 commits into from
Apr 12, 2024
Merged

1909 #2016

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
2 changes: 2 additions & 0 deletions cmd/yurt-manager/app/options/platformadmincontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (n *PlatformAdminControllerOptions) AddFlags(fs *pflag.FlagSet) {
if n == nil {
return
}

fs.Int32Var(&n.ConcurrentPlatformAdminWorkers, "concurrent-platform-administrator-workers", n.ConcurrentPlatformAdminWorkers, "Max concurrent workers for PlatformAdmin controller.")
}

// ApplyTo fills up nodePool config with options.
Expand Down
22 changes: 12 additions & 10 deletions pkg/yurtmanager/controller/platformadmin/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,25 @@ func ExtractRequiredComponentsName(manifest *Manifest, versionName string) sets.

// PlatformAdminControllerConfiguration contains elements describing PlatformAdminController.
type PlatformAdminControllerConfiguration struct {
Manifest Manifest
SecurityComponents map[string][]*Component
NoSectyComponents map[string][]*Component
SecurityConfigMaps map[string][]corev1.ConfigMap
NoSectyConfigMaps map[string][]corev1.ConfigMap
Manifest Manifest
SecurityComponents map[string][]*Component
NoSectyComponents map[string][]*Component
SecurityConfigMaps map[string][]corev1.ConfigMap
NoSectyConfigMaps map[string][]corev1.ConfigMap
ConcurrentPlatformAdminWorkers int32
}

func NewPlatformAdminControllerConfiguration() *PlatformAdminControllerConfiguration {
var (
edgexconfig = EdgeXConfig{}
edgexnosectyconfig = EdgeXConfig{}
conf = PlatformAdminControllerConfiguration{
Manifest: Manifest{},
SecurityComponents: make(map[string][]*Component),
NoSectyComponents: make(map[string][]*Component),
SecurityConfigMaps: make(map[string][]corev1.ConfigMap),
NoSectyConfigMaps: make(map[string][]corev1.ConfigMap),
Manifest: Manifest{},
SecurityComponents: make(map[string][]*Component),
NoSectyComponents: make(map[string][]*Component),
SecurityConfigMaps: make(map[string][]corev1.ConfigMap),
NoSectyConfigMaps: make(map[string][]corev1.ConfigMap),
ConcurrentPlatformAdminWorkers: 3,
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package platformadmin
import (
"context"
"encoding/json"
"flag"
"fmt"
"time"

Expand Down Expand Up @@ -54,18 +53,13 @@ import (
util "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/platformadmin/utils"
)

func init() {
flag.IntVar(&concurrentReconciles, "platformadmin-workers", concurrentReconciles, "Max concurrent workers for PlatformAdmin controller.")
}

func Format(format string, args ...interface{}) string {
s := fmt.Sprintf(format, args...)
return fmt.Sprintf("%s: %s", names.PlatformAdminController, s)
}

var (
concurrentReconciles = 3
controllerResource = iotv1alpha2.SchemeGroupVersion.WithResource("platformadmins")
controllerResource = iotv1alpha2.SchemeGroupVersion.WithResource("platformadmins")
)

const (
Expand Down Expand Up @@ -126,7 +120,7 @@ func Add(ctx context.Context, c *appconfig.CompletedConfig, mgr manager.Manager)
}

klog.Infof("platformadmin-controller add controller %s", controllerResource.String())
return add(mgr, newReconciler(c, mgr))
return add(mgr, c, newReconciler(c, mgr))
}

// newReconciler returns a new reconcile.Reconciler
Expand All @@ -141,10 +135,10 @@ func newReconciler(c *appconfig.CompletedConfig, mgr manager.Manager) reconcile.
}

// add adds a new Controller to mgr with r as the reconcile.Reconciler
func add(mgr manager.Manager, r reconcile.Reconciler) error {
func add(mgr manager.Manager, cfg *appconfig.CompletedConfig, r reconcile.Reconciler) error {
// Create a new controller
c, err := controller.New(names.PlatformAdminController, mgr, controller.Options{
Reconciler: r, MaxConcurrentReconciles: concurrentReconciles,
Reconciler: r, MaxConcurrentReconciles: int(cfg.ComponentConfig.PlatformAdminController.ConcurrentPlatformAdminWorkers),
})
if err != nil {
return err
Expand Down
Loading