Skip to content

fix: machine scp/ssh operations#1016

Closed
yanksyoon wants to merge 17 commits intojuju:masterfrom
yanksyoon:fix/machine_ssh
Closed

fix: machine scp/ssh operations#1016
yanksyoon wants to merge 17 commits intojuju:masterfrom
yanksyoon:fix/machine_ssh

Conversation

@yanksyoon
Copy link
Copy Markdown
Contributor

@yanksyoon yanksyoon commented Jan 27, 2024

Description

<Please add why this change is needed and what it does.>
This is a follow up PR to #1015
This addresses the issue #997

The current machine.ssh or machine.scp will fail due to machine address not being ready.
This makes the machine ssh command become ssh ubuntu@None.

<Fixes: >
Added a function machine.wait() which waits for machine agent to become ready and the machine address to exist.
The scp/ssh functions now will raise if await machine.wait() hasn't been called.

QA Steps

tox -e integration -- -k test_machine_ssh

All CI tests need to pass.

<Please note that most likely an additional test will be required by the reviewers for any change that's not a one liner to land.>

Notes & Discussion

<Additional notes for the reviewers if needed. Please delete section if not applicable.>

@jujubot
Copy link
Copy Markdown
Contributor

jujubot commented Jan 27, 2024

Thanks for opening a pull request! Please follow the instructions here to ensure your pull request is ready for review. Then, a maintainer will review your patch.

@hpidcock @anvial

1 similar comment
@jujubot
Copy link
Copy Markdown
Contributor

jujubot commented Jan 27, 2024

Thanks for opening a pull request! Please follow the instructions here to ensure your pull request is ready for review. Then, a maintainer will review your patch.

@hpidcock @anvial

@tlm tlm requested a review from cderici January 30, 2024 05:56
@tlm
Copy link
Copy Markdown
Member

tlm commented Jan 30, 2024

@cderici mind taking a look? Or happy to do a dual review if you want to shadow me through this to make sure my assumptions are correct?

Copy link
Copy Markdown
Contributor

@cderici cderici left a comment

Choose a reason for hiding this comment

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

This is nice, but instead of failing in machine.ssh and machine.scp, I'd add an optional wait_until_active=False argument and inline the body of wait() in where you're currently raising an error. Note that block_until is defined in the model, so you're gonna need to call it like self.model.block_until() in Machine methods.

Also this in it's current implementation requires heavy testing, as the status is a bit finicky in pylibjuju, as the status we get through the api is not exactly the same status you'd see via juju-cli (i.e. juju status). For machines it shouldn't be too much of a problem, however, I would refrain from checking the status directly (like self.agent_status == "started"), as there might be a race where in between the block_until check intervals the status might change and you'd lose the time to catch it, so I wouldn't want my code to rely on the status itself. Instead I'd check just the addresses, as that's what you essentially need.

However, safe_data shouldn't be used outside the class, as it's internal, so let's add a machine.addresses() method and use that (also in the machine.dns_name() as well). WDYT?

@yanksyoon
Copy link
Copy Markdown
Contributor Author

Thank you for the review @cderici !

I've applied the changes - but since this was branched off of #1015 , shall I wait until the conversation there is resolved? Or I could cherry-pick the changes for this PR and branch if off of main again :)

@cderici
Copy link
Copy Markdown
Contributor

cderici commented Jan 31, 2024

shall I wait until the conversation there is resolved? Or I could cherry-pick the changes for this PR and branch if off of main again :)

@yanksyoon if it's not too much trouble it would be nice to isolate this change to just fixing #997, thanks again for working on this! (If it'll take time feel free to wait until we decide how to proceed with #1015)

@yanksyoon yanksyoon mentioned this pull request Feb 1, 2024
@yanksyoon
Copy link
Copy Markdown
Contributor Author

@cderici I've created #1020 with cherry-picked commits, I'll close this one! Thank you for the feedback so far! :D

@yanksyoon yanksyoon closed this Feb 1, 2024
jujubot added a commit that referenced this pull request Mar 5, 2024
#1020

#### Description

This is a follow-up PR to #1016 , which contains cherry-picked commits without type imports.

Fİxes #997 

#### QA Steps

*<Commands / tests / steps to run to verify that the change works:>*

```
tox -e py3 -- tests/unit/...
```

```
tox -e integration -- tests/integration/test_machine.py
```

All CI tests need to pass.

*<Please note that most likely an additional test will be required by the reviewers for any change that's not a one liner to land.>*

#### Notes & Discussion

*<Additional notes for the reviewers if needed. Please delete section if not applicable.>*
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.

4 participants