From 61256617a1cc1ddab9c731b701341b5dbaf40fe2 Mon Sep 17 00:00:00 2001 From: James Fantin-Hardesty <24646452+jfantinhardesty@users.noreply.github.com> Date: Tue, 12 Nov 2024 08:41:15 -0700 Subject: [PATCH 1/3] Small cleanup of code --- cmd/mount.go | 7 ++-- cmd/mount_linux.go | 4 +-- cmd/secure.go | 2 +- cmd/secure_test.go | 2 +- common/config/config_test.go | 2 ++ component/block_cache/block_cache_linux.go | 4 +-- .../block_cache/block_cache_linux_test.go | 24 ++++++------- component/file_cache/file_cache_test.go | 2 +- component/loopback/loopback_fs.go | 8 ++--- component/stream/read_write_filename_test.go | 4 --- component/stream/read_write_test.go | 4 --- internal/pipeline_test.go | 3 +- internal/stats_manager/stats_manager_linux.go | 6 ++-- releaseVersionUpdate.py | 36 ------------------- test/benchmark_test/benchmark_test.go | 2 +- test/e2e_tests/data_validation_test.go | 7 ---- test/e2e_tests/dir_test.go | 2 +- test/e2e_tests/file_test.go | 4 +-- tools/health-monitor/internal/stats_export.go | 2 +- .../cloudfuse_stats/stats_reader_linux.go | 4 +-- 20 files changed, 40 insertions(+), 89 deletions(-) delete mode 100644 releaseVersionUpdate.py diff --git a/cmd/mount.go b/cmd/mount.go index 6ec800c2d..f73c8c8a2 100644 --- a/cmd/mount.go +++ b/cmd/mount.go @@ -165,7 +165,7 @@ func (opt *mountOptions) validate(skipNonEmptyMount bool) error { if err != nil && os.IsNotExist(err) { // create the default work dir - if err = os.MkdirAll(common.ExpandPath(common.DefaultWorkDir), 0777); err != nil { + if err = os.MkdirAll(common.ExpandPath(common.DefaultWorkDir), 0755); err != nil { return fmt.Errorf("failed to create default work dir [%s]", err.Error()) } } @@ -526,8 +526,9 @@ var mountCmd = &cobra.Command{ pid := os.Getpid() fname := fmt.Sprintf("/tmp/cloudfuse.%v", pid) - ctx, _ := context.WithCancel(context.Background()) //nolint - err = createDaemon(pipeline, ctx, pidFileName, 0644, 027, fname) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + err = createDaemon(pipeline, ctx, pidFileName, 0644, 022, fname) if err != nil { return fmt.Errorf("mount: failed to create daemon [%v]", err.Error()) } diff --git a/cmd/mount_linux.go b/cmd/mount_linux.go index 3dae16b1b..0743706d7 100644 --- a/cmd/mount_linux.go +++ b/cmd/mount_linux.go @@ -45,8 +45,8 @@ import ( func createDaemon(pipeline *internal.Pipeline, ctx context.Context, pidFileName string, pidFilePerm os.FileMode, umask int, fname string) error { dmnCtx := &daemon.Context{ PidFileName: pidFileName, - PidFilePerm: 0644, - Umask: 022, + PidFilePerm: pidFilePerm, + Umask: umask, LogFileName: fname, // this will redirect stderr of child to given file } diff --git a/cmd/secure.go b/cmd/secure.go index 3d4f8396f..953630b77 100644 --- a/cmd/secure.go +++ b/cmd/secure.go @@ -196,7 +196,7 @@ func decryptConfigFile(saveConfig bool) ([]byte, error) { // saveToFile: Save the newly generated config file and delete the source if requested func saveToFile(configFileName string, data []byte, deleteSource bool) error { - err := os.WriteFile(configFileName, data, 0777) + err := os.WriteFile(configFileName, data, 0644) if err != nil { return err } diff --git a/cmd/secure_test.go b/cmd/secure_test.go index cb71e7945..9cb73aa7f 100644 --- a/cmd/secure_test.go +++ b/cmd/secure_test.go @@ -218,7 +218,7 @@ func (suite *secureConfigTestSuite) TestSecureConfigDecrypt() { // Config file should be deleted suite.assert.NoFileExists(confFile.Name()) - _, err = executeCommandSecure(rootCmd, "secure", "decrypt", fmt.Sprintf("--config-file=%s", outFile.Name()), "--passphrase=12312312312312312312312312312312", fmt.Sprintf("--output-file=./tmp.yaml")) + _, err = executeCommandSecure(rootCmd, "secure", "decrypt", fmt.Sprintf("--config-file=%s", outFile.Name()), "--passphrase=12312312312312312312312312312312", "--output-file=./tmp.yaml") suite.assert.NoError(err) data, err := os.ReadFile("./tmp.yaml") diff --git a/common/config/config_test.go b/common/config/config_test.go index 779fd1b43..a7b0165d1 100644 --- a/common/config/config_test.go +++ b/common/config/config_test.go @@ -155,6 +155,7 @@ func (suite *ConfigTestSuite) TestOverlapShadowConfigReader() { templAppFlag.Changed = true BindPFlag("template.metadata.labels.app", templAppFlag) err = os.Setenv("CF_TEST_TEMPLABELS_APP", "somethingthatshouldnotshowup") + assert.NoError(err) BindEnv("template.metadata.labels.app", "CF_TEST_TEMPLABELS_APP") err = ReadConfigFromReader(strings.NewReader(specconf)) @@ -306,6 +307,7 @@ func (suite *ConfigTestSuite) TestPlainConfig1Reader() { }{} err = Unmarshal(&randOpts) + assert.NoError(err) assert.Empty(randOpts) } diff --git a/component/block_cache/block_cache_linux.go b/component/block_cache/block_cache_linux.go index c8466205d..d52014b57 100644 --- a/component/block_cache/block_cache_linux.go +++ b/component/block_cache/block_cache_linux.go @@ -967,7 +967,7 @@ func (bc *BlockCache) download(item *workItem) { item.block.endIndex = item.block.offset + uint64(n) if bc.tmpPath != "" { - err := os.MkdirAll(filepath.Dir(localPath), 0777) + err := os.MkdirAll(filepath.Dir(localPath), 0755) if err != nil { log.Err("BlockCache::download : error creating directory structure for file %s [%s]", localPath, err.Error()) return @@ -1376,7 +1376,7 @@ func (bc *BlockCache) upload(item *workItem) { if bc.tmpPath != "" { localPath := filepath.Join(bc.tmpPath, fileName) - err := os.MkdirAll(filepath.Dir(localPath), 0777) + err := os.MkdirAll(filepath.Dir(localPath), 0755) if err != nil { log.Err("BlockCache::upload : error creating directory structure for file %s [%s]", localPath, err.Error()) goto return_safe diff --git a/component/block_cache/block_cache_linux_test.go b/component/block_cache/block_cache_linux_test.go index d5bcffa80..256c3c00f 100644 --- a/component/block_cache/block_cache_linux_test.go +++ b/component/block_cache/block_cache_linux_test.go @@ -43,7 +43,6 @@ import ( "encoding/base64" "fmt" "io" - "io/ioutil" "math" mrand "math/rand/v2" "os" @@ -335,7 +334,7 @@ func (suite *blockCacheTestSuite) TestFileOpenClose() { storagePath := filepath.Join(tobj.fake_storage_path, fileName) data := make([]byte, 5*_1MB) _, _ = rand.Read(data) - ioutil.WriteFile(storagePath, data, 0777) + os.WriteFile(storagePath, data, 0777) options := internal.OpenFileOptions{Name: fileName} h, err := tobj.blockCache.OpenFile(options) @@ -560,15 +559,16 @@ func (suite *blockCacheTestSuite) TestFileReadBlockCacheTmpPath() { tmpPath := tobj.blockCache.tmpPath - files, err := ioutil.ReadDir(tmpPath) + files, err := os.ReadDir(tmpPath) suite.assert.NoError(err) var size1048576, size7 bool for _, file := range files { - if file.Size() == 1048576 { + info, _ := file.Info() + if info.Size() == 1048576 { size1048576 = true } - if file.Size() == 7 { + if info.Size() == 7 { size7 = true } } @@ -592,7 +592,7 @@ func (suite *blockCacheTestSuite) TestFileReadSerial() { storagePath := filepath.Join(tobj.fake_storage_path, fileName) data := make([]byte, 50*_1MB) _, _ = rand.Read(data) - ioutil.WriteFile(storagePath, data, 0777) + os.WriteFile(storagePath, data, 0777) options := internal.OpenFileOptions{Name: fileName} h, err := tobj.blockCache.OpenFile(options) @@ -634,7 +634,7 @@ func (suite *blockCacheTestSuite) TestFileReadRandom() { storagePath := filepath.Join(tobj.fake_storage_path, fileName) data := make([]byte, 100*_1MB) _, _ = rand.Read(data) - ioutil.WriteFile(storagePath, data, 0777) + os.WriteFile(storagePath, data, 0777) options := internal.OpenFileOptions{Name: fileName} h, err := tobj.blockCache.OpenFile(options) @@ -675,7 +675,7 @@ func (suite *blockCacheTestSuite) TestFileReadRandomNoPrefetch() { storagePath := filepath.Join(tobj.fake_storage_path, fileName) data := make([]byte, 100*_1MB) _, _ = rand.Read(data) - ioutil.WriteFile(storagePath, data, 0777) + os.WriteFile(storagePath, data, 0777) options := internal.OpenFileOptions{Name: fileName} h, err := tobj.blockCache.OpenFile(options) @@ -792,7 +792,7 @@ func (suite *blockCacheTestSuite) TestOpenWithTruncate() { storagePath := filepath.Join(tobj.fake_storage_path, fileName) data := make([]byte, 5*_1MB) _, _ = rand.Read(data) - ioutil.WriteFile(storagePath, data, 0777) + os.WriteFile(storagePath, data, 0777) options := internal.OpenFileOptions{Name: fileName} h, err := tobj.blockCache.OpenFile(options) @@ -885,7 +885,6 @@ func (suite *blockCacheTestSuite) TestWriteFileMultiBlock() { suite.assert.NotNil(tobj.blockCache) path := getTestFileName(suite.T().Name()) - storagePath := filepath.Join(tobj.fake_storage_path, path) data := make([]byte, 5*_1MB) _, _ = rand.Read(data) @@ -908,7 +907,7 @@ func (suite *blockCacheTestSuite) TestWriteFileMultiBlock() { err = tobj.blockCache.CloseFile(internal.CloseFileOptions{Handle: h}) suite.assert.NoError(err) - storagePath = filepath.Join(tobj.fake_storage_path, path) + storagePath := filepath.Join(tobj.fake_storage_path, path) fs, err := os.Stat(storagePath) suite.assert.NoError(err) suite.assert.Equal(fs.Size(), int64(len(data))) @@ -924,7 +923,6 @@ func (suite *blockCacheTestSuite) TestWriteFileMultiBlockWithOverwrite() { suite.assert.NotNil(tobj.blockCache) path := getTestFileName(suite.T().Name()) - storagePath := filepath.Join(tobj.fake_storage_path, path) data := make([]byte, 5*_1MB) _, _ = rand.Read(data) @@ -959,7 +957,7 @@ func (suite *blockCacheTestSuite) TestWriteFileMultiBlockWithOverwrite() { err = tobj.blockCache.CloseFile(internal.CloseFileOptions{Handle: h}) suite.assert.NoError(err) - storagePath = filepath.Join(tobj.fake_storage_path, path) + storagePath := filepath.Join(tobj.fake_storage_path, path) fs, err := os.Stat(storagePath) suite.assert.NoError(err) suite.assert.Equal(fs.Size(), int64(len(data))) diff --git a/component/file_cache/file_cache_test.go b/component/file_cache/file_cache_test.go index 761896049..8dcc6b4e8 100644 --- a/component/file_cache/file_cache_test.go +++ b/component/file_cache/file_cache_test.go @@ -1645,7 +1645,7 @@ func (suite *fileCacheTestSuite) TestReadFileWithRefresh() { // Now wait for refresh timeout and we shall get the updated content on next read byteArr = []byte("test data123456") - err = os.WriteFile(suite.fake_storage_path+"/"+path, []byte("test data123456"), 0777) + err = os.WriteFile(suite.fake_storage_path+"/"+path, byteArr, 0777) suite.assert.NoError(err) time.Sleep(2 * time.Second) f, err = suite.fileCache.OpenFile(options) diff --git a/component/loopback/loopback_fs.go b/component/loopback/loopback_fs.go index a5f48468a..7cbca87f8 100644 --- a/component/loopback/loopback_fs.go +++ b/component/loopback/loopback_fs.go @@ -253,7 +253,7 @@ func (lfs *LoopbackFS) ReadInBuffer(options internal.ReadInBufferOptions) (int, f := options.Handle.GetFileObject() if f == nil { - f1, err := os.OpenFile(filepath.Join(lfs.path, options.Handle.Path), os.O_RDONLY, 0666) + f1, err := os.Open(filepath.Join(lfs.path, options.Handle.Path)) if err != nil { return 0, nil } @@ -397,7 +397,7 @@ func (lfs *LoopbackFS) Chown(options internal.ChownOptions) error { func (lfs *LoopbackFS) StageData(options internal.StageDataOptions) error { log.Trace("LoopbackFS::StageData : name=%s, id=%s", options.Name, options.Id) path := fmt.Sprintf("%s_%s", filepath.Join(lfs.path, options.Name), strings.ReplaceAll(options.Id, "/", "_")) - return os.WriteFile(path, options.Data, 0777) + return os.WriteFile(path, options.Data, 0644) } func (lfs *LoopbackFS) CommitData(options internal.CommitDataOptions) error { @@ -405,7 +405,7 @@ func (lfs *LoopbackFS) CommitData(options internal.CommitDataOptions) error { mainFilepath := filepath.Join(lfs.path, options.Name) - blob, err := os.OpenFile(mainFilepath, os.O_RDWR|os.O_CREATE, os.FileMode(0777)) + blob, err := os.OpenFile(mainFilepath, os.O_RDWR|os.O_CREATE, os.FileMode(0644)) if err != nil { log.Err("LoopbackFS::CommitData : error opening [%s]", err) return err @@ -415,7 +415,7 @@ func (lfs *LoopbackFS) CommitData(options internal.CommitDataOptions) error { path := fmt.Sprintf("%s_%s", filepath.Join(lfs.path, options.Name), strings.ReplaceAll(id, "/", "_")) info, err := os.Lstat(path) if err == nil { - block, err := os.OpenFile(path, os.O_RDONLY, os.FileMode(0666)) + block, err := os.Open(path) if err != nil { return err } diff --git a/component/stream/read_write_filename_test.go b/component/stream/read_write_filename_test.go index 36af242b2..7a4bc6898 100644 --- a/component/stream/read_write_filename_test.go +++ b/component/stream/read_write_filename_test.go @@ -339,11 +339,7 @@ func (suite *streamTestSuite) TestFilenameStreamOnly() { // open new file handle = &handlemap.Handle{Size: int64(4 * MB), Path: fileNames[1]} - getFileBlockOffsetsOptions = internal.GetFileBlockOffsetsOptions{Name: fileNames[0]} openFileOptions = internal.OpenFileOptions{Name: fileNames[1], Flags: os.O_RDONLY, Mode: os.FileMode(0777)} - bol = &common.BlockOffsetList{ - BlockList: []*common.Block{{StartIndex: 0, EndIndex: 2 * MB}, {StartIndex: 2, EndIndex: 4 * MB}}, - } suite.mock.EXPECT().OpenFile(openFileOptions).Return(handle, nil) _, _ = suite.stream.OpenFile(openFileOptions) diff --git a/component/stream/read_write_test.go b/component/stream/read_write_test.go index 03424c237..3fccac251 100644 --- a/component/stream/read_write_test.go +++ b/component/stream/read_write_test.go @@ -339,11 +339,7 @@ func (suite *streamTestSuite) TestStreamOnly() { // create new handle handle = &handlemap.Handle{Size: int64(4 * MB), Path: fileNames[0]} - getFileBlockOffsetsOptions = internal.GetFileBlockOffsetsOptions{Name: fileNames[0]} openFileOptions = internal.OpenFileOptions{Name: fileNames[0], Flags: os.O_RDONLY, Mode: os.FileMode(0777)} - bol = &common.BlockOffsetList{ - BlockList: []*common.Block{{StartIndex: 0, EndIndex: 2 * MB}, {StartIndex: 2, EndIndex: 4 * MB}}, - } suite.mock.EXPECT().OpenFile(openFileOptions).Return(handle, nil) _, _ = suite.stream.OpenFile(openFileOptions) diff --git a/internal/pipeline_test.go b/internal/pipeline_test.go index b0cea47eb..efb0a8c08 100644 --- a/internal/pipeline_test.go +++ b/internal/pipeline_test.go @@ -26,6 +26,7 @@ package internal import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -104,7 +105,7 @@ func (s *pipelineTestSuite) TestStartStopCreateNewPipeline() { p, err := NewPipeline([]string{"ComponentA", "ComponentB"}, false) s.assert.NoError(err) - err = p.Start(nil) + err = p.Start(context.TODO()) s.assert.NoError(err) err = p.Stop() diff --git a/internal/stats_manager/stats_manager_linux.go b/internal/stats_manager/stats_manager_linux.go index c837bb6a9..38b8f2d01 100644 --- a/internal/stats_manager/stats_manager_linux.go +++ b/internal/stats_manager/stats_manager_linux.go @@ -48,7 +48,7 @@ func (sc *StatsCollector) statsDumper() { return } - f, err := os.OpenFile(common.TransferPipe, os.O_CREATE|os.O_WRONLY, 0777) + f, err := os.OpenFile(common.TransferPipe, os.O_WRONLY, 0) if err != nil { log.Err("stats_manager::statsDumper : unable to open pipe file [%v]", err) disableMonitoring() @@ -137,7 +137,7 @@ func statsPolling() { } // open polling pipe - pf, err := os.OpenFile(common.PollingPipe, os.O_RDONLY, os.ModeNamedPipe) + pf, err := os.Open(common.PollingPipe) if err != nil { fmt.Printf("stats_manager::statsPolling : unable to open pipe file [%v]", err) return @@ -157,7 +157,7 @@ func statsPolling() { } // open transfer pipe - tf, err := os.OpenFile(common.TransferPipe, os.O_CREATE|os.O_WRONLY, 0777) + tf, err := os.OpenFile(common.TransferPipe, os.O_WRONLY, 0) if err != nil { log.Err("stats_manager::statsPolling : unable to open pipe file [%v]", err) disableMonitoring() diff --git a/releaseVersionUpdate.py b/releaseVersionUpdate.py deleted file mode 100644 index b5fdddf78..000000000 --- a/releaseVersionUpdate.py +++ /dev/null @@ -1,36 +0,0 @@ -import json -import requests -import sys -from xml.dom import minidom - -sasUrl = sys.argv[1] -releaseVersion = sys.argv[2].split(' ')[2] -print('Release Version: ' + releaseVersion) -if(len(releaseVersion)==0): - print('Incorrect Release Version') - sys.exit(1) - -containerUrl = sasUrl.split('?')[0] -sasToken = sasUrl.split('?')[1] - -# list latest version file in the container -listUrl = sasUrl + '&restype=container&comp=list&prefix=latest/' -resp = requests.get(listUrl) -sys.exit(1) if(resp.status_code<200 or resp.status_code>202) else print('Listed latest version container') -listData = minidom.parseString(resp.content) -name = listData.getElementsByTagName('Name') -if(len(name)!=1): - print('Latest version container should have exactly one file. Number of files present is ' + str(len(name))) - sys.exit(1) -latestVersion = name[0].firstChild.data -print('Last release version: ' + latestVersion) - -# delete latest version file in the container -deleteUrl = containerUrl + '/' + latestVersion + '?' + sasToken -resp = requests.delete(deleteUrl) -sys.exit(1) if(resp.status_code<200 or resp.status_code>202) else print('Deleted last release file') - -# create release version file in the container -createUrl = containerUrl + '/latest/' + releaseVersion + '?' + sasToken -resp = requests.put(createUrl, headers={'x-ms-blob-type': 'BlockBlob'}) -sys.exit(1) if(resp.status_code<200 or resp.status_code>202) else print('Created new release version file') \ No newline at end of file diff --git a/test/benchmark_test/benchmark_test.go b/test/benchmark_test/benchmark_test.go index 15ca5973e..89ead5f22 100644 --- a/test/benchmark_test/benchmark_test.go +++ b/test/benchmark_test/benchmark_test.go @@ -60,7 +60,7 @@ func createSingleFile(size float32, path string) (float64, error) { if err != nil { return 0, err } - return float64(time.Now().Sub(start)), nil + return float64(time.Since(start)), nil } func (suite *benchmarkSuite) TestCreateSingleFiles() { diff --git a/test/e2e_tests/data_validation_test.go b/test/e2e_tests/data_validation_test.go index 172e23852..5cdd65b7f 100644 --- a/test/e2e_tests/data_validation_test.go +++ b/test/e2e_tests/data_validation_test.go @@ -182,13 +182,6 @@ func writeSparseData(suite *dataValidationTestSuite, fh *os.File, offsets []int6 } } -func min(x, y int) int { - if x < y { - return x - } - return y -} - // Creates the file with filePath and puts random data of size bytes func generateFileWithRandomData(suite *dataValidationTestSuite, filePath string, size int) { fh, err := os.Create(filePath) diff --git a/test/e2e_tests/dir_test.go b/test/e2e_tests/dir_test.go index 1cfd4423b..d07e64728 100644 --- a/test/e2e_tests/dir_test.go +++ b/test/e2e_tests/dir_test.go @@ -276,7 +276,7 @@ func (suite *dirTestSuite) TestDirGetStats() { stat, err := os.Stat(dirName) suite.NoError(err) - modTineDiff := time.Now().Sub(stat.ModTime()) + modTineDiff := time.Since(stat.ModTime()) // for directory block blob may still return timestamp as 0 // So compare the time only if epoch is non-zero diff --git a/test/e2e_tests/file_test.go b/test/e2e_tests/file_test.go index 81a1e8ce4..5b45dd14a 100644 --- a/test/e2e_tests/file_test.go +++ b/test/e2e_tests/file_test.go @@ -365,7 +365,7 @@ func (suite *fileTestSuite) TestFileGetStat() { stat, err := os.Stat(fileName) suite.NoError(err) - modTineDiff := time.Now().Sub(stat.ModTime()) + modTineDiff := time.Since(stat.ModTime()) suite.False(stat.IsDir()) suite.Equal("test", stat.Name()) @@ -494,7 +494,7 @@ func (suite *fileTestSuite) TestLinkWrite() { suite.NoError(err) stat, err := os.Stat(targetName) - modTineDiff := time.Now().Sub(stat.ModTime()) + modTineDiff := time.Since(stat.ModTime()) suite.NoError(err) suite.LessOrEqual(modTineDiff.Minutes(), float64(1)) suite.fileTestCleanup([]string{targetName}) diff --git a/tools/health-monitor/internal/stats_export.go b/tools/health-monitor/internal/stats_export.go index b033e437f..44327fa21 100644 --- a/tools/health-monitor/internal/stats_export.go +++ b/tools/health-monitor/internal/stats_export.go @@ -275,7 +275,7 @@ func (se *StatsExporter) getNewFile() error { _ = os.Rename(fname, fnameNew) fname = fmt.Sprintf("%v_%v.%v", baseName, hmcommon.Pid, hmcommon.OutputFileExtension) - se.opFile, err = os.OpenFile(fname, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) + se.opFile, err = os.OpenFile(fname, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { log.Err("stats_exporter::getNewFile : Unable to create output file [%v]", err) return err diff --git a/tools/health-monitor/monitor/cloudfuse_stats/stats_reader_linux.go b/tools/health-monitor/monitor/cloudfuse_stats/stats_reader_linux.go index 1b466c15e..e9a07bf02 100644 --- a/tools/health-monitor/monitor/cloudfuse_stats/stats_reader_linux.go +++ b/tools/health-monitor/monitor/cloudfuse_stats/stats_reader_linux.go @@ -45,7 +45,7 @@ func (cfs *CloudfuseStats) statsReader() error { return err } - f, err := os.OpenFile(cfs.transferPipe, os.O_RDONLY, os.ModeNamedPipe) + f, err := os.Open(cfs.transferPipe) if err != nil { log.Err("StatsReader::statsReader : unable to open pipe file [%v]", err) return err @@ -84,7 +84,7 @@ func (cfs *CloudfuseStats) statsPoll() { return } - pf, err := os.OpenFile(cfs.pollingPipe, os.O_CREATE|os.O_WRONLY, 0777) + pf, err := os.OpenFile(cfs.pollingPipe, os.O_CREATE|os.O_WRONLY, 0666) if err != nil { log.Err("StatsReader::statsPoll : unable to open pipe file [%v]", err) return From 925389110e4a0a056f62dd7a66d82f376817dcf5 Mon Sep 17 00:00:00 2001 From: James Fantin-Hardesty <24646452+jfantinhardesty@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:06:51 -0700 Subject: [PATCH 2/3] Remove more unused files --- .github/template/generate_page/action.yml | 63 ------------------- blobfuse2-data-validation.yaml | 74 ----------------------- 2 files changed, 137 deletions(-) delete mode 100644 .github/template/generate_page/action.yml delete mode 100644 blobfuse2-data-validation.yaml diff --git a/.github/template/generate_page/action.yml b/.github/template/generate_page/action.yml deleted file mode 100644 index df24959fb..000000000 --- a/.github/template/generate_page/action.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: generate_page -description: "Generate github page for performance benchmark" - -inputs: - TEST: - required: true - description: "Test to run" - TYPE: - required: true - description: "Type of storage account" - TOKEN: - required: true - description: "Token for checkin" - -runs: - using: "composite" - - steps: - # Pre-run cleanup - - name: "Cleanup before test" - shell: bash - run: | - rm -rf /mnt/blob_mnt/* - rm -rf /mnt/tempcache/* - - # Run the benchmark script - - name: "Run Benchmark Script : ${{ inputs.TEST }}" - shell: bash - run: | - ./perf_testing/scripts/fio_bench.sh /mnt/blob_mnt ${{ inputs.TEST }} - - # Push the bandwidth results and publish the graphs - - name: "Update Bandwidth Results : ${{ inputs.TEST }}" - uses: benchmark-action/github-action-benchmark@v1 - with: - output-file-path: ${{ inputs.TEST }}/bandwidth_results.json - tool: 'customBiggerIsBetter' - alert-threshold: "160%" - max-items-in-chart: 100 - github-token: ${{ inputs.TOKEN }} - fail-on-alert: true - auto-push: true - comment-on-alert: true - gh-pages-branch: benchmarks - benchmark-data-dir-path: ${{ inputs.TYPE }}/bandwidth/${{ inputs.TEST }} - - # Push the latency results and publish the graphs - - name: "Update Latency Results : ${{ inputs.TEST }}" - uses: benchmark-action/github-action-benchmark@v1 - with: - output-file-path: ${{ inputs.TEST }}/latency_results.json - tool: 'customSmallerIsBetter' - alert-threshold: "160%" - max-items-in-chart: 100 - github-token: ${{ inputs.TOKEN }} - fail-on-alert: true - auto-push: true - comment-on-alert: true - gh-pages-branch: benchmarks - benchmark-data-dir-path: ${{ inputs.TYPE }}/latency/${{ inputs.TEST }} - - - \ No newline at end of file diff --git a/blobfuse2-data-validation.yaml b/blobfuse2-data-validation.yaml deleted file mode 100644 index b9a803607..000000000 --- a/blobfuse2-data-validation.yaml +++ /dev/null @@ -1,74 +0,0 @@ -stages: - - stage: KernelBuild - jobs: - # Ubuntu Tests - - job: Set_1 - timeoutInMinutes: 360 - strategy: - matrix: - Ubuntu-22: - AgentName: 'blobfuse-benchmark-ubn22' - containerName: 'test-cnt-ubn-22' - pool: - name: "blobfuse-perf-pool" - demands: - - ImageOverride -equals $(AgentName) - - variables: - - group: NightlyBlobFuse - - name: ROOT_DIR - value: "/usr/pipeline/workv2" - - name: WORK_DIR - value: "/usr/pipeline/workv2/go/src/azure-storage-fuse" - - name: MOUNT_DIR - value: "/usr/pipeline/workv2/blob_mnt" - - name: TEMP_DIR - value: "/usr/pipeline/workv2/temp" - - name: BLOBFUSE2_CFG - value: "/usr/pipeline/workv2/blobfuse2.yaml" - - name: GOPATH - value: "/usr/pipeline/workv2/go" - - steps: - - template: 'azure-pipeline-templates/setup.yml' - parameters: - tags: $(tags) - installStep: - script: | - sudo apt-get update --fix-missing - sudo apt update - sudo apt-get install cmake gcc libfuse3-dev git parallel -y - sudo apt-get install fuse3 -y - displayName: 'Install fuse' - - - script: | - sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison -y - displayName: 'Install kernel build dependencies' - - - script: | - cd $(WORK_DIR) - $(WORK_DIR)/blobfuse2 gen-test-config --config-file=azure_block_perf.yaml --container-name=$(containerName) --output-file=$(BLOBFUSE2_CFG) - displayName: "Create Config File" - env: - NIGHTLY_STO_ACC_NAME: $(NIGHTLY_STO_BLOB_ACC_NAME) - NIGHTLY_STO_ACC_KEY: $(NIGHTLY_STO_BLOB_ACC_KEY) - ACCOUNT_TYPE: 'block' - ACCOUNT_ENDPOINT: 'https://$(NIGHTLY_STO_BLOB_ACC_NAME).blob.core.windows.net' - VERBOSE_LOG: ${{ parameters.verbose_log }} - continueOnError: false - - - script: | - cat $(BLOBFUSE2_CFG) - displayName: 'Print config file' - - - template: 'azure-pipeline-templates/blobfuse2-data-validation.yml' - parameters: - working_dir: $(WORK_DIR) - mount_dir: $(MOUNT_DIR) - temp_dir: $(TEMP_DIR) - prefix: 'ubn-22' - kversion: "6.10.2" - - - - \ No newline at end of file From 26ad31c31974207ea2933eb129a068581f390583 Mon Sep 17 00:00:00 2001 From: James Fantin-Hardesty <24646452+jfantinhardesty@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:22:44 -0700 Subject: [PATCH 3/3] Use context background when creating daemon --- cmd/mount.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/mount.go b/cmd/mount.go index 55bcedd30..43de78f32 100644 --- a/cmd/mount.go +++ b/cmd/mount.go @@ -526,8 +526,7 @@ var mountCmd = &cobra.Command{ pid := os.Getpid() fname := fmt.Sprintf("/tmp/cloudfuse.%v", pid) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := context.Background() err = createDaemon(pipeline, ctx, pidFileName, 0644, 022, fname) if err != nil { return fmt.Errorf("mount: failed to create daemon [%v]", err.Error())