Skip to content

Commit e2c015e

Browse files
authored
cleanup: Remove old server-side hints (#1450)
1 parent ed0d4b5 commit e2c015e

File tree

4 files changed

+29
-47
lines changed

4 files changed

+29
-47
lines changed

internal/build/buildkit/client.go

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ var (
4444
BuildOnNamespaceCloud = knobs.Bool("build_in_nscloud", "If set to true, builds are triggered remotely.", false)
4545
BuildOnNamespaceCloudUnlessHost = knobs.Bool("build_in_nscloud_unless_host", "If set to true, builds that match the host platform run locally. All other builds are triggered remotely.", false)
4646
BuildOnExistingBuildkit = knobs.String("buildkit_addr", "The address of an existing buildkitd to use.", "")
47-
BuildUsingServerSideProxy = knobs.Bool("build_using_server_side_proxy", "If set to true, builds are performed using the server-side buildkit proxy.", false)
4847
)
4948

5049
const SSHAgentProviderID = "default"
@@ -173,51 +172,37 @@ func (c *clientInstance) Compute(ctx context.Context, _ compute.Resolved) (*Gate
173172
}
174173

175174
if buildRemotely(c.conf, c.platform) {
176-
profile, err := api.GetProfile(ctx, api.Methods)
175+
parsedPlatform, err := parsePlatformOrDefault(c.platform)
177176
if err != nil {
178-
return nil, err
177+
return nil, fnerrors.InternalError("failed to parse build platform: %v", err)
179178
}
180179

181-
if profile.BuildServerSideProxyHint || BuildUsingServerSideProxy.Get(c.conf) {
182-
parsedPlatform, err := parsePlatformOrDefault(c.platform)
183-
if err != nil {
184-
return nil, fnerrors.InternalError("failed to parse build platform: %v", err)
185-
}
186-
187-
stateDir, err := dirs.Ensure(cluster.DetermineStateDir("", cluster.BuildkitProxyPath))
188-
if err != nil {
189-
return nil, fnerrors.InternalError("failed to ensure state dir: %v", err)
190-
}
191-
192-
builderConfigs, err := cluster.PrepareServerSideBuildxProxy(ctx, stateDir, []api.BuildPlatform{parsedPlatform}, true, "")
193-
if err != nil {
194-
return nil, err
195-
}
196-
if len(builderConfigs) != 1 {
197-
return nil, fnerrors.InternalError("expected one builder config, got %d", len(builderConfigs))
198-
}
199-
200-
endpoint := builderConfigs[0].FullBuildkitEndpoint
201-
fmt.Fprintf(console.Info(ctx), "buildkit: using server-side build proxy (endpoint: %s)\n", endpoint)
180+
stateDir, err := dirs.Ensure(cluster.DetermineStateDir("", cluster.BuildkitProxyPath))
181+
if err != nil {
182+
return nil, fnerrors.InternalError("failed to ensure state dir: %v", err)
183+
}
202184

203-
isServerSideProxy, err := cluster.TestServerSideBuildxProxyConnectivity(ctx, builderConfigs[0])
204-
if err != nil {
205-
fmt.Fprintf(console.Warnings(ctx), "buildkit: connectivity check to '%s' failed: %v\n", endpoint, err)
206-
}
185+
builderConfigs, err := cluster.PrepareServerSideBuildxProxy(ctx, stateDir, []api.BuildPlatform{parsedPlatform}, true, "")
186+
if err != nil {
187+
return nil, err
188+
}
189+
if len(builderConfigs) != 1 {
190+
return nil, fnerrors.InternalError("expected one builder config, got %d", len(builderConfigs))
191+
}
207192

208-
if !isServerSideProxy {
209-
fmt.Fprintf(console.Warnings(ctx), "buildkit: '%s' has connectivity but doesn't seem to be Namespace Build Ingress\n", endpoint)
210-
}
193+
endpoint := builderConfigs[0].FullBuildkitEndpoint
194+
fmt.Fprintf(console.Info(ctx), "buildkit: using server-side build proxy (endpoint: %s)\n", endpoint)
211195

212-
return useRemoteClusterViaMtls(ctx, builderConfigs[0])
196+
isServerSideProxy, err := cluster.TestServerSideBuildxProxyConnectivity(ctx, builderConfigs[0])
197+
if err != nil {
198+
fmt.Fprintf(console.Warnings(ctx), "buildkit: connectivity check to '%s' failed: %v\n", endpoint, err)
213199
}
214200

215-
bp, err := cluster.NewBuildCluster(ctx, formatPlatformOrDefault(c.platform), "")
216-
if err != nil {
217-
return nil, err
201+
if !isServerSideProxy {
202+
fmt.Fprintf(console.Warnings(ctx), "buildkit: '%s' has connectivity but doesn't seem to be Namespace Build Ingress\n", endpoint)
218203
}
219204

220-
return useBuildClusterCluster(ctx, bp)
205+
return useRemoteClusterViaMtls(ctx, builderConfigs[0])
221206
}
222207

223208
localAddr, err := EnsureBuildkitd(ctx, c.overrides.ContainerName)

internal/cli/cmd/cluster/buildx.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func newSetupBuildxCmd() *cobra.Command {
7676
_ = cmd.Flags().MarkHidden("buildkit_sock_path")
7777
defaultLoad := cmd.Flags().Bool("default_load", false, "If true, load images to the Docker Engine image store if no other output is specified.")
7878
_ = cmd.Flags().MarkHidden("default_load")
79-
useServerSideProxy := cmd.Flags().Bool("use_server_side_proxy", false, "If set, buildx is setup to use transparent server-side proxy powered by Namespace")
79+
useServerSideProxy := cmd.Flags().Bool("use_server_side_proxy", true, "If set, buildx is setup to use transparent server-side proxy powered by Namespace")
8080
_ = cmd.Flags().MarkHidden("use_server_side_proxy")
8181

8282
cmd.RunE = fncobra.RunE(func(ctx context.Context, args []string) error {
@@ -105,7 +105,7 @@ func newSetupBuildxCmd() *cobra.Command {
105105
return err
106106
}
107107

108-
available, serverSideProxyDefault, err := determineAvailable(ctx)
108+
available, err := determineAvailable(ctx)
109109
if err != nil {
110110
return err
111111
}
@@ -119,9 +119,7 @@ func newSetupBuildxCmd() *cobra.Command {
119119
return err
120120
}
121121

122-
// NSL-3935 use remote-side buildx proxy
123-
// This will be soon the default
124-
if serverSideProxyDefault || *useServerSideProxy {
122+
if *useServerSideProxy {
125123
if err := setupServerSideBuildxProxy(ctx, state, *name, *use, *defaultLoad, dockerCli, available, *createAtStartup, *tag); err != nil {
126124
return err
127125
}
@@ -604,18 +602,18 @@ func newWireBuildxCommand(hidden bool) *cobra.Command {
604602
return cmd
605603
}
606604

607-
func determineAvailable(ctx context.Context) ([]api.BuildPlatform, bool, error) {
605+
func determineAvailable(ctx context.Context) ([]api.BuildPlatform, error) {
608606
profile, err := api.GetProfile(ctx, api.Methods)
609607
if err != nil {
610-
return nil, false, err
608+
return nil, err
611609
}
612610

613611
avail := make([]api.BuildPlatform, len(profile.ClusterPlatform))
614612
for k, x := range profile.ClusterPlatform {
615613
avail[k] = api.BuildPlatform(x)
616614
}
617615

618-
return avail, profile.BuildxServerSideProxyDefaultHint, nil
616+
return avail, nil
619617
}
620618

621619
func banner(ctx context.Context, name string, use bool, native []api.BuildPlatform, background, serverSideProxy bool) string {

internal/providers/nscloud/api/rpc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ func CreateCluster(ctx context.Context, api API, opts CreateClusterOpts) (*Insta
359359
fmt.Fprintf(console.Debug(ctx), "[nsc] instance will be removed on exit: %s\n", resp.InstanceId)
360360

361361
compute.On(ctx).Cleanup(tasks.Action("nscloud.cluster-cleanup"), func(ctx context.Context) error {
362+
fmt.Fprintf(console.Debug(ctx), "[nsc] Removing instance for nscloud.cluster-cleanup %s\n", resp.InstanceId)
362363
if err := DestroyCluster(ctx, api, MaybeEndpoint(resp.ApiEndpoint), resp.InstanceId); err != nil {
363364
// The cluster being gone is an acceptable state (it could have
364365
// been deleted by DeleteRecursively for example).

internal/providers/nscloud/api/types.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,7 @@ type EnsureBazelCacheResponse struct {
486486
}
487487

488488
type GetProfileResponse struct {
489-
ClusterPlatform []string `json:"cluster_platform,omitempty"`
490-
BuildxServerSideProxyDefaultHint bool `json:"buildx_server_side_proxy_default_hint,omitempty"`
491-
BuildServerSideProxyHint bool `json:"build_server_side_proxy_hint,omitempty"`
489+
ClusterPlatform []string `json:"cluster_platform,omitempty"`
492490
}
493491

494492
type RegisterIngressRequest struct {

0 commit comments

Comments
 (0)