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

🌱 server: split apart first tmc pieces #2795

Merged
merged 7 commits into from
Feb 20, 2023

Conversation

sttts
Copy link
Member

@sttts sttts commented Feb 15, 2023

  • create options for the cmd/kcp binary, and move root directory there (probably more flags will follow).

    Rule of thumb: flags that are not useful for embedding belong into the command.

  • create a tmc/pkg/server package and move controller initialization from pkg/server.

  • create cmd/kcp-core.

This is just a start. Many more steps will follow.


cmd := &cobra.Command{
Use: "kcp",
Short: "Kube for Control Plane (KCP)",
Copy link
Member

Choose a reason for hiding this comment

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

Since kcp isn't technically an acronym, we should avoid using (KCP) here

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Output io.Writer

Server serveroptions.Options
Extra ExtraOptions
Copy link
Member

Choose a reason for hiding this comment

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

Food for thought (not really applicable to this PR specifically) - why do we have an options struct and then we put options in an Extra field? i.e. here could we just have Options.RootDirectory instead of Options.Extra.RootDirectory?

Copy link
Member Author

@sttts sttts Feb 17, 2023

Choose a reason for hiding this comment

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

It's part of the pattern. Compare other options where there are 20 fields in Extra. It saves a lot of repetition and avoids mistakes.

Copy link
Member

Choose a reason for hiding this comment

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

Where would there be repetition?

Copy link
Member Author

Choose a reason for hiding this comment

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

on completion, different type.

Copy link
Member

Choose a reason for hiding this comment

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

Sometimes, but not always? e.g. I can see an Options/completedOptions pair that both have an ExtraOptions field. Is this just a way to make moving the options from Options to completedOptions a one-liner?

cmd/kcp/kcp.go Outdated
"github.com/kcp-dev/kcp/pkg/cmd/help"
"github.com/kcp-dev/kcp/pkg/embeddedetcd"
kcpfeatures "github.com/kcp-dev/kcp/pkg/features"
"github.com/kcp-dev/kcp/pkg/server"
"github.com/kcp-dev/kcp/pkg/server/options"
"github.com/kcp-dev/kcp/tmc/pkg/server"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe alias to tmcserver?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

serveroptions "github.com/kcp-dev/kcp/tmc/pkg/server/options"
)

type Options struct {
Copy link
Member

Choose a reason for hiding this comment

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

What is the relationship between this and kcp-core? They look really similar?

Copy link
Member Author

@sttts sttts Feb 17, 2023

Choose a reason for hiding this comment

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

Factored out the generic bits around the root directory (and probably more in the future). Now both sides are simple and share the non-standard logic.

pkg/server/config.go Show resolved Hide resolved
Comment on lines 32 to 33
apiresource "github.com/kcp-dev/kcp/pkg/reconciler/apis/apiresource/options"
heartbeat "github.com/kcp-dev/kcp/pkg/reconciler/workload/heartbeat/options"
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove these?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

}

func (s *Server) Run(ctx context.Context) error {
logger := klog.FromContext(ctx).WithValues("component", "kcp")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger := klog.FromContext(ctx).WithValues("component", "kcp")
logger := klog.FromContext(ctx).WithValues("component", "tmc")

?

Copy link
Member Author

Choose a reason for hiding this comment

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

for now I assume that we call the two layers "kcp-core" and "kcp". The latter includes tmc. If we want split out the workspace hierarchy even more, we need a third name:

  • kcp-core, kcp, kcp-tmc
  • or kcp-base, kcp-core, kcp
  • or kcp-core, kcp, kcp-full.

What do we want? That's more of a communication question how we want to "sell" the layers.

Copy link
Member Author

Choose a reason for hiding this comment

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

my vote goes for the first: kcp-core, kcp, kcp-tmc

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the different between kcp-core, kcp in kcp-core, kcp, kcp-tmc?

Copy link
Member

Choose a reason for hiding this comment

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

kcp-core, kcp, kcp-tmc

That makes sense to me.

Copy link
Member

Choose a reason for hiding this comment

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

So should we apply the change proposed (with kcp-tmc instead of tmc) ?

dynamicClusterClient,
s.Core.DiscoveringDynamicSharedInformerFactory,
s.Core.KcpSharedInformerFactory.Workload().V1alpha1().SyncTargets(),
s.Core.KubeSharedInformerFactory.Core().V1().Namespaces(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Move this one above to put all kcp ones together?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's pure move right now. Cleanups can come in follow-up.

return nil // don't klog.Fatal. This only happens when context is cancelled.
}

go resourceScheduler.Start(ctx, 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see 2 is passed in a number of places, should we make this a constant instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ncdc has a PR for that I believe

Copy link
Member

Choose a reason for hiding this comment

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

I do 😄

@@ -24,7 +24,7 @@ import (

const (
// WorkspaceTypes leads to creation of a number of default types beyond the universal type.
WorkspaceTypes = "cluster-workspace-types"
WorkspaceTypes = "workspace-types"
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want to move the RootComputeWorkspace battery definition to the TMC side ?

Copy link
Member Author

Choose a reason for hiding this comment

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

follow-up. This is just the first step. There must be many more.

Copy link
Member

Choose a reason for hiding this comment

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

OK, sure

@sttts
Copy link
Member Author

sttts commented Feb 20, 2023

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 20, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sttts

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 20, 2023
@davidfestal
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2023
@openshift-merge-robot openshift-merge-robot merged commit ae03042 into kcp-dev:main Feb 20, 2023
@pweil-
Copy link
Member

pweil- commented Feb 22, 2023

Linking to kcp-dev/contrib-tmc#76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants