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

client: flink commands ignore the current project #391

Merged

Conversation

jclarysse
Copy link
Contributor

@jclarysse jclarysse commented Nov 13, 2024

Customers are used to set environment so they don't have to pass all arguments for each aiven-client command they run. This PR takes the current project into account in flink commands.

PM-4549

Customers are used to set environment so they don't have to pass
all arguments for each aiven-client command they run.
This PR takes the current project into account in flink commands.

[PM-4549]
@jclarysse jclarysse requested review from a team as code owners November 13, 2024 11:38
@jclarysse jclarysse requested a review from ilpon November 13, 2024 11:38
@jclarysse
Copy link
Contributor Author

Set current project

$ avn project switch dev-sandbox                                 
INFO	Set project 'dev-sandbox' as the default project

Before

$ avn service flink list-applications julien-flink-75b445f       
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/__main__.py", line 10, in <module>
    main()
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/__main__.py", line 6, in main
    AivenCLI().main()
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/argx.py", line 409, in main
    sys.exit(self.run(args))
             ^^^^^^^^^^^^^^
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/argx.py", line 381, in run
    return self.run_actual(args)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/argx.py", line 403, in run_actual
    return func()
           ^^^^^^
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/cli.py", line 5322, in service__flink__list_applications
    self.client.flink_list_applications(
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/client.py", line 2259, in flink_list_applications
    self.build_path(
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/client.py", line 246, in build_path
    return "/" + "/".join(quote(part, safe="") for part in parts)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aiven/client/client.py", line 246, in <genexpr>
    return "/" + "/".join(quote(part, safe="") for part in parts)
                          ^^^^^^^^^^^^^^^^^^^^
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/urllib/parse.py", line 893, in quote
    return quote_from_bytes(string, safe)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julien.clarysse/.pyenv/versions/3.11.4/lib/python3.11/urllib/parse.py", line 923, in quote_from_bytes
    raise TypeError("quote_from_bytes() expected bytes")
TypeError: quote_from_bytes() expected bytes

After

$ avn service flink list-applications julien-flink-75b445f 
{
    "applications": [
        {
            "created_at": "2023-08-31T11:32:59.549205Z",
            "created_by": "[email protected]",
            "id": "698f469a-9e42-406d-840a-ec152b8fac6f",
            "name": "pizza-orders-to-avro",
            "updated_at": "2023-08-31T11:32:59.549205Z",
            "updated_by": "[email protected]"
        },
        ...
]

@jclarysse jclarysse requested a review from a team November 13, 2024 11:42
Copy link
Contributor

@dogukancagatay dogukancagatay left a comment

Choose a reason for hiding this comment

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

With the current changes, it looks fine, and we can merge it.

However, I realized that the method get_project doesn't consider the AIVEN_PROJECT environment variable when inferring the project name where the default value of args.project was the environment variable.

IMO, we should fix the get_project to reflect the correct hierarchy of inference which should be argument -> environment -> config.

Additionally, we should fix the args.project default to behave similarly so as not to mislead developers in the future.

@jclarysse
Copy link
Contributor Author

jclarysse commented Nov 13, 2024

we should fix the get_project to reflect the correct hierarchy of inference which should be argument -> environment -> config.
we should fix the args.project default to behave similarly so as not to mislead developers in the future.

@dogukancagatay Do we agree that this should be a separate ticket? Thanks

@dogukancagatay dogukancagatay merged commit 8185de7 into main Nov 14, 2024
26 checks passed
@dogukancagatay dogukancagatay deleted the jclarysse/flink-commands-ignore-current-project branch November 14, 2024 15:52
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.

3 participants