|
44 | 44 | BuildOnNamespaceCloud = knobs.Bool("build_in_nscloud", "If set to true, builds are triggered remotely.", false) |
45 | 45 | 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) |
46 | 46 | 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) |
48 | 47 | ) |
49 | 48 |
|
50 | 49 | const SSHAgentProviderID = "default" |
@@ -173,51 +172,37 @@ func (c *clientInstance) Compute(ctx context.Context, _ compute.Resolved) (*Gate |
173 | 172 | } |
174 | 173 |
|
175 | 174 | if buildRemotely(c.conf, c.platform) { |
176 | | - profile, err := api.GetProfile(ctx, api.Methods) |
| 175 | + parsedPlatform, err := parsePlatformOrDefault(c.platform) |
177 | 176 | if err != nil { |
178 | | - return nil, err |
| 177 | + return nil, fnerrors.InternalError("failed to parse build platform: %v", err) |
179 | 178 | } |
180 | 179 |
|
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 | + } |
202 | 184 |
|
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 | + } |
207 | 192 |
|
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) |
211 | 195 |
|
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) |
213 | 199 | } |
214 | 200 |
|
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) |
218 | 203 | } |
219 | 204 |
|
220 | | - return useBuildClusterCluster(ctx, bp) |
| 205 | + return useRemoteClusterViaMtls(ctx, builderConfigs[0]) |
221 | 206 | } |
222 | 207 |
|
223 | 208 | localAddr, err := EnsureBuildkitd(ctx, c.overrides.ContainerName) |
|
0 commit comments