-
Notifications
You must be signed in to change notification settings - Fork 355
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
Add lakefs instrumentation #6217
Conversation
🎊 PR Preview 0268f29 has been successfully built and deployed to https://treeverse-lakeFS-preview-pr-6217.surge.sh 🕐 Build time: 0.018s 🤖 By surge-preview |
pkg/auth/metadata.go
Outdated
_, k8s := os.LookupEnv("KUBERNETES_SERVICE_HOST") | ||
lakefsAccessKeyID := os.Getenv("LAKEFS_ACCESS_KEY_ID") | ||
quickstart, _ := strconv.ParseBool(os.Getenv("QUICKSTART")) | ||
_, statErr := StatFunc("/.dockerenv") |
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.
- separate keys for docker / k8s / sample|quickstart
- stats - global string point to dockerenv filename instead of override stat func
treeverse/lakefs:latest | ||
|
||
- name: Build and push lakefs quickstart |
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.
if we will get to the point where we will need to version quickstart images I prefer to keep it simple and think of alternative way to identify quickstart usage - arg? or just env var and not new image.
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'm not in favour of a new Docker image for quickstart, sorry. This is for two reasons:
- Quickstart should ideally be a "runway" for users to get up and running (and take off, to continue the analogy)—using a dedicated image is like a dead-end road. There are exceptions to this rule but they need to be a good one, not just to make it easier to instrument
- If we use a dedicated image we need to explain to the user why, and that explanation is too thin to hold weight IMHO
Appreciate the feedback, please suggest an alternative for identifying execution as part of the quickstart guide |
pkg/auth/metadata.go
Outdated
@@ -206,13 +212,43 @@ func (m *KVMetadataManager) IsInitialized(ctx context.Context) (bool, error) { | |||
return !setupTimestamp.IsZero(), nil | |||
} | |||
|
|||
// DockerFileExists For testing purposes | |||
var DockerFileExists = "/.dockerenv" |
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.
DockeEnvExists
pkg/auth/metadata.go
Outdated
func (m *KVMetadataManager) GetMetadata(ctx context.Context) (map[string]string, error) { | ||
metadata := make(map[string]string) | ||
metadata["lakefs_version"] = m.version | ||
metadata["lakefs_kv_type"] = m.kvType | ||
metadata["golang_version"] = runtime.Version() | ||
metadata["architecture"] = runtime.GOARCH | ||
metadata["os"] = runtime.GOOS | ||
getInstrumentation(metadata) |
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.
Suggest to split into functions
getInstrumentation(metadata) | |
metadata["is_k8s"] = inK8sMetadata() | |
metadata["is_docker"] = inDockerMetadata() | |
metadata["instrumentation"] = instrumentationMetadata() |
func isK8sMetadata() string {
_, k8s := os.LookupEnv("KUBERNETES_SERVICE_HOST")
return strconv.FormatBool(k8s)
}
func isDockerMetadata() string {
var err error
if DockerFileExists != "" {
_, err = os.Stat(DockerFileExists)
}
return strconv.FormatBool(err == nil)
}
func instrumentationMetadata() string {
lakefsAccessKeyID := os.Getenv("LAKEFS_ACCESS_KEY_ID")
if strings.HasSuffix(lakefsAccessKeyID, "LKFSSAMPLES") {
return InstrumentationSamplesRepo
}
quickstart, _ := strconv.ParseBool(os.Getenv("QUICKSTART"))
if quickstart {
return InstrumentationQuickstart
}
return InstrumentationRun
}
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.
Thanks! looks good - if there is an alternative for the docker image I'm +1
@nopcoder Please re-review quickstart refactor |
pkg/auth/metadata.go
Outdated
switch { | ||
case strings.HasSuffix(lakefsAccessKeyID, "LKFSSAMPLES"): | ||
return InstrumentationSamplesRepo | ||
} | ||
quickstart, _ := strconv.ParseBool(os.Getenv("QUICKSTART")) | ||
if quickstart { | ||
case strings.HasSuffix(lakefsAccessKeyID, "QUICKSTART"): | ||
return InstrumentationQuickstart | ||
default: | ||
return InstrumentationRun | ||
} | ||
return InstrumentationRun | ||
} |
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.
nice
cmd/lakefs/cmd/root.go
Outdated
os.Exit(1) | ||
} | ||
accessKey := "AKIAIOSFOLQUICKSTART" | ||
secretKey := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" |
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.
will need to lint ignore - gosec
cmd/lakefs/cmd/root.go
Outdated
accessKey := "AKIAIOSFOLQUICKSTART" | ||
secretKey := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" |
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.
accessKey := "AKIAIOSFOLQUICKSTART" | |
secretKey := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" | |
const ( | |
accessKey = "AKIAIOSFOLQUICKSTART" | |
secretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" | |
) |
cmd/lakefs/cmd/root.go
Outdated
fmt.Printf("Access Key ID : %s \n", accessKey) | ||
fmt.Printf("Secret Access Key: %s \n", secretKey) |
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.
fmt.Printf("Access Key ID : %s \n", accessKey) | |
fmt.Printf("Secret Access Key: %s \n", secretKey) | |
fmt.Printf("Access Key ID : %s\n", accessKey) | |
fmt.Printf("Secret Access Key: %s\n", secretKey) |
cmd/lakefs/cmd/root.go
Outdated
if useLocal() { | ||
return config.NewLocalConfig() | ||
} | ||
quickStart := useConfig(config.QuickStartConfiguration) |
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.
Do we need to verify that not both are on?
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.
Not sure we wan't to enforce mutual exclusion - do you see an issue with it?
} | ||
|
||
func useLocal() bool { | ||
res, err := rootCmd.PersistentFlags().GetBool(config.UseLocalConfiguration) | ||
func validateQuickstartEnv(cfg *config.Config) { |
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.
The name is a bit misleading as we verify the database and blockstore - but we override the configuration and not set them as default.
If we like to verify that the default as not override we should do the same as local - setup the right defaults for quick-start and verify after the configuration is loaded that the user didn't override the default for all the values we require.
cmd/lakefs/cmd/root.go
Outdated
fmt.Printf("Secret Access Key: %s\n", config.DefaultQuickstartSecretKey) | ||
} | ||
|
||
func useConfig(cfg string) bool { |
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.
func useConfig(cfg string) bool { | |
func useConfig(flagName string) bool { |
cmd/lakefs/cmd/root.go
Outdated
if useLocal() { | ||
return config.NewLocalConfig() | ||
} | ||
quickStart := useConfig(config.QuickstartConfiguration) |
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.
Suggest, if it is more clear and less references of calling NewConfig
name := ""
configurations := []string{config.QuickstartConfiguration, config.UseLocalConfiguration}
if idx := slices.IndexFunc(configurations, func(f string) bool { return useConfig(f); }); idx != -1 {
name = configurations[idx]
}
cfg, err := config.NewConfig(name)
if err != nil {
return nil, err
}
if name == config.QuickstartConfiguration {
validateQuickstartEnv(cfg)
}
return cfg, nil
pkg/config/defaults.go
Outdated
func setDefaults(local bool) { | ||
if local { | ||
func setDefaults(cfgType string) { | ||
switch { |
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.
switch { | |
switch cfgType { |
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.
LGTM!
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.
Firstly: I think this is a positive change and a good direction 👍🏻
However 😬 I have some nits, as well as a blocker.
🛑 Potential blocker: This change will remove quickstart email capture
From a DevEx point of view I am 💯 💯 💯 💯 💯 in favour of this, but last time I did it it caused ructions elsewhere ;)
We need to make it clear to all stakeholders (@iddoavn, @einato , @ozkatz et al) the impact and get agreement from them.
The solution here is to implement #6033 / #6204 first.
Nits
Pre-create the quickstart repo
Since we know they're running the quickstart, we should pre-create the quickstart
sample repo
Sample repo instructions
These need updating for the new --quickstart
flag
Startup Banner
The startup banner should reflect the startup mode; if the user is using --quickstart
then echo the pre-baked creds to stdout and not direct them to complete the setup process at http://127.0.0.1:8000/setup
You already have this change but only in the docs, whereas it should be conditional and in the lakeFS output itself
i.e. instead the current startup banner:
██╗ █████╗ ██╗ ██╗███████╗███████╗███████╗
██║ ██╔══██╗██║ ██╔╝██╔════╝██╔════╝██╔════╝
██║ ███████║█████╔╝ █████╗ █████╗ ███████╗
██║ ██╔══██║██╔═██╗ ██╔══╝ ██╔══╝ ╚════██║
███████╗██║ ██║██║ ██╗███████╗██║ ███████║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝
│
│ If you're running lakeFS locally for the first time,
│ complete the setup process at http://127.0.0.1:8000/setup
│
│
│ For more information on how to use lakeFS,
│ check out the docs at https://docs.lakefs.io/quickstart/
│
│
│ For support or any other question, >(._.)<
│ join our Slack channel https://docs.lakefs.io/slack ( )_
│
Should be this for quickstart:
██╗ █████╗ ██╗ ██╗███████╗███████╗███████╗
██║ ██╔══██╗██║ ██╔╝██╔════╝██╔════╝██╔════╝
██║ ███████║█████╔╝ █████╗ █████╗ ███████╗
██║ ██╔══██║██╔═██╗ ██╔══╝ ██╔══╝ ╚════██║
███████╗██║ ██║██║ ██╗███████╗██║ ███████║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝
│
│ You are running lakeFS in quickstart mode.
| Login at http://127.0.0.1:8000/
│
| Access Key ID : AKIAIOSFOLQUICKSTART
│ Secret Access Key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
│
│
│ For more information on how to use lakeFS,
│ check out the docs at https://docs.lakefs.io/quickstart/
│
│
│ For support or any other question, >(._.)<
│ join our Slack channel https://docs.lakefs.io/slack ( )_
│
I realise that the creds are echoed earlier on as part of the bootup but from a DX point of view it's not obvious particularly when there is a user-facing dialog later on in the stdout
Thanks, Regarding the blocker: Nits: Startup Banner |
I'd like both the nits addressed as part of this PR please. If we're implementing a |
@rmoff Added the banner changes - but I have to insist on the sample repo creation. This PR should focus on the issue at hand which is providing a way to understand where lakefs is run from. |
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.
cmd/lakefs/cmd/run.go
Outdated
} | ||
templ := template.New("banner") | ||
var buf bytes.Buffer | ||
t := template.Must(templ.Parse(runBannerTmpl)) |
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.
you can define var outside and use template must api to render it once
cmd/lakefs/cmd/run.go
Outdated
} | ||
if isQuickstart { | ||
data.LocalSetup = "" | ||
data.Quickstart = quickStartBanner |
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.
This should be done inside the template base on the args we provide.
provide the params we require to render the template - it can include the admin key/secret, the mode and the lakefs version.
cmd/lakefs/cmd/run.go
Outdated
_, _ = fmt.Fprintf(os.Stderr, "Failed formatting banner: %v\n", err) | ||
os.Exit(1) | ||
} | ||
_, _ = fmt.Fprintf(os.Stderr, "lakeFS %s - Up and running (^C to shutdown)...\n", version.Version) |
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.
nice - I think it can be also move inside the template
…trumentation-6216 # Conflicts: # docs/quickstart/launch.md
…trumentation-6216
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.
looked at the CR Fixes
LGTM
On vacation - Guy covered requested changes
Linked Issue
Closes #6216