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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悪 octavia-cli: implement apply #10703

Merged
merged 6 commits into from
Mar 5, 2022

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Feb 28, 2022

What is octavia apply

The octavia apply command creates and updates Airbyte remote resources according to the local YAML configuration of these resources.

By default, running octavia apply will:

  • Find all the available YAML configurations in your local project directory
  • Deserialize the YAML into a BaseResource object
  • Try to find if a remote resource exists on the targetted Airbyte instance matching the local one:
    • If the remote resource does not exist:
      1. Create the resource on the Airbyte instance.
      2. Save a local state.yaml file with the resource id, the checksum of the latest configuration applied, and the generation timestamp/
    • If the resource exists:
      1. Display a diff to the user between local and remote resources configuration, ask the user to validate
      2. Prompt user for validation of the diff
      3. Update the remote resource
      4. Save a local state.yaml file

Optional behavior:

  • --force flag to not prompt the user with a diff validation and always run create or update.
  • --file option to target specific configuration files (can be used multiple times-.

Demo

Screen Shot 2022-03-02 at 16 22 21

Screen Shot 2022-03-02 at 15 58 00

Screen Shot 2022-03-02 at 16 02 06

Previous actions made:

  • octavia init
  • octavia generate octavia generate source decd338e-5647-4c0b-adf4-da0e75f5a750 my_db
  • Edited ./sources/my_db/configuration.yaml

Recommended reading order

  1. octavia-cli/octavia_cli/apply/commands.py: Declares the logic of what happens when running an apply command.
  2. octavia-cli/octavia_cli/apply/resources.py: Declares the resource objects, their interface, and how they interact with the backend + factory to create these resource objects. This PR implemented sources and destinations resources.
  3. octavia-cli/octavia_cli/entrypoint.py: add the command to the entrypoint
  4. octavia-cli/octavia_cli/apply/diff_helpers.py: Some helpers for diff computation with DeepDiff + checksum.
  5. octavia-cli/tests/unit/test_apply/*: All code addition was unit tested, we maintain a 100% test coverage.

Refacto made

What's missing

  • Apply for connection resources (waiting for octavia generate connection to be ready)
  • Check connection after resource creation or update (use check_connection_to_* and check_connection_to_*_for_update endpoints)

馃毃 User Impact 馃毃

@alafanechere alafanechere temporarily deployed to more-secrets February 28, 2022 14:43 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets February 28, 2022 14:43 Inactive
@alafanechere alafanechere force-pushed the augustin/octavia-cli/implement-apply branch from ef9ef88 to 22c80b7 Compare February 28, 2022 14:43
@alafanechere alafanechere temporarily deployed to more-secrets February 28, 2022 14:44 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets February 28, 2022 14:44 Inactive
@alafanechere alafanechere added this to the octavia-cli-alpha milestone Feb 28, 2022
@alafanechere alafanechere temporarily deployed to more-secrets February 28, 2022 22:52 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets February 28, 2022 22:52 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets February 28, 2022 23:06 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets February 28, 2022 23:06 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 1, 2022 12:25 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 1, 2022 12:25 Inactive
@alafanechere alafanechere force-pushed the augustin/octavia-cli/implement-apply branch from d248711 to 2b3e149 Compare March 2, 2022 14:23
@alafanechere alafanechere temporarily deployed to more-secrets March 2, 2022 14:24 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 2, 2022 14:24 Inactive
@alafanechere alafanechere marked this pull request as ready for review March 2, 2022 15:18
@alafanechere alafanechere temporarily deployed to more-secrets March 2, 2022 15:23 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 2, 2022 15:23 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 2, 2022 21:28 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 2, 2022 21:28 Inactive
Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Had a few small comments but nothing major. Nice work on this! I think it looks great

octavia-cli/octavia_cli/apply/commands.py Outdated Show resolved Hide resolved
octavia-cli/octavia_cli/apply/resources.py Outdated Show resolved Hide resolved
octavia-cli/octavia_cli/apply/resources.py Outdated Show resolved Hide resolved
diff = compute_diff(remote_config, current_config)
return diff.pretty()

def _create_or_update(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will all work as expected if the remote Airbyte instance does not have any sources/destinations already that the user wants to interact with with this CLI.

However, what about the case where someone wants to use this CLI to manage sources/destinations that already exist in their Airbyte instance? Is there some way for them to export their existing sources/destinations to create these resources, so that they don't need to recreate them with this CLI? Maybe that functionality is coming in a later PR?

Another way I could see a user getting into this case is if they delete all of the octavia-cli resource files - they should have some way to regenerate them from their Airbyte instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're 馃挴 right! This functionality will come with the octavia import feature. It's only possible to update resources created with the CLI at the moment.

octavia-cli/octavia_cli/apply/commands.py Outdated Show resolved Hide resolved
octavia-cli/tests/unit/test_apply/test_diff_helpers.py Outdated Show resolved Hide resolved
@alafanechere alafanechere temporarily deployed to more-secrets March 5, 2022 18:12 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 5, 2022 18:12 Inactive
@alafanechere
Copy link
Contributor Author

Thank you for the review @lmossman . I implemented your suggestions. Sorry for the typos, in French resource is ressource 馃槃 .

@alafanechere alafanechere merged commit 706d7f1 into master Mar 5, 2022
@alafanechere alafanechere deleted the augustin/octavia-cli/implement-apply branch March 5, 2022 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants