Skip to content

Commit b00ba43

Browse files
committed
OCPBUGS-37821: Remove timed context for gcp client
** removing the timeout for a client that is causing failures when we return from the function that creates a signed url.
1 parent a651e1a commit b00ba43

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

pkg/asset/ignition/bootstrap/gcp/storage.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@ func NewStorageClient(ctx context.Context) (*storage.Client, error) {
3737
return client, nil
3838
}
3939

40-
// CreateBucketHandle will create the bucket handle that can be used as a reference for other storage resources.
41-
func CreateBucketHandle(ctx context.Context, bucketName string) (*storage.BucketHandle, error) {
42-
ctx, cancel := context.WithTimeout(ctx, time.Minute*1)
43-
defer cancel()
44-
45-
client, err := NewStorageClient(ctx)
46-
if err != nil {
47-
return nil, fmt.Errorf("failed to create storage client: %w", err)
48-
}
49-
return client.Bucket(bucketName), nil
50-
}
51-
5240
// CreateStorage creates the gcp bucket/storage. The storage bucket does Not include the bucket object. The
5341
// bucket object is created as a separate process/function, so that the two are not tied together, and
5442
// the data stored inside the object can be set at a later time.
@@ -79,9 +67,10 @@ func CreateStorage(ctx context.Context, ic *installconfig.InstallConfig, bucketH
7967
// CreateSignedURL creates a signed url and correlates the signed url with a storage bucket.
8068
func CreateSignedURL(clusterID string) (string, error) {
8169
bucketName := GetBootstrapStorageName(clusterID)
82-
handle, err := CreateBucketHandle(context.Background(), bucketName)
70+
71+
client, err := NewStorageClient(context.TODO())
8372
if err != nil {
84-
return "", fmt.Errorf("creating presigned url, failed to create bucket handle: %w", err)
73+
return "", fmt.Errorf("failed to create storage client: %w", err)
8574
}
8675

8776
// Signing a URL requires credentials authorized to sign a URL. You can pass
@@ -95,7 +84,7 @@ func CreateSignedURL(clusterID string) (string, error) {
9584

9685
// The object has not been created yet. This is ok, it is expected to be created after this call.
9786
// However, if the object is never created this could cause major issues.
98-
url, err := handle.SignedURL(bootstrapIgnitionBucketObjName, &opts)
87+
url, err := client.Bucket(bucketName).SignedURL(bootstrapIgnitionBucketObjName, &opts)
9988
if err != nil {
10089
return "", fmt.Errorf("failed to create a signed url: %w", err)
10190
}
@@ -122,15 +111,14 @@ func FillBucket(ctx context.Context, bucketHandle *storage.BucketHandle, content
122111

123112
// DestroyStorage Destroy the bucket and the bucket objects that are associated with the bucket.
124113
func DestroyStorage(ctx context.Context, clusterID string) error {
125-
ctx, cancel := context.WithTimeout(ctx, time.Minute*1)
126-
defer cancel()
127-
128114
client, err := NewStorageClient(ctx)
129115
if err != nil {
130116
return fmt.Errorf("failed to create storage client: %w", err)
131117
}
132118
bucketName := GetBootstrapStorageName(clusterID)
133119

120+
ctx, cancel := context.WithTimeout(ctx, time.Minute*1)
121+
defer cancel()
134122
if err := client.Bucket(bucketName).Object(bootstrapIgnitionBucketObjName).Delete(ctx); err != nil {
135123
return fmt.Errorf("failed to delete bucket object %s: %w", bootstrapIgnitionBucketObjName, err)
136124
}

0 commit comments

Comments
 (0)