From 2ed7519665e59fd1300ca32259e67330fa120fe0 Mon Sep 17 00:00:00 2001 From: Adam Wolfe Gordon Date: Mon, 29 Jun 2026 13:24:45 -0600 Subject: [PATCH 1/2] projects: Use a fresh scheme for the dev control plane client Avoid races with other code that uses the global `scheme.Scheme` by creating a fresh scheme for the control plane client. This allows us to safely create dev control planes concurrently with other operations. Signed-off-by: Adam Wolfe Gordon --- internal/project/controlplane/controlplane.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/project/controlplane/controlplane.go b/internal/project/controlplane/controlplane.go index 23776f59..a3d58f18 100644 --- a/internal/project/controlplane/controlplane.go +++ b/internal/project/controlplane/controlplane.go @@ -34,7 +34,9 @@ import ( corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "sigs.k8s.io/controller-runtime/pkg/client" @@ -278,7 +280,9 @@ func EnsureLocalDevControlPlane(ctx context.Context, opts ...Option) (DevControl return nil, errors.Wrap(err, "cannot get rest config") } - cl, err := client.New(restConfig, client.Options{}) + cl, err := client.New(restConfig, client.Options{ + Scheme: newScheme(), + }) if err != nil { return nil, errors.Wrap(err, "cannot construct control plane client") } @@ -334,6 +338,12 @@ func EnsureLocalDevControlPlane(ctx context.Context, opts ...Option) (DevControl }, nil } +func newScheme() *runtime.Scheme { + sch := runtime.NewScheme() + _ = clientgoscheme.AddToScheme(sch) + return sch +} + // TeardownLocalDevControlPlane tears down a local dev control plane by name. // It deletes the kind cluster, stops the registry container, and removes the // registry data directory. From 7508aa8b58bf5105046c9de986ecb6efc1ecad6e Mon Sep 17 00:00:00 2001 From: Adam Wolfe Gordon Date: Mon, 29 Jun 2026 13:26:13 -0600 Subject: [PATCH 2/2] schemas: Avoid concurrent writes to the schemas map We generate schemas for all languages concurrently and previously wrote to the `schemas` map without coordination. Signed-off-by: Adam Wolfe Gordon --- internal/schemas/manager/manager.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/schemas/manager/manager.go b/internal/schemas/manager/manager.go index fd35fe29..ee87194d 100644 --- a/internal/schemas/manager/manager.go +++ b/internal/schemas/manager/manager.go @@ -80,6 +80,7 @@ func (m *Manager) Generate(ctx context.Context, source Source) (map[string]afero return nil, err } + var schemasMu sync.Mutex schemas := make(map[string]afero.Fs) eg, egCtx := errgroup.WithContext(ctx) sourceType := source.Type() @@ -101,7 +102,9 @@ func (m *Manager) Generate(ctx context.Context, source Source) (map[string]afero } if schemaFS != nil { + schemasMu.Lock() schemas[gen.Language()] = schemaFS + schemasMu.Unlock() } return nil