-
Notifications
You must be signed in to change notification settings - Fork 391
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
wire TemporaryRootShardKcpSharedInformerFactory #1572
wire TemporaryRootShardKcpSharedInformerFactory #1572
Conversation
c3fc225
to
eb2c902
Compare
/retest |
|
||
getAPIResourceSchema: func(clusterName logicalcluster.Name, name string) (*apisv1alpha1.APIResourceSchema, error) { | ||
return apiResourceSchemaInformer.Lister().Get(clusters.ToClusterAwareKey(clusterName, name)) | ||
apiResourceSchema, err := apiResourceSchemaInformer.Lister().Get(clusters.ToClusterAwareKey(clusterName, name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the expected sequencing here? I'm not sure we want to have this structure around in the code for a long time, it seems easy to do incorrectly from the dev side.
eb2c902
to
3112756
Compare
pkg/server/server.go
Outdated
@@ -28,6 +28,7 @@ import ( | |||
apiextensionsapiserver "k8s.io/apiextensions-apiserver/pkg/apiserver" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs better commit name
pkg/server/server.go
Outdated
@@ -121,6 +122,9 @@ type ExtraConfig struct { | |||
// resource identities for the root shard into the rest.Config used by the client. | |||
// Only after it succeeds, the clients can wildcard-list/watch most kcp resources. | |||
ResolveRootKcpShardIdentities func(ctx context.Context) error | |||
|
|||
// RootShardKcpClusterClient holds a cluster-wide client to the root shard | |||
RootShardKcpClusterClient *kcpclient.Cluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move up to the clients
pkg/server/server.go
Outdated
// ResolveRootKcpShardIdentities is to be called on server start until it succeeds. It injects the kcp | ||
// resource identities for the root shard into the rest.Config used by the client. | ||
// Only after it succeeds, the clients can wildcard-list/watch most kcp resources. | ||
ResolveRootKcpShardIdentities func(ctx context.Context) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have that at the top already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for the root shard only, resolved in a different place. I think we need both.
f0a34db
to
e6a75d7
Compare
pkg/server/server.go
Outdated
// Only after it succeeds, the clients can wildcard-list/watch most kcp resources. | ||
ResolveRootKcpShardIdentities func(ctx context.Context) error | ||
|
||
identityConfig *rest.Config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
am still confused about the new fields. The existing should do exactly that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I think I know what you mean :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what we need #1620
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you wire it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/server/server.go
Outdated
return nil, err | ||
} | ||
var rootKcpShardIdentityConfig *rest.Config | ||
rootKcpShardIdentityConfig, c.ResolveRootKcpShardIdentities = boostrap.NewConfigWithWildcardIdentities(nonIdentityRootKcpShardSystemAdminConfig, boostrap.KcpRootGroupExportNames, boostrap.KcpRootGroupResourceExportNames, nonIdentityRootKcpShardClient.Cluster(tenancyv1alpha1.RootCluster)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am lost in this wiring. Don't we have these two cases:
- we are the root shard. Then we need the old, staged flow where we start the local informer only for apis.kcp.dev first, then pick the identities from the APIExports, inject them into the roundtripper and then start the rest.
- we are NOT the root shard. Then we can run
resolveRootKcpShardIdentities
here in-place very early before anything of the code further down runs, i.e. before any of the informers have been started.
e6a75d7
to
0df6f34
Compare
pkg/server/server.go
Outdated
} | ||
|
||
if rootKcpShardIdentityRoundTripper != nil { | ||
c.identityConfig = rest.CopyConfig(c.GenericConfig.LoopbackClientConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could move this inside the if clause in L190
pkg/server/server.go
Outdated
c.identityConfig = rest.CopyConfig(c.GenericConfig.LoopbackClientConfig) | ||
c.identityConfig.Wrap(rootKcpShardIdentityRoundTripper) | ||
} else { | ||
// The informers here are not used before the informers are actually started (i.e. no race). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this into the else clause in L214
0df6f34
to
99baec0
Compare
…or the root shard
99baec0
to
eb21f33
Compare
NewWildcardIdentitiesWrappingRoundTripper creates a HTTP RoundTripper that injected resource identities for individual group or group resources. Each group or resource is coming from one APIExport whose names are passed in as a map. The RoundTripper is exposed as a function that allows wrapping the RoundTripper. The method also returns the resolve function that gets the APIExports and extract the identities. The resolve func might return an error if the APIExport is not found or for other reason. Only after it succeeds a client using the returned RoundTripper can use the group and group resources with identities.
eb21f33
to
3639d33
Compare
pkg/server/config.go
Outdated
return nil, err | ||
} | ||
var rootKcpShardIdentityRoundTripper func(rt http.RoundTripper) http.RoundTripper | ||
rootKcpShardIdentityRoundTripper, c.resolveIdentities = boostrap.NewWildcardIdentitiesWrappingRoundTripper(boostrap.KcpRootGroupExportNames, boostrap.KcpRootGroupResourceExportNames, nonIdentityRootKcpShardClient.Cluster(tenancyv1alpha1.RootCluster)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to resolve it here, config is for setting up configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's an argument indeed
@@ -172,24 +173,76 @@ func (s *Server) Run(ctx context.Context) error { | |||
return nil // don't klog.Fatal. This only happens when context is cancelled. | |||
} | |||
klog.Infof("Bootstrapped root workspace phase 0") | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now the flow is:
- common
- root
- non-root
- common
- root (moving 4 and 5 breaks the server, not sure it can be done in any other way)
3639d33
to
ad0010a
Compare
pkg/server/config.go
Outdated
@@ -86,6 +87,8 @@ type ExtraConfig struct { | |||
KubeClusterClient kubernetes.ClusterInterface | |||
ApiExtensionsClusterClient apiextensionsclient.ClusterInterface | |||
KcpClusterClient kcpclient.ClusterInterface | |||
// RootShardKcpClusterClient holds a cluster-wide client to the root shard | |||
RootShardKcpClusterClient *kcpclient.Cluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ClusterInterface
pkg/server/config.go
Outdated
@@ -86,6 +87,8 @@ type ExtraConfig struct { | |||
KubeClusterClient kubernetes.ClusterInterface | |||
ApiExtensionsClusterClient apiextensionsclient.ClusterInterface | |||
KcpClusterClient kcpclient.ClusterInterface | |||
// RootShardKcpClusterClient holds a cluster-wide client to the root shard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the comment. Doesn't add anything :)
pkg/server/config.go
Outdated
rootKcpShardIdentityRoundTripper, c.resolveIdentities = boostrap.NewWildcardIdentitiesWrappingRoundTripper(boostrap.KcpRootGroupExportNames, boostrap.KcpRootGroupResourceExportNames, nonIdentityRootKcpShardClient.Cluster(tenancyv1alpha1.RootCluster)) | ||
rootKcpShardIdentityConfig := rest.CopyConfig(nonIdentityRootKcpShardSystemAdminConfig) | ||
rootKcpShardIdentityConfig.Wrap(rootKcpShardIdentityRoundTripper) | ||
c.RootShardKcpClusterClient, err = kcpclient.NewClusterForConfig(rootKcpShardIdentityConfig) // this is now generic to be used for all kcp API groups |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment is not correct. The client can be used after resolving via c.resolveIdentities
. Would just drop the comment.
ad0010a
to
64aa157
Compare
64aa157
to
c881323
Compare
/lgtm |
[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 |
/retest |
2 similar comments
/retest |
/retest |
Summary
wires TemporaryRootShardKcpSharedInformerFactory, essentially when c.Options.Extra.RootShardKubeconfigFile is set then:
Related issue(s)
Fixes #