Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
go-version: "1.26"
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports
- name: Formatting diff
Expand All @@ -26,7 +26,7 @@ jobs:
linux-tests:
strategy:
matrix:
go: [ 1.23.x ]
go: [ 1.26.x ]
runs-on: ubuntu-latest
timeout-minutes: 15

Expand Down Expand Up @@ -64,12 +64,13 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.23"
go-version: "1.26"
- name: checkout code
uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@032fa5c5e48499f06cf9d32c02149bfac1284239
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: -E=goimports --timeout 2m0s
only-new-issues: true

2 changes: 1 addition & 1 deletion .github/workflows/flake-detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.x
go-version: 1.26.x
cache: false
- name: Install fuse
run: sudo apt-get update && sudo apt-get install -y fuse3 libfuse-dev
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Mount the gcsfuse to /mnt/gcs:
# > docker run --privileged --device /fuse -v /mnt/gcs:/gcs:rw,rshared gcsfuse

FROM golang:1.23.0-alpine as builder
FROM golang:1.26.1-alpine as builder

RUN apk add git

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/googlecloudplatform/gcsfuse/v2

go 1.23.0
go 1.26.1

require (
cloud.google.com/go/compute/metadata v0.5.0
Expand Down
2 changes: 1 addition & 1 deletion internal/cache/file/downloader/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (job *Job) Download(ctx context.Context, offset int64, waitForDownload bool
job.mu.Lock()
if int64(job.object.Size) < offset {
defer job.mu.Unlock()
err = fmt.Errorf(fmt.Sprintf("Download: the requested offset %d is greater than the size of object %d", offset, job.object.Size))
err = fmt.Errorf("Download: the requested offset %d is greater than the size of object %d", offset, job.object.Size)
return job.status, err
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cache/file/downloader/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ func (dt *downloaderTest) Test_Download_Concurrent() {
ctx := context.Background()
wg := sync.WaitGroup{}
offsets := []int64{0, 4 * util.MiB, 16 * util.MiB, 8 * util.MiB, int64(objectSize), int64(objectSize) + 1}
expectedErrs := []error{nil, nil, nil, nil, nil, fmt.Errorf(fmt.Sprintf("Download: the requested offset %d is greater than the size of object %d", int64(objectSize)+1, int64(objectSize)))}
expectedErrs := []error{nil, nil, nil, nil, nil, fmt.Errorf("Download: the requested offset %d is greater than the size of object %d", int64(objectSize)+1, int64(objectSize))}
downloadFunc := func(expectedOffset int64, expectedErr error) {
defer wg.Done()
var jobStatus JobStatus
Expand Down
2 changes: 1 addition & 1 deletion internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func Errorf(format string, v ...interface{}) {
// Fatal prints an error log and exits with non-zero exit code.
func Fatal(format string, v ...interface{}) {
Errorf(format, v...)
Errorf(string(debug.Stack()))
Errorf("%s", string(debug.Stack()))
os.Exit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion perfmetrics/scripts/ml_tests/pytorch/run_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NUM_EPOCHS=80
TEST_BUCKET="gcsfuse-ml-data"

# Install golang
wget -O go_tar.tar.gz https://go.dev/dl/go1.23.0.linux-amd64.tar.gz -q
wget -O go_tar.tar.gz https://go.dev/dl/go1.26.1.linux-amd64.tar.gz -q
rm -rf /usr/local/go && tar -C /usr/local -xzf go_tar.tar.gz
export PATH=$PATH:/usr/local/go/bin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Installs go1.23.0 on the container, builds gcsfuse using log_rotation file
# Installs go1.26.1 on the container, builds gcsfuse using log_rotation file
# and installs tf-models-official v2.13.2, makes update to include clear_kernel_cache
# and epochs functionality, and runs the model

# Install go lang
BUCKET_TYPE=$1
wget -O go_tar.tar.gz https://go.dev/dl/go1.23.0.linux-amd64.tar.gz -q
wget -O go_tar.tar.gz https://go.dev/dl/go1.26.1.linux-amd64.tar.gz -q
sudo rm -rf /usr/local/go && tar -xzf go_tar.tar.gz && sudo mv go /usr/local
export PATH=$PATH:/usr/local/go/bin

Expand Down
4 changes: 2 additions & 2 deletions perfmetrics/scripts/presubmit_test/pr_perf_test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ set -e
sudo apt-get update
echo Installing git
sudo apt-get install git
echo Installing go-lang 1.23.0
wget -O go_tar.tar.gz https://go.dev/dl/go1.23.0.linux-amd64.tar.gz -q
echo Installing go-lang 1.26.1
wget -O go_tar.tar.gz https://go.dev/dl/go1.26.1.linux-amd64.tar.gz -q
sudo rm -rf /usr/local/go && tar -xzf go_tar.tar.gz && sudo mv go /usr/local
export PATH=$PATH:/usr/local/go/bin
export CGO_ENABLED=0
Expand Down
2 changes: 1 addition & 1 deletion perfmetrics/scripts/read_cache/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ sed -i 's/define \+FIO_IO_U_PLAT_GROUP_NR \+\([0-9]\+\)/define FIO_IO_U_PLAT_GRO
cd -

# Install and validate go.
version=1.23.0
version=1.26.1
wget -O go_tar.tar.gz https://go.dev/dl/go${version}.linux-amd64.tar.gz -q
sudo rm -rf /usr/local/go
tar -xzf go_tar.tar.gz && sudo mv go /usr/local
Expand Down
2 changes: 1 addition & 1 deletion tools/cd_scripts/e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ else
fi
# install go
wget -O go_tar.tar.gz https://go.dev/dl/go1.23.0.linux-${architecture}.tar.gz
wget -O go_tar.tar.gz https://go.dev/dl/go1.26.1.linux-${architecture}.tar.gz
sudo tar -C /usr/local -xzf go_tar.tar.gz
export PATH=${PATH}:/usr/local/go/bin
#Write gcsfuse and go version to log file
Expand Down
2 changes: 1 addition & 1 deletion tools/containerize_gcsfuse_docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ARG OS_VERSION
ARG OS_NAME

# Image with gcsfuse installed and its package (.deb)
FROM golang:1.23.0 as gcsfuse-package
FROM golang:1.26.1 as gcsfuse-package

RUN apt-get update -qq && apt-get install -y ruby ruby-dev rubygems build-essential rpm fuse && gem install --no-document bundler

Expand Down
8 changes: 4 additions & 4 deletions tools/integration_tests/managed_folders/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ func providePermissionToManagedFolder(bucket, managedFolderPath, serviceAccount,
// Indent for readability
jsonData, err := json.MarshalIndent(policy, "", " ")
if err != nil {
t.Fatalf(fmt.Sprintf("Error in marshal the data into JSON format: %v", err))
t.Fatalf("Error in marshal the data into JSON format: %v", err)
}

localIAMPolicyFilePath := path.Join(os.Getenv("HOME"), "iam_policy.json")
// Write the JSON to a FileInNonEmptyManagedFoldersTest
err = os.WriteFile(localIAMPolicyFilePath, jsonData, setup.FilePermission_0600)
if err != nil {
t.Fatalf(fmt.Sprintf("Error in writing iam policy in json FileInNonEmptyManagedFoldersTest : %v", err))
t.Fatalf("Error in writing iam policy in json FileInNonEmptyManagedFoldersTest : %v", err)
}

gcloudProvidePermissionCmd := fmt.Sprintf("alpha storage managed-folders set-iam-policy gs://%s/%s %s", bucket, managedFolderPath, localIAMPolicyFilePath)
_, err = operations.ExecuteGcloudCommandf(gcloudProvidePermissionCmd)
_, err = operations.ExecuteGcloudCommandf("%s", gcloudProvidePermissionCmd)
Comment on lines 85 to +86
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of pre-formatting the command string with fmt.Sprintf and then passing it to ExecuteGcloudCommandf with a "%s" format, you can pass the arguments directly to ExecuteGcloudCommandf. This is cleaner and avoids redundant formatting.

Suggested change
gcloudProvidePermissionCmd := fmt.Sprintf("alpha storage managed-folders set-iam-policy gs://%s/%s %s", bucket, managedFolderPath, localIAMPolicyFilePath)
_, err = operations.ExecuteGcloudCommandf(gcloudProvidePermissionCmd)
_, err = operations.ExecuteGcloudCommandf("%s", gcloudProvidePermissionCmd)
_, err = operations.ExecuteGcloudCommandf("alpha storage managed-folders set-iam-policy gs://%s/%s %s", bucket, managedFolderPath, localIAMPolicyFilePath)
References
  1. In integration tests, it is acceptable to use exec.Command to call external tools if the test's explicit purpose is to verify the system's behavior when interacting with that specific external tool.

if err != nil {
t.Fatalf("Error in providing permission to managed folder: %v", err)
}
Expand All @@ -92,7 +92,7 @@ func providePermissionToManagedFolder(bucket, managedFolderPath, serviceAccount,
func revokePermissionToManagedFolder(bucket, managedFolderPath, serviceAccount, iamRole string, t *testing.T) {
gcloudRevokePermissionCmd := fmt.Sprintf("alpha storage managed-folders remove-iam-policy-binding gs://%s/%s --member=%s --role=%s", bucket, managedFolderPath, serviceAccount, iamRole)

_, err := operations.ExecuteGcloudCommandf(gcloudRevokePermissionCmd)
_, err := operations.ExecuteGcloudCommandf("%s", gcloudRevokePermissionCmd)
Comment on lines 93 to +95
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The command can be passed directly to ExecuteGcloudCommandf without an intermediate fmt.Sprintf call.

Suggested change
gcloudRevokePermissionCmd := fmt.Sprintf("alpha storage managed-folders remove-iam-policy-binding gs://%s/%s --member=%s --role=%s", bucket, managedFolderPath, serviceAccount, iamRole)
_, err := operations.ExecuteGcloudCommandf(gcloudRevokePermissionCmd)
_, err := operations.ExecuteGcloudCommandf("%s", gcloudRevokePermissionCmd)
_, err := operations.ExecuteGcloudCommandf("alpha storage managed-folders remove-iam-policy-binding gs://%s/%s --member=%s --role=%s", bucket, managedFolderPath, serviceAccount, iamRole)
References
  1. In integration tests, it is acceptable to use exec.Command to call external tools if the test's explicit purpose is to verify the system's behavior when interacting with that specific external tool.

if err != nil && !strings.Contains(err.Error(), "Policy binding with the specified principal, role, and condition not found!") && !strings.Contains(err.Error(), "The specified managed folder does not exist.") {
t.Fatalf("Error in removing permission to managed folder: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions tools/integration_tests/run_e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ function upgrade_gcloud_version() {
function install_packages() {
# e.g. architecture=arm64 or amd64
architecture=$(dpkg --print-architecture)
echo "Installing go-lang 1.23.0..."
wget -O go_tar.tar.gz https://go.dev/dl/go1.23.0.linux-${architecture}.tar.gz -q
echo "Installing go-lang 1.26.1..."
wget -O go_tar.tar.gz https://go.dev/dl/go1.26.1.linux-${architecture}.tar.gz -q
sudo rm -rf /usr/local/go && tar -xzf go_tar.tar.gz && sudo mv go /usr/local
export PATH=$PATH:/usr/local/go/bin
# install python3-setuptools tools.
Expand Down
6 changes: 3 additions & 3 deletions tools/integration_tests/util/creds_tests/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func CreateCredentials() (serviceAccount, localKeyFilePath string) {

// Download credentials
gcloudSecretAccessCmd := fmt.Sprintf("secrets versions access latest --secret %s", CredentialsSecretName)
creds, err := operations.ExecuteGcloudCommandf(gcloudSecretAccessCmd)
creds, err := operations.ExecuteGcloudCommandf("%s", gcloudSecretAccessCmd)
Comment on lines 60 to +61
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Simplify the command execution by passing the format string and arguments directly to ExecuteGcloudCommandf.

Suggested change
gcloudSecretAccessCmd := fmt.Sprintf("secrets versions access latest --secret %s", CredentialsSecretName)
creds, err := operations.ExecuteGcloudCommandf(gcloudSecretAccessCmd)
creds, err := operations.ExecuteGcloudCommandf("%s", gcloudSecretAccessCmd)
creds, err := operations.ExecuteGcloudCommandf("secrets versions access latest --secret %s", CredentialsSecretName)
References
  1. In integration tests, it is acceptable to use exec.Command to call external tools if the test's explicit purpose is to verify the system's behavior when interacting with that specific external tool.

if err != nil {
setup.LogAndExit(fmt.Sprintf("Error while fetching key file %v", err))
}
Expand All @@ -79,7 +79,7 @@ func CreateCredentials() (serviceAccount, localKeyFilePath string) {

func ApplyPermissionToServiceAccount(serviceAccount, permission, bucket string) {
// Provide permission to service account for testing.
_, err := operations.ExecuteGcloudCommandf(fmt.Sprintf("storage buckets add-iam-policy-binding gs://%s --member=serviceAccount:%s --role=roles/storage.%s", bucket, serviceAccount, permission))
_, err := operations.ExecuteGcloudCommandf("storage buckets add-iam-policy-binding gs://%s --member=serviceAccount:%s --role=roles/storage.%s", bucket, serviceAccount, permission)
if err != nil {
setup.LogAndExit(fmt.Sprintf("Error while setting permissions to SA: %v", err))
}
Expand All @@ -91,7 +91,7 @@ func ApplyPermissionToServiceAccount(serviceAccount, permission, bucket string)
func RevokePermission(serviceAccount, permission, bucket string) {
// Revoke the permission to service account after testing.
cmd := fmt.Sprintf("storage buckets remove-iam-policy-binding gs://%s --member=serviceAccount:%s --role=roles/storage.%s", bucket, serviceAccount, permission)
_, err := operations.ExecuteGcloudCommandf(cmd)
_, err := operations.ExecuteGcloudCommandf("%s", cmd)
Comment on lines 93 to +94
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid redundant formatting by passing the arguments directly to ExecuteGcloudCommandf.

Suggested change
cmd := fmt.Sprintf("storage buckets remove-iam-policy-binding gs://%s --member=serviceAccount:%s --role=roles/storage.%s", bucket, serviceAccount, permission)
_, err := operations.ExecuteGcloudCommandf(cmd)
_, err := operations.ExecuteGcloudCommandf("%s", cmd)
_, err := operations.ExecuteGcloudCommandf("storage buckets remove-iam-policy-binding gs://%s --member=serviceAccount:%s --role=roles/storage.%s", bucket, serviceAccount, permission)
References
  1. In integration tests, it is acceptable to use exec.Command to call external tools if the test's explicit purpose is to verify the system's behavior when interacting with that specific external tool.

if err != nil {
setup.LogAndExit(fmt.Sprintf("Error in unsetting permissions to SA: %v", err))
}
Expand Down
12 changes: 6 additions & 6 deletions tools/integration_tests/util/operations/dir_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,26 @@ func DirSizeMiB(dirPath string) (dirSizeMB int64, err error) {
func DeleteManagedFoldersInBucket(managedFolderPath, bucket string) {
gcloudDeleteManagedFolderCmd := fmt.Sprintf("alpha storage rm -r gs://%s/%s", bucket, managedFolderPath)

_, err := ExecuteGcloudCommandf(gcloudDeleteManagedFolderCmd)
_, err := ExecuteGcloudCommandf("%s", gcloudDeleteManagedFolderCmd)
Comment on lines 173 to +175
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Simplify by passing the format string and arguments directly to ExecuteGcloudCommandf.

Suggested change
gcloudDeleteManagedFolderCmd := fmt.Sprintf("alpha storage rm -r gs://%s/%s", bucket, managedFolderPath)
_, err := ExecuteGcloudCommandf(gcloudDeleteManagedFolderCmd)
_, err := ExecuteGcloudCommandf("%s", gcloudDeleteManagedFolderCmd)
_, err := ExecuteGcloudCommandf("alpha storage rm -r gs://%s/%s", bucket, managedFolderPath)
References
  1. In integration tests, it is acceptable to use exec.Command to call external tools if the test's explicit purpose is to verify the system's behavior when interacting with that specific external tool.

if err != nil && !strings.Contains(err.Error(), "The following URLs matched no objects or files") {
log.Fatalf(fmt.Sprintf("Error while deleting managed folder: %v", err))
log.Fatalf("Error while deleting managed folder: %v", err)
}
}

func CreateManagedFoldersInBucket(managedFolderPath, bucket string) {
gcloudCreateManagedFolderCmd := fmt.Sprintf("alpha storage managed-folders create gs://%s/%s", bucket, managedFolderPath)

_, err := ExecuteGcloudCommandf(gcloudCreateManagedFolderCmd)
_, err := ExecuteGcloudCommandf("%s", gcloudCreateManagedFolderCmd)
Comment on lines 182 to +184
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Simplify by passing the format string and arguments directly to ExecuteGcloudCommandf.

Suggested change
gcloudCreateManagedFolderCmd := fmt.Sprintf("alpha storage managed-folders create gs://%s/%s", bucket, managedFolderPath)
_, err := ExecuteGcloudCommandf(gcloudCreateManagedFolderCmd)
_, err := ExecuteGcloudCommandf("%s", gcloudCreateManagedFolderCmd)
_, err := ExecuteGcloudCommandf("alpha storage managed-folders create gs://%s/%s", bucket, managedFolderPath)
References
  1. In integration tests, it is acceptable to use exec.Command to call external tools if the test's explicit purpose is to verify the system's behavior when interacting with that specific external tool.

if err != nil && !strings.Contains(err.Error(), "The specified managed folder already exists") {
log.Fatalf(fmt.Sprintf("Error while creating managed folder: %v", err))
log.Fatalf("Error while creating managed folder: %v", err)
}
}

func CopyFileInBucket(srcfilePath, destFilePath, bucket string, t *testing.T) {
gcloudCopyFileCmd := fmt.Sprintf("alpha storage cp %s gs://%s/%s/", srcfilePath, bucket, destFilePath)

_, err := ExecuteGcloudCommandf(gcloudCopyFileCmd)
_, err := ExecuteGcloudCommandf("%s", gcloudCopyFileCmd)
Comment on lines 191 to +193
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Simplify by passing the format string and arguments directly to ExecuteGcloudCommandf.

Suggested change
gcloudCopyFileCmd := fmt.Sprintf("alpha storage cp %s gs://%s/%s/", srcfilePath, bucket, destFilePath)
_, err := ExecuteGcloudCommandf(gcloudCopyFileCmd)
_, err := ExecuteGcloudCommandf("%s", gcloudCopyFileCmd)
_, err := ExecuteGcloudCommandf("alpha storage cp %s gs://%s/%s/", srcfilePath, bucket, destFilePath)
References
  1. In integration tests, it is acceptable to use exec.Command to call external tools if the test's explicit purpose is to verify the system's behavior when interacting with that specific external tool.

if err != nil {
t.Fatalf(fmt.Sprintf("Error while copying file in bucket: %v", err))
t.Fatalf("Error while copying file in bucket: %v", err)
}
}
2 changes: 1 addition & 1 deletion tools/package_gcsfuse_docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Copy the gcsfuse packages to the host:
# > docker run -it -v /tmp:/output gcsfuse-release cp -r /packages /output

FROM golang:1.23.0 as builder
FROM golang:1.26.1 as builder

RUN apt-get update -qq && apt-get install -y ruby ruby-dev rubygems build-essential rpm && gem install --no-document bundler

Expand Down
2 changes: 1 addition & 1 deletion tools/prefetch_cache_gcsfuse/prefetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
const NUM_WORKERS = 10

func downloadFile(ctx context.Context, client *storage.Client, object *storage.ObjectAttrs, cacheDir string) (err error) {
log.Printf(fmt.Sprintf("downloading file %v from bucket %v into dir %v", object.Name, object.Bucket, cacheDir))
log.Printf("downloading file %v from bucket %v into dir %v", object.Name, object.Bucket, cacheDir)

// We may want a way to verify the files are fully downloaded
// and either resuming the download or discarding and redownloading the file
Expand Down
Loading