-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Client
Storage v1.42.0
Environment
local machine (MB Pro) (also tested in golang:alpine container)
Go Environment
$ go version
go version go1.22.4 darwin/arm64
Code
package main
import (
"context"
"log"
"time"
"cloud.google.com/go/storage"
)
const (
BucketName = "<BUCKET_NAME>"
ProjectID = "<PROJECT_ID>"
)
func main() {
ctx := context.Background()
// Create a client
client, err := storage.NewClient(ctx)
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
// Create the bucket
err = client.Bucket(BucketName).Create(ctx, ProjectID, &storage.BucketAttrs{
Location: "EU",
SoftDeletePolicy: &storage.SoftDeletePolicy{
// Setting the RetentionDuration to 0 should disable the feature
RetentionDuration: 0,
},
})
if err != nil {
log.Fatalf("Failed to create bucket: %v", err)
}
}
Expected behavior
Bucket gets created without a SoftDeletePolicy / SoftDelete Protection as mentioned in the docs:
https://github.com/googleapis/google-cloud-go/blob/storage/v1.42.0/storage/bucket.go#L491-L492
In order to fully disable soft delete, you need to set a policy with a RetentionDuration of 0.
Actual behavior
Bucket has the default 7 day soft delete policy set.
Screenshots
Additional context
Using any other valid RetentionDuration
- e.g. 10 days using 10 * 24 * time.hour
- is working as expected and sets the SoftDelete Policy to a 10 day retention duration.
Without knowing much about the internal behaviours of the golang storage lib, I would first suspect these lines when looking at the PR that implements the SoftDeletePolicy: https://github.com/googleapis/google-cloud-go/blob/main/storage/bucket.go#L1334-L1336
(But this could also be totally wrong and the issue could be caused by something completely different)