Skip to content

Commit

Permalink
Revert "buildproxy: extend builder deadline to 1h if below 1h"
Browse files Browse the repository at this point in the history
Refresher is already implemented on both client side and server side. This is redundant.

Fixes: NSL-1372

This reverts commit 931595a.
  • Loading branch information
gmichelo committed Jul 17, 2023
1 parent 931595a commit 61e53e9
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions internal/cli/cmd/cluster/buildproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import (
"errors"
"fmt"
"log"
"math"
"net"
"os"
"path/filepath"
"sync"
"time"

"github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/config/configfile"
Expand All @@ -31,7 +29,6 @@ import (

const (
nscrRegistryUsername = "token"
clusterMinDuration = time.Hour * 1
)

type BuildClusterInstance struct {
Expand All @@ -48,10 +45,8 @@ func (bp *BuildClusterInstance) NewConn(ctx context.Context) (net.Conn, error) {
defer bp.mu.Unlock()

if bp.previous != nil && (bp.previous.BuildCluster == nil || bp.previous.BuildCluster.Resumable) {
if clusterInfo, err := api.EnsureCluster(ctx, api.Methods, bp.previous.ClusterId); err == nil {
if err := ensureMinClusterDuration(ctx, clusterInfo.Cluster.ClusterId); err == nil {
return bp.rawDial(ctx, bp.previous)
}
if _, err := api.EnsureCluster(ctx, api.Methods, bp.previous.ClusterId); err == nil {
return bp.rawDial(ctx, bp.previous)
}
}

Expand All @@ -77,10 +72,6 @@ func (bp *BuildClusterInstance) NewConn(ctx context.Context) (net.Conn, error) {

bp.previous = response

if err := ensureMinClusterDuration(ctx, response.ClusterId); err != nil {
return nil, err
}

return bp.rawDial(ctx, response)
}

Expand Down Expand Up @@ -266,17 +257,3 @@ func runBuildProxyWithRegistry(ctx context.Context, platform api.BuildPlatform,

return &buildProxyWithRegistry{p.socketPath, tmpDir, p.Cleanup}, nil
}

func ensureMinClusterDuration(ctx context.Context, clusterID string) error {
req := api.RefreshKubernetesClusterRequest{
ClusterId: clusterID,
EnsureMinimumSecs: int32(math.Floor(clusterMinDuration.Seconds())),
}

_, err := api.RefreshCluster(ctx, api.Methods, req)
if err != nil {
return err
}

return nil
}

0 comments on commit 61e53e9

Please sign in to comment.