Skip to content
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 OS info to lakectl UA #7759

Merged
merged 7 commits into from
May 20, 2024
Merged

Add OS info to lakectl UA #7759

merged 7 commits into from
May 20, 2024

Conversation

eladlachmi
Copy link
Contributor

Closes #7712

Change Description

Background

This PR adds basic OS information to the lakectl User-Agent string. In aggregate, this information can support decisions regarding the development of lakectl.

New Feature

The following properties are added to the UA string used by lakectl:

  • OS (e.g., Windows, Darwin, etc.)
  • Version
  • Platform (e.g., arm64, amd64, etc.)

Testing Details

Tested manually + unit test included in this PR.

@eladlachmi eladlachmi added area/lakectl Issues related to lakeFS' command line interface (lakectl) include-changelog PR description should be included in next release changelog labels May 13, 2024
@eladlachmi eladlachmi self-assigned this May 13, 2024
Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

13 passed

Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,
Added my comments.
Also suggest to verify with Not before merging

.gitallowed Outdated
@@ -6,3 +6,4 @@ AKIAJZZZZZZZZZZZZZZQ
AKIAIOSFDNN7EXAMPLEQ
wJalrXUtnFEMI/K3MDENG/bPxRfiCYEXAMPLEKEY
wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AKIAIOSFOLQUICKSTART
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this suddenly pop up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷🏻‍♂️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was due to your experiments with the test server. Try to remove it and see if you see the error again

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try removing it and see if it fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting... I removed it, and the commit wasn't blocked. I wonder if the next commit will be blocked, and maybe that's how this got committed in the first place 😅

client, err := apigen.NewClientWithResponses(
serverEndpoint,
apigen.WithHTTPClient(httpClient),
apigen.WithRequestEditorFn(basicAuthProvider.Intercept),
apigen.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error {
req.Header.Set("User-Agent", "lakectl/"+version.Version)
req.Header.Set("User-Agent", fmt.Sprintf("lakectl/%s/%s/%s/%s", version.Version, oss.OS, oss.Version, oss.Platform))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment here. Someone can naively change this and not understand the implications.
Generally, as we already discussed I'm not on favor of this approach 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏽

oss := OSInfo{
OS: "windows",
Version: ver,
Platform: "unknown",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also get the os architecture in windows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked around for a bit and didn't find a reliable way of doing this. If you know of one, please let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wmic cpu get DataWidth is not good enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is. In terms of 32/64bit, modern Windows won't even run on 32bit processors. The more interesting part is x86 vs. ARM, and that command won't give you that. Once windows on ARM becomes more of a thing, there will probably be a better way of doing this. Right now, I don't see much value in this information TBH.

@@ -462,12 +463,13 @@ func getClient() *apigen.ClientWithResponses {
DieErr(err)
}

oss, _ := osinfo.GetOSInfo()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we returning an error if we're not using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the error and added a default return value to all implementations

"time"
)

func GetOSInfo() (OSInfo, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all the OSInfo variations, you already know the OS type. Suggest to remove the error and always return some info

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Done.

@eladlachmi eladlachmi requested a review from N-o-Z May 15, 2024 12:17

func GetOSInfo() OSInfo {
out, err := getInfo()
for strings.Contains(out, brokenPipeOutput) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we switch the if statements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


func GetOSInfo() OSInfo {
out, err := getInfo()
for strings.Contains(out, brokenPipeOutput) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

out, err = getInfo()
time.Sleep(retryWaitTime)
}
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

out, err = getInfo()
time.Sleep(retryWaitTime)
}
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 🫣

Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replied

@eladlachmi eladlachmi requested a review from N-o-Z May 16, 2024 14:30
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, one comment left and we're good to go

Comment on lines 29 to 34
osInfo := strings.Split(osStr, " ")
oss := OSInfo{
OS: osInfo[0],
Version: osInfo[1],
Platform: osInfo[2],
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment for all code instances - this could easily panic and requires handling in case slice len != 3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@eladlachmi eladlachmi requested a review from N-o-Z May 20, 2024 09:42
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eladlachmi eladlachmi merged commit 1d6062b into master May 20, 2024
35 checks passed
@eladlachmi eladlachmi deleted the 7712-lakectl-os-stats branch May 20, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lakectl Issues related to lakeFS' command line interface (lakectl) include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lakectl version: send the OS version when checking up to date version
2 participants