Skip to content

Conversation

@mjudeikis
Copy link
Contributor

@mjudeikis mjudeikis commented Nov 24, 2024

Summary

In this PR:

  1. Move some of the proxy handler code from pkg/proxy into pkg/server/proxy so it could be reused in miniproxy. This is to avoid circular imports problem :/ didn't find better place for this.
  2. Add flag --mapping-file for kcp start in dev mode, so once can start kcp locally and iterate on external virtual workspace binary code without having to deal with embedding code. It makes kcp core more standalone and forces people to think "core vs non-core"
  3. Refactors proxy index with error codes to be more consistent (a consequence of reusing same more in miniproxy and front-proxy)

All in all, this makes local development of anything outside kcp (like mounts proxy) exponentially easier.

Related issue(s)

Fixes #

Release Notes

Enhance local development experience for VirtualWorkspaces, adding `--mappings-file` option for local dev

@kcp-ci-bot kcp-ci-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has signed the DCO. labels Nov 24, 2024
@kcp-ci-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@mjudeikis mjudeikis marked this pull request as ready for review November 24, 2024 15:13
@kcp-ci-bot kcp-ci-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Nov 24, 2024
// for the mini-front-proxy to use. The file should be in the format of the
// --mapping-file flag of the front-proxy. Do NOT expose this flag to users via main server options.
// It is overridden by the kcp start command.
AdditionalMappingsFile string
Copy link
Member

Choose a reason for hiding this comment

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

is this also written in the flag description? Probably should?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@sttts
Copy link
Member

sttts commented Dec 12, 2024

Direction looks fine. @embik do you have time for a detailed review?

Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

Looks good to me overall, I'm just confused by the flag.

cmd/kcp/kcp.go Outdated
Comment on lines 79 to 84
} else if f == "--mapping-file" {
if i < len(os.Args)-1 {
additionalMappingsFile = os.Args[i+1]
} // else let normal flag processing fail
} else if strings.HasPrefix(f, "--mapping-file") {
additionalMappingsFile = strings.TrimPrefix(f, "--mapping-file=")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I get the way this flag is set up. There is this code here in cmd/kcp/kcp.go, then there is another flag with the same name in cmd/kcp/options/generic.go (so this will be read into both serverOptions.Server.Extra.AdditionalMappingsFile and serverOptions.Server.GenericControlPlane.Extra.MappingFile as far as I can say). Then there is a comment on AdditionalMappingsFile in pkg/server/options/opttions.go saying it shouldn't be exposed.

Can you explain a little bit more here, maybe with comments on the code? Why is this early initialisation necessary, what is the relationship to the MappingFile value, etc? Do we really need both things?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One is for front-proxy in production where we use this.
Another is at the server level for cases when we don't have a proxy. In this case when we run slim mini proxy with kcp start and we need to pass the flag in somehow.

maybe we can rename one at the server level to something dev-mapping-file so it's not confusing?

Copy link
Member

Choose a reason for hiding this comment

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

But this PR doesn't touch the option in pkg/proxy/options/options.go, which is a separate implementation of --mapping-file. I think a --miniproxy-mapping-file flag on the server would be nicer, but I'm still not sure I understand why we read the flag in two places 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we need to load it into fake-frontproxy :) So if we rename it will be cleaner - one for frontproxy, another for minifrontproxy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So TL:DR:
its 2 different kube apiservers - proxy and core kcp server. Core server should never have this flag defined. But because we share code with kcp start I didn't find nice way not to add it. Not its implied its development only.

@kcp-ci-bot kcp-ci-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 18, 2024
@kcp-ci-bot kcp-ci-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 20, 2024
Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

/approve

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 20, 2024
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 68168a7bc0e5ea4edda57b776f8a02cc260dfe22

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik

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

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 20, 2024
@kcp-ci-bot kcp-ci-bot merged commit 14d793a into kcp-dev:main Dec 20, 2024
16 checks passed
@embik
Copy link
Member

embik commented Mar 18, 2025

/kind feature

@kcp-ci-bot kcp-ci-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 18, 2025
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. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants