Skip to content

Commit

Permalink
Make minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Saartank committed Dec 30, 2024
1 parent cad799c commit 553dfd7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
12 changes: 6 additions & 6 deletions director/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,10 +981,10 @@ func registerServeAd(engineCtx context.Context, ctx *gin.Context, sType server_s
}

// Check if the allowed prefixes for caches data from the registry
// have been initialized in the director
// has been initialized in the director
if sType == server_structs.CacheType {
// If the allowed prefix for caches data is not initialized,
// wait for it to be initialized within 3 seconds.
// wait for it to be initialized for 3 seconds.
if allowedPrefixesForCachesLastSetTimestamp.Load() == 0 {
log.Warning("Allowed prefixes for caches data is not initialized. Waiting for initialization before continuing with processing cache server advertisement.")
start := time.Now()
Expand All @@ -1004,7 +1004,7 @@ func registerServeAd(engineCtx context.Context, ctx *gin.Context, sType server_s
log.Error("Allowed prefixes for caches data is outdated, rejecting cache server ad.")
ctx.JSON(http.StatusInternalServerError, server_structs.SimpleApiResp{
Status: server_structs.RespFailed,
Msg: "Allowed prefixes for caches data is outdated",
Msg: "Something is wrong with the director or registry. Allowed prefixes for caches data is outdated.",
})
return
}
Expand All @@ -1029,8 +1029,8 @@ func registerServeAd(engineCtx context.Context, ctx *gin.Context, sType server_s
adV2 = server_structs.ConvertOriginAdV1ToV2(ad)
}

// Filter the advertised prefixes in the cache server advertisement
// based on the allowed prefix for caches data.
// Filter the advertised prefixes in the cache server ad
// based on the allowed prefixes for caches data.
if sType == server_structs.CacheType {
// Parse URL to extract hostname
parsedURL, err := url.Parse(adV2.DataURL)
Expand All @@ -1057,7 +1057,7 @@ func registerServeAd(engineCtx context.Context, ctx *gin.Context, sType server_s
// filter the advertised prefixes. If the cache hostname is not present,
// do nothing. This is the default behavior where all prefixes are allowed.
//
// `prefixes` is a set of prefixes that the given cache is allowed to serve.
// Variable `prefixes` is a set of prefixes that the given cache is allowed to serve.
if prefixes, exists := (*allowedPrefixesMap)[cacheHostname]; exists {
filteredNamespaces := []server_structs.NamespaceAdV2{}

Expand Down
4 changes: 2 additions & 2 deletions director/director_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,8 @@ func TestDirectorRegistration(t *testing.T) {
allowedPrefixesForCachesLastSetTimestamp.Store(time.Now().Unix())

ad := server_structs.OriginAdvertiseV2{
Name: "Human-readable name", // For web UI display
RegistryPrefix: "/caches/test", // For registry lookup
Name: "Human-readable name",
RegistryPrefix: "/caches/test",
DataURL: "https://data-url.org",
WebURL: "https://localhost:8844",
Namespaces: []server_structs.NamespaceAdV2{
Expand Down
6 changes: 5 additions & 1 deletion director/registry_periodic_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ func fetchAllowedPrefixesForCaches(ctx context.Context) (map[string]map[string]s
}

// LaunchRegistryPeriodicQuery starts a new goroutine that periodically refreshes
// the allowed prefixes for cache data maintained by the director in memory.
// the allowed prefixes for caches data maintained by the director in memory.
// It queries the registry at the interval specified by the config parameter
// Director.RegistryQueryInterval. If the data is stale (older than 15 minutes)
// or uninitialized, it queries the registry at a shorter interval of 1 second
// and switches back to the regular interval upon successful retrieval of the information.
func LaunchRegistryPeriodicQuery(ctx context.Context, egrp *errgroup.Group) {
refreshInterval := param.Director_RegistryQueryInterval.GetDuration()

Expand Down

0 comments on commit 553dfd7

Please sign in to comment.