-
Notifications
You must be signed in to change notification settings - Fork 399
chore(modulestore): add public coredump modulestore API #543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
korniltsev
wants to merge
1
commit into
open-telemetry:main
from
grafana:korniltsev/modulestore_public_api
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package coredumpstore // import "go.opentelemetry.io/ebpf-profiler/tools/coredump/coredumpstore" | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| "github.com/aws/aws-sdk-go-v2/aws" | ||
| "github.com/aws/aws-sdk-go-v2/config" | ||
| "github.com/aws/aws-sdk-go-v2/service/s3" | ||
| "go.opentelemetry.io/ebpf-profiler/tools/coredump/modulestore" | ||
| ) | ||
|
|
||
| // moduleStoreRegion defines the S3 bucket OCI region. | ||
| const moduleStoreRegion = "us-sanjose-1" | ||
|
|
||
| // moduleStoreObjectNamespace defines the S3 bucket OCI object name space. | ||
| const moduleStoreObjectNamespace = "axtwf1hkrwcy" | ||
|
|
||
| // modulePublicReadUrl defines the S3 bucket OCI public read only base path. | ||
| // | ||
| //nolint:lll | ||
| const modulePublicReadURL = "sm-wftyyzHJkBghWeexmK1o5ArimNwZC-5eBej5Lx4e46sLVHtO_y7Zf7FZgoIu_/n/axtwf1hkrwcy" | ||
|
|
||
| // moduleStoreS3Bucket defines the S3 bucket used for the module store. | ||
| const moduleStoreS3Bucket = "ebpf-profiling-coredumps" | ||
|
|
||
| const localCachePath = "tools/coredump/modulecache" | ||
|
|
||
| // New creates a new modulestore.Store pointing to the public s3 used for coredump tests | ||
| func New() (*modulestore.Store, error) { | ||
| gitRoot, err := findGitRoot() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| localCachePath := filepath.Join(gitRoot, localCachePath) | ||
| publicReadURL := fmt.Sprintf("https://%s.objectstorage.%s.oci.customer-oci.com/p/%s/b/%s/o/", | ||
| moduleStoreObjectNamespace, moduleStoreRegion, modulePublicReadURL, moduleStoreS3Bucket) | ||
|
|
||
| cfg, err := config.LoadDefaultConfig(context.Background()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| s3Client := s3.NewFromConfig(cfg, func(o *s3.Options) { | ||
| baseEndpoint := fmt.Sprintf("https://%s.compat.objectstorage.%s.oraclecloud.com/", | ||
| moduleStoreObjectNamespace, moduleStoreRegion) | ||
| o.Region = moduleStoreRegion | ||
| o.BaseEndpoint = aws.String(baseEndpoint) | ||
| o.UsePathStyle = true | ||
| }) | ||
| return modulestore.New(s3Client, publicReadURL, moduleStoreS3Bucket, localCachePath) | ||
| } | ||
|
|
||
| func findGitRoot() (string, error) { | ||
| it, err := os.Getwd() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| for len(it) > 1 { | ||
| _, err = os.Stat(filepath.Join(it, ".git")) | ||
| if err == nil { | ||
| return it, nil | ||
| } | ||
| it = filepath.Dir(it) | ||
| } | ||
| return "", errors.New("git not found") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate a bit more, what you prevents from constructing your own
modulestore.New()wrapper, so it can be used also in different places?Would it be sufficient for you to move the constants, like
moduleStoreRegionand others, to packagemodulestoreand make them public?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite get the question. This PR does exactly that.
It would work. I still want a convenient wrapper, not just constants. I don't want to bother with aws config and s3 clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also want to have a shared cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the request to use the coredump package, and its subpackages, in other places I would have expected some interface, that can be used and replaced in other situations.
That is why I did ask if the alternative with exposing the constants would be an option.
Personally, I don't have a good feeling around the
findGitRoot()function. And so I'm looking for alternatives.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just in case: I've added
findGitRootso that I don't have to specify the correct number of../../../../../for each different package that is going to use the new helper.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to understand you.
I propose to do this
and you propose to do this
Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what this PR is trying to change.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being short in #543 (comment) and not expanding more on the idea.
With #558 I have quickly implemented the idea that I proposed in #543 (comment).
With this, your tests should look like this:
Is this something you could work with?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your draft is almost the same as mine, why can't we make
cloudstore.Client()just return themodulestore.Store?It technically work. It is less convenient. It is verbose and repetitive I still have to copypaste these details
loudClient, cloudstore.PublicReadURL(), cloudstore.ModulestoreS3Bucket(),which I don't really care about ( I just need to pull a blob, I dont want to know about s3 clients and urls). It is fine to have them available as publi API for those who need them and needs to swap them. I just don't need them and propose something slightly more convenient.It is ugly and inconvenitent to calculate the correct number of
../../../localCachePathin each test.Would that work for you if I add
cloudstore.Client(),cloudstore.ModulestoreS3Bucket(),cloudstore.PublicReadURL()and then never use but still keep thecloudstore.New()with zero parameters?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When thinking about APIs and packages, I try to separate them by their functionality.
To me, the most significant difference between #543 and #558 is, that #543 mixes functionality, while #558 separates them. Additionally, #558 also allows people to have their dedicated cloud module storage.
I agree with that. But I think, you can use and reuse your
findGitRoot()from #543 to improve that.As pointed out, before, I think, packages and API should have their clear boundary and should be separated by functionality.