Skip to content

Commit

Permalink
Merge pull request nephio-project#148 from Nordix/cache-close-trace
Browse files Browse the repository at this point in the history
Add tracing to cache close function
  • Loading branch information
nephio-prow[bot] authored Dec 3, 2024
2 parents 90b2326 + 573af7c commit de90105
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

type Cache interface {
OpenRepository(ctx context.Context, repositorySpec *configapi.Repository) (repository.Repository, error)
CloseRepository(repositorySpec *configapi.Repository, allRepos []configapi.Repository) error
CloseRepository(ctx context.Context, repositorySpec *configapi.Repository, allRepos []configapi.Repository) error
}
5 changes: 4 additions & 1 deletion pkg/cache/memory/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ func (c *Cache) OpenRepository(ctx context.Context, repositorySpec *configapi.Re
}
}

func (c *Cache) CloseRepository(repositorySpec *configapi.Repository, allRepos []configapi.Repository) error {
func (c *Cache) CloseRepository(ctx context.Context, repositorySpec *configapi.Repository, allRepos []configapi.Repository) error {
_, span := tracer.Start(ctx, "Cache::OpenRepository", trace.WithAttributes())
defer span.End()

key, err := getCacheKey(repositorySpec)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/memory/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func openRepositoryFromArchive(t *testing.T, ctx context.Context, testPath, name
}

t.Cleanup(func() {
err := cache.CloseRepository(apiRepo, []v1alpha1.Repository{*apiRepo})
err := cache.CloseRepository(ctx, apiRepo, []v1alpha1.Repository{*apiRepo})
if err != nil {
t.Errorf("CloseRepository(%q) failed: %v", address, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/porch/background.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (b *background) updateCache(ctx context.Context, event watch.EventType, rep
if err := b.coreClient.List(ctx, &repoList); err != nil {
return err
}
return b.cache.CloseRepository(repository, repoList.Items)
return b.cache.CloseRepository(ctx, repository, repoList.Items)
default:
klog.Warningf("Unhandled watch event type: %s", event)
}
Expand Down

0 comments on commit de90105

Please sign in to comment.