Skip to content

Commit

Permalink
Merge pull request PelicanPlatform#1841 from jhiemstrawisc/issue-1840
Browse files Browse the repository at this point in the history
Move /pelican/monitoring into the "namespace" directory
  • Loading branch information
jhiemstrawisc authored Dec 18, 2024
2 parents bc3215e + d5a0e74 commit 8a3db42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cache/cache_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
func CheckCacheSentinelLocation() error {
if param.Cache_SentinelLocation.IsSet() {
sentinelPath := param.Cache_SentinelLocation.GetString()
dataLoc := param.Cache_StorageLocation.GetString()
dataLoc := param.Cache_NamespaceLocation.GetString()
sentinelPath = path.Clean(sentinelPath)
if path.Base(sentinelPath) != sentinelPath {
return errors.Errorf("invalid Cache.SentinelLocation path. File must not contain a directory. Got %s", sentinelPath)
Expand All @@ -51,17 +51,17 @@ func CheckCacheSentinelLocation() error {
return nil
}

// Periodically scan the ${Cache.StorageLocation}/pelican/monitoring directory to clean up test files
// Periodically scan the ${Cache.NamespaceLocation}/pelican/monitoring directory to clean up test files
// TODO: Director test files should be under /pelican/monitoring/directorTest and the file names
// should have director-test- as the prefix
func LaunchDirectorTestFileCleanup(ctx context.Context) {
server_utils.LaunchWatcherMaintenance(ctx,
[]string{filepath.Join(param.Cache_StorageLocation.GetString(), "pelican", "monitoring")},
[]string{filepath.Join(param.Cache_NamespaceLocation.GetString(), "pelican", "monitoring")},
"cache director-based health test clean up",
time.Minute,
func(notifyEvent bool) error {
// We run this function regardless of notifyEvent to do the cleanup
dirPath := filepath.Join(param.Cache_StorageLocation.GetString(), "pelican", "monitoring")
dirPath := filepath.Join(param.Cache_NamespaceLocation.GetString(), "pelican", "monitoring")
dirInfo, err := os.Stat(dirPath)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cache/cache_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestCheckCacheSentinelLocation(t *testing.T) {
tmpDir := t.TempDir()
server_utils.ResetTestState()
viper.Set(param.Cache_SentinelLocation.GetName(), "test.txt")
viper.Set(param.Cache_StorageLocation.GetName(), tmpDir)
viper.Set(param.Cache_NamespaceLocation.GetName(), tmpDir)
err := CheckCacheSentinelLocation()
require.Error(t, err)
assert.Contains(t, err.Error(), "failed to open Cache.SentinelLocation")
Expand All @@ -61,7 +61,7 @@ func TestCheckCacheSentinelLocation(t *testing.T) {
server_utils.ResetTestState()

viper.Set(param.Cache_SentinelLocation.GetName(), "test.txt")
viper.Set(param.Cache_StorageLocation.GetName(), tmpDir)
viper.Set(param.Cache_NamespaceLocation.GetName(), tmpDir)

file, err := os.Create(filepath.Join(tmpDir, "test.txt"))
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions cache/self_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func InitSelfTestDir() error {
return err
}

basePath := param.Cache_StorageLocation.GetString()
basePath := param.Cache_NamespaceLocation.GetString()
pelicanMonPath := filepath.Join(basePath, "/pelican")
monitoringPath := filepath.Join(pelicanMonPath, "/monitoring")
selfTestPath := filepath.Join(monitoringPath, "/selfTest")
Expand All @@ -80,9 +80,9 @@ func InitSelfTestDir() error {
}

func generateTestFile() (string, error) {
basePath := param.Cache_StorageLocation.GetString()
basePath := param.Cache_NamespaceLocation.GetString()
if basePath == "" {
return "", errors.New("failed to generate self-test file for cache: Cache.StorageLocation is not set.")
return "", errors.New("failed to generate self-test file for cache: Cache.NamespaceLocation is not set.")
}
selfTestPath := filepath.Join(basePath, selfTestDir)
_, err := os.Stat(selfTestPath)
Expand Down Expand Up @@ -225,7 +225,7 @@ func downloadTestFile(ctx context.Context, fileUrl string) error {
}

func deleteTestFile(fileUrlStr string) error {
basePath := param.Cache_StorageLocation.GetString()
basePath := param.Cache_NamespaceLocation.GetString()
fileUrl, err := url.Parse(fileUrlStr)
if err != nil {
return errors.Wrap(err, "invalid file url to remove the test file")
Expand Down

0 comments on commit 8a3db42

Please sign in to comment.