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

Utilize and expose functions for starting up the manager #1601

Open
tenzen-y opened this issue Jan 17, 2024 · 17 comments
Open

Utilize and expose functions for starting up the manager #1601

tenzen-y opened this issue Jan 17, 2024 · 17 comments
Assignees
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Comments

@tenzen-y
Copy link
Member

tenzen-y commented Jan 17, 2024

What would you like to be cleaned:
I would like to utilize and expose the below functions for starting up the manager:
We can probably cut an initialize package under the pkg directory, and then we can put the below functions there.

func setupIndexes(ctx context.Context, mgr ctrl.Manager, cfg *configapi.Configuration) error {

func setupControllers(mgr ctrl.Manager, cCache *cache.Cache, queues *queue.Manager, certsReady chan struct{}, cfg *configapi.Configuration, serverVersionFetcher *kubeversion.ServerVersionFetcher) {

func setupProbeEndpoints(mgr ctrl.Manager) {

func setupServerVersionFetcher(mgr ctrl.Manager, kubeConfig *rest.Config) *kubeversion.ServerVersionFetcher {

func blockForPodsReady(cfg *configapi.Configuration) bool {

func waitForPodsReady(cfg *configapi.Configuration) bool {

func apply(configFile string) (ctrl.Options, configapi.Configuration, error) {

func isFrameworkEnabled(cfg *configapi.Configuration, name string) bool {

Why is this needed:

When the platform developers implement the managers for the in-house custom jobs, they can avoid copying and pasting those functions to their manager.

@tenzen-y tenzen-y added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jan 17, 2024
@tenzen-y
Copy link
Member Author

/assign

@alculquicondor
Copy link
Contributor

Some of them don't seem to be necessary for a custom integration, unless you are essentially forking kueue?

My general recommendation would be run the custom integration in a separate binary that can be released independently, similar to https://github.com/kubernetes-sigs/kueue/blob/main/cmd/experimental/podtaintstolerations/main.go

@tenzen-y
Copy link
Member Author

My general recommendation would be run the custom integration in a separate binary that can be released independently, similar to https://github.com/kubernetes-sigs/kueue/blob/main/cmd/experimental/podtaintstolerations/main.go

Yes, I meant a separate binary. Currently, separate main function can not import functions like setupProbeEndpoints since those functions aren't exported.

It means that the platform developer implements the main function like the following:
I would like to avoid copying these similar functions. @alculquicondor Does this make sense?

func main() {
...
	ctx := ctrl.SetupSignalHandler()
	setupIndexes(ctx, mgr)
	setupProbeEndpoints(mgr)
	go setupControllers(mgr, certsReady, &cfg)

	setupLog.Info("starting manager")
	if err := mgr.Start(ctx); err != nil {
		setupLog.Error(err, "could not run manager")
		os.Exit(1)
	}

func setupIndexes(ctx context.Context, mgr ctrl.Manager) {
	err := jobframework.ForEachIntegration(func(name string, cb jobframework.IntegrationCallbacks) error {
		if err := cb.SetupIndexes(ctx, mgr.GetFieldIndexer()); err != nil {
			return fmt.Errorf("integration %s: %w", name, err)
		}
		return nil
	})
	if err != nil {
		setupLog.Error(err, "unable to setup jobs indexes")
	}
}

func setupProbeEndpoints(mgr ctrl.Manager) {
	defer setupLog.Info("probe endpoints are configured on healthz and readyz")

	if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
		setupLog.Error(err, "unable to set up health check")
		os.Exit(1)
	}
	if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
		setupLog.Error(err, "unable to set up ready check")
		os.Exit(1)
	}
}

func setupControllers(mgr ctrl.Manager, certsReady chan struct{}, cfg *configapi.Configuration) {
...
	opts := []jobframework.Option{
		jobframework.WithManageJobsWithoutQueueName(cfg.ManageJobsWithoutQueueName),
		jobframework.WithWaitForPodsReady(waitForPodsReady(cfg)),
	}
	err := jobframework.ForEachIntegration(func(name string, cb jobframework.IntegrationCallbacks) error {
		log := setupLog.WithValues("jobFrameworkName", name)
		if err := cb.NewReconciler(
			mgr.GetClient(),
			mgr.GetEventRecorderFor(fmt.Sprintf("%s-%s-controller", name, constants.ManagerName)),
			opts...,
...
	if err != nil {
		os.Exit(1)
	}
	// +kubebuilder:scaffold:builder
}

func waitForPodsReady(cfg *configapi.Configuration) bool {
	return cfg.WaitForPodsReady != nil && cfg.WaitForPodsReady.Enable
}

@alculquicondor
Copy link
Contributor

oh I see. So you have a single binary to add multiple integrations. Then it might make sense to export things like SetupIndexes and SetupControllers.

But I don't think you should be using Kueue's Configuration API. You should probably have your own.

@tenzen-y
Copy link
Member Author

oh I see. So you have a single binary to add multiple integrations. Then it might make sense to export things like SetupIndexes and SetupControllers.

Yes, I will expose the only needed functions.

But I don't think you should be using Kueue's Configuration API. You should probably have your own.

In my env, I deployed another ConfigMap embedded Kueue Config to cluster and then the another Kueue Config is mounted on the inhouse kueue manager.

It means that I have 2 configMaps embedded kueue config.

@alculquicondor
Copy link
Contributor

I think we shouldn't make the same assumption in the exported functions. The functions could take some specific fields.

@tenzen-y
Copy link
Member Author

I think we shouldn't make the same assumption in the exported functions. The functions could take some specific fields.

Maybe, I couldn't understand correctly what you want to mean.

But I don't think you should be using Kueue's Configuration API. You should probably have your own.

Does this mean that you suggested not mounting another Kueue's Configuration on the in-house Kueue manager?
Or you meant that we shouldn't expose functions with Kueue's Configuration as args?

@alculquicondor
Copy link
Contributor

I think we should export something like SetupControllers(mgr ctrl.Manager, certsReady chan struct{}, opts... jobframework.Options), without making assumptions about how your configuration API looks like.

@tenzen-y
Copy link
Member Author

I think we should export something like SetupControllers(mgr ctrl.Manager, certsReady chan struct{}, opts... jobframework.Options), without making assumptions about how your configuration API looks like.

Ah, it makes sense. Thank you for the clarifications!

This was referenced Jan 22, 2024
@mimowo
Copy link
Contributor

mimowo commented Feb 7, 2024

@tenzen-y I see #1630 merged. Is there more to do, or we can close?

@tenzen-y
Copy link
Member Author

tenzen-y commented Feb 7, 2024

@tenzen-y I see #1630 merged. Is there more to do, or we can close?

I'm still working on this, but I'm not sure if we can finalize this by the deadline for v0.6.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 7, 2024
@tenzen-y
Copy link
Member Author

tenzen-y commented May 7, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 7, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 5, 2024
@tenzen-y
Copy link
Member Author

tenzen-y commented Aug 5, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 5, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 3, 2024
@tenzen-y
Copy link
Member Author

tenzen-y commented Nov 4, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
None yet
Development

No branches or pull requests

5 participants