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

User agent v2 #8664

Merged
merged 1 commit into from May 14, 2024
Merged

User agent v2 #8664

merged 1 commit into from May 14, 2024

Conversation

kdaily
Copy link
Member

@kdaily kdaily commented May 2, 2024

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kdaily kdaily requested review from kyleknap and hssyoo May 2, 2024 17:26
@kdaily kdaily force-pushed the kdaily-useragent-v2 branch 6 times, most recently from 3acb404 to 0a854e2 Compare May 2, 2024 21:25
@kdaily kdaily removed request for kyleknap and hssyoo May 2, 2024 21:25
@kdaily kdaily force-pushed the kdaily-useragent-v2 branch 5 times, most recently from 59d60cc to f5fa323 Compare May 2, 2024 21:58
tests/unit/test_clidriver.py Outdated Show resolved Hide resolved
@kdaily kdaily marked this pull request as ready for review May 7, 2024 16:33
@kdaily kdaily requested a review from kyleknap May 7, 2024 16:33
awscli/utils.py Show resolved Hide resolved
@kdaily kdaily force-pushed the kdaily-useragent-v2 branch 2 times, most recently from f26fca0 to 1ade664 Compare May 7, 2024 21:17
Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

The implementation looks good. I only had some minor feedback. I plan on taking another pass later to go over the tests, but it's looking good so far.

awscli/botocore/args.py Outdated Show resolved Hide resolved
awscli/botocore/__init__.py Outdated Show resolved Hide resolved
awscli/botocore/compat.py Outdated Show resolved Hide resolved
awscli/botocore/__init__.py Outdated Show resolved Hide resolved
awscli/utils.py Outdated
def add_command_lineage_to_user_agent_extra(session, lineage):
# Find existing command metadata and append the last item in the lineage to
# it
if comp := _LINEAGE_COMMAND_METADATA_REGEX.search(session.user_agent_extra):
Copy link
Member

Choose a reason for hiding this comment

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

Looking at this now, I plan take a deeper look into this to see if we actually need this logic. This is definitely a bit messy and it would be nice if we could avoid it all together.

Copy link
Member

Choose a reason for hiding this comment

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

Circling back on this... So I think this pull request made the chance of the session having the command component less significant: #7399. Specifically, the log will eagerly delegate to the subcommand's __call__ instead of updating the user agent.

That being said there are instances such as s3 rb --force where a command is called directly:

def _force(self, path, parsed_globals):
but that ends up in unexpected updates to the command component (e.g. md/command#s3.rb.rm on the DeleteObject calls).

I think with this knowledge, we can probably just update it to check if md/command is defined and only add the command if it is not in the user agent. That should help simplify this logic.

Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good. Just had a few more comments on the tests.

tests/functional/test_useragent.py Show resolved Hide resolved
tests/functional/test_useragent.py Outdated Show resolved Hide resolved
tests/integration/test_cli.py Outdated Show resolved Hide resolved
Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good! 🚢

Port user agent 2.0 from botocore.

Update existing CLI v2 user agent formatting.

Moves the source installer and arch to separate
metadata:

Before: `exe/x86_64`
After: `md/installer#exe md/arch#x86_64`

Moves the linux distro to separate metadata.
Before the linux distro was appended to the
source/arch metadata, like

`src/x86_64.Ubuntu.18`.

Now, since installer and arch are separate,
moves distro to `md/distrib#Ubuntu.18`.

Updates command lineage from `command/cmd.subcmd`
to `md/command#cmd.subcmd`.

Updates prompt modefrom `prompt/on`
to `md/prompty#on`.

Change format for ecs customization user agent
from `customization/ecs-deploy` to
`md/customization#ecs-deploy`. This is retained
because CLI v1 does not include the command
lineage.

Adds helper methods for setting the user agent
to make it easier to alter them in the future.

Changes the behavior when adding the command
lineage metadata to not assume that it comes at
the end of the string. Also it removes the case
that if a command lineage is already present to
add the last element of the lineage. This is no
longer necessary because sub-command parsing
always occurs before injecting the user agent
string.
@kdaily kdaily merged commit 6d8e277 into aws:v2 May 14, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants