Skip to content

Commit

Permalink
Merge pull request #372 from pixlise/bugfix/lambda-disk-space
Browse files Browse the repository at this point in the history
Print more disk space stats, and ensure download of archived files ha…
  • Loading branch information
pnemere authored Dec 8, 2024
2 parents c47c307 + bdf5f85 commit 6f7c380
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/dataimport/datasetArchive/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ func (dl *DatasetArchiveDownloader) downloadArchivedZipsForDataset(datasetID str
// Download all zip files that have the dataset ID prefixed in their file name
// Unzip them in timestamp order into downloadPath
archiveSearchPath := path.Join(filepaths.RootArchive, datasetID)
if !strings.HasSuffix(archiveSearchPath, "/") {
archiveSearchPath = archiveSearchPath + "/"
}

dl.log.Infof("Searching for archived files in: s3://%v/%v", dl.datasetBucket, archiveSearchPath)

archivedFiles, err := dl.remoteFS.ListObjects(dl.datasetBucket, archiveSearchPath)
Expand Down
23 changes: 22 additions & 1 deletion core/utils/diskfree_nonwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package utils

import (
"fmt"
"os"

"golang.org/x/sys/unix"
Expand All @@ -15,7 +16,27 @@ func GetDiskAvailableBytes() (uint64, error) {
return 0, err
}

unix.Statfs(wd, &stat)
err = unix.Statfs(wd, &stat)
if err != nil {
return 0, err
}

fmt.Sprintf("Bavail: %v", stat.Bavail)
fmt.Sprintf("Bfree: %v", stat.Bfree)
fmt.Sprintf("Blocks: %v", stat.Blocks)
fmt.Sprintf("Bsize: %v", stat.Bsize)
fmt.Sprintf("Ffree: %v", stat.Ffree)
fmt.Sprintf("Files: %v", stat.Files)
fmt.Sprintf("Flags: %v", stat.Flags)
fmt.Sprintf("Flags_ext: %v", stat.Flags_ext)

Check failure on line 31 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / build

stat.Flags_ext undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Flags_ext)

Check failure on line 31 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / test

stat.Flags_ext undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Flags_ext)

Check failure on line 31 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / build

stat.Flags_ext undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Flags_ext)

Check failure on line 31 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / test

stat.Flags_ext undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Flags_ext)
fmt.Sprintf("Fsid: %v", stat.Fsid.Val)
fmt.Sprintf("Fssubtype: %v", stat.Fssubtype)

Check failure on line 33 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / build

stat.Fssubtype undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Fssubtype)

Check failure on line 33 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / test

stat.Fssubtype undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Fssubtype)

Check failure on line 33 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / build

stat.Fssubtype undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Fssubtype)

Check failure on line 33 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / test

stat.Fssubtype undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Fssubtype)
fmt.Sprintf("Fstypename: %v", stat.Fstypename)

Check failure on line 34 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / build

stat.Fstypename undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Fstypename)

Check failure on line 34 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / test

stat.Fstypename undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Fstypename)

Check failure on line 34 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / build

stat.Fstypename undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Fstypename)

Check failure on line 34 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / test

stat.Fstypename undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Fstypename)
fmt.Sprintf("Iosize: %v", stat.Iosize)

Check failure on line 35 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / build

stat.Iosize undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Iosize)

Check failure on line 35 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / test

stat.Iosize undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Iosize)

Check failure on line 35 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / build

stat.Iosize undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Iosize)

Check failure on line 35 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / test

stat.Iosize undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Iosize)
fmt.Sprintf("Mntfromname: %v", stat.Mntfromname)

Check failure on line 36 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / build

stat.Mntfromname undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Mntfromname)

Check failure on line 36 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / test

stat.Mntfromname undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Mntfromname)

Check failure on line 36 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / build

stat.Mntfromname undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Mntfromname)

Check failure on line 36 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / test

stat.Mntfromname undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Mntfromname)
fmt.Sprintf("Mntonname: %v", stat.Mntonname)

Check failure on line 37 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / build

stat.Mntonname undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Mntonname)

Check failure on line 37 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / test

stat.Mntonname undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Mntonname)

Check failure on line 37 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / build

stat.Mntonname undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Mntonname)

Check failure on line 37 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / test

stat.Mntonname undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Mntonname)
fmt.Sprintf("Owner: %v", stat.Owner)

Check failure on line 38 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / build

stat.Owner undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Owner)

Check failure on line 38 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / prerelease / test

stat.Owner undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Owner)

Check failure on line 38 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / build

stat.Owner undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Owner)

Check failure on line 38 in core/utils/diskfree_nonwindows.go

View workflow job for this annotation

GitHub Actions / release / test

stat.Owner undefined (type "golang.org/x/sys/unix".Statfs_t has no field or method Owner)
fmt.Sprintf("Type: %v", stat.Type)

// Available blocks * size per block = available space in bytes
return stat.Bavail * uint64(stat.Bsize), nil
Expand Down

0 comments on commit 6f7c380

Please sign in to comment.