@@ -67,13 +67,22 @@ func NewKCPManager(
6767 schemaResolver := apischema .NewResolver (log )
6868
6969 // Create the apiexport provider for multicluster-runtime
70- // We need to use the APIExport endpoint, not the general KCP config
71- // The APIExport endpoint should be configured to discover multiple workspaces
70+ // Configure the provider to use the APIExport endpoint
71+ // The multicluster-provider needs to connect to the specific APIExport endpoint
72+ // to discover workspaces, not the base KCP host
7273 apiexportConfig := rest .CopyConfig (opts .Config )
7374
74- // TODO: Configure with the correct APIExport endpoint
75- // For now, we'll use the general config and let the provider discover the APIExport
76- // The provider should automatically find the core.platform-mesh.io APIExport
75+ // Construct the APIExport URL from the base host
76+ // We know the APIExport name is "core.platform-mesh.io" and we need to find the cluster hash
77+ baseHost := opts .Config .Host
78+
79+ // For now, we'll construct a known APIExport URL
80+ // TODO: This should be made configurable or discovered dynamically
81+ apiexportURL := baseHost + "/services/apiexport/1mx3340lwq4c8kkw/core.platform-mesh.io/"
82+
83+ log .Info ().Str ("baseHost" , baseHost ).Str ("apiexportURL" , apiexportURL ).Msg ("Using APIExport URL for multicluster provider" )
84+ apiexportConfig .Host = apiexportURL
85+
7786 provider , err := apiexport .New (apiexportConfig , apiexport.Options {
7887 Scheme : opts .Scheme ,
7988 })
@@ -222,7 +231,6 @@ func (m *KCPManager) generateAndWriteSchemaForWorkspace(ctx context.Context, wor
222231 return fmt .Errorf ("failed to create workspace config: %w" , err )
223232 }
224233
225-
226234 // WORKAROUND: Use the original approach from main branch
227235 // Create discovery client but ensure it doesn't make /api requests to KCP front proxy
228236 // Use the existing discovery factory which should handle KCP properly
@@ -241,41 +249,29 @@ func (m *KCPManager) generateAndWriteSchemaForWorkspace(ctx context.Context, wor
241249 return fmt .Errorf ("failed to create REST mapper: %w" , err )
242250 }
243251
244- // Get the original APIExport virtual workspace URL
245- // For multicluster-provider, check if we already have the APIExport URL or need to construct it
252+ // Use direct workspace URLs like the main branch for gateway compatibility
253+ // The multicluster-provider is only used for workspace discovery in the listener
254+ // The gateway will use standard Kubernetes clients with direct workspace URLs
246255 baseConfig := m .mcMgr .GetLocalManager ().GetConfig ()
247256 baseHost := baseConfig .Host
248-
249- var originalClusterHost string
250- if strings .Contains (baseHost , "/services/apiexport/" ) {
251- // Base host already contains APIExport path, use it directly
252- originalClusterHost = baseHost
253- } else {
254- // Construct the APIExport URL using the cluster name (hash) and known APIExport name
255- originalClusterHost = fmt .Sprintf ("%s/services/apiexport/%s/core.platform-mesh.io" , baseHost , clusterName )
256- }
257-
258- // DEBUG: Log the constructed URL
259- m .log .Info ().
260- Str ("clusterName" , clusterName ).
261- Str ("baseHost" , baseHost ).
262- Str ("constructedAPIExportURL" , originalClusterHost ).
263- Msg ("*** CONSTRUCTED APIExport URL for host override ***" )
264-
265- // DEBUG: Log before calling generateSchemaWithMetadata
257+
258+ // Construct direct workspace URL like main branch: /clusters/{workspace}
259+ directWorkspaceHost := fmt .Sprintf ("%s/clusters/%s" , baseHost , workspacePath )
260+
266261 m .log .Info ().
267262 Str ("clusterName" , clusterName ).
268263 Str ("workspacePath" , workspacePath ).
269- Str ("hostOverride" , originalClusterHost ).
270- Msg ("*** ABOUT TO CALL generateSchemaWithMetadata ***" )
271-
264+ Str ("baseHost" , baseHost ).
265+ Str ("directWorkspaceHost" , directWorkspaceHost ).
266+ Msg ("Using direct workspace URL for gateway compatibility (same as main branch)" )
267+
272268 // Generate current schema using direct workspace access
273269 currentSchema , err := generateSchemaWithMetadata (
274270 SchemaGenerationParams {
275271 ClusterPath : workspacePath ,
276272 DiscoveryClient : discoveryClient ,
277273 RESTMapper : restMapper ,
278- HostOverride : originalClusterHost , // Pass the original APIExport URL
274+ HostOverride : directWorkspaceHost , // Use direct workspace URL like main branch
279275 },
280276 m .schemaResolver ,
281277 m .log ,
@@ -389,7 +385,6 @@ func (m *KCPManager) resolveWorkspacePath(ctx context.Context, clusterName strin
389385 return workspacePath , nil
390386}
391387
392-
393388// providerRunnable wraps the apiexport provider to make it compatible with controller-runtime manager
394389type providerRunnable struct {
395390 provider * apiexport.Provider
0 commit comments