Skip to content

Add more events when creating a machine with hetzner cloud#59861

Closed
dithmer wants to merge 24 commits intosaltstack:masterfrom
adesso-mobile:add-waiting-for-ssh-event-to-hetzner
Closed

Add more events when creating a machine with hetzner cloud#59861
dithmer wants to merge 24 commits intosaltstack:masterfrom
adesso-mobile:add-waiting-for-ssh-event-to-hetzner

Conversation

@dithmer
Copy link
Copy Markdown

@dithmer dithmer commented Mar 22, 2021

What does this PR do?

It adds events and a waiting routing for the creation of cloud machines via hetzner cloud driver to react to them via the reactor system of saltstack.

Commits signed with GPG?

No

@dithmer dithmer marked this pull request as ready for review March 22, 2021 09:39
@dithmer dithmer requested a review from a team as a code owner March 22, 2021 09:39
@dithmer dithmer requested review from krionbsd and removed request for a team March 22, 2021 09:39
@krionbsd krionbsd added the needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases label Mar 22, 2021
@dithmer
Copy link
Copy Markdown
Author

dithmer commented Mar 22, 2021

@krionbsd

Hello!

I feel like there is already the created-function tested in a unit test. I don't think I am adding something which is not covered by the already written tests from PR #59301

If there is still something wanted, please let me know your ideas of how I can test the events I trigger.

Best regards

@dithmer
Copy link
Copy Markdown
Author

dithmer commented Apr 6, 2021

@krionbsd

I've just added tests for the timeout and added the check if server is running via a patch of unittest.mock in all the create methods. Anything else todo here?

@github-actions
Copy link
Copy Markdown

Hi! I'm your friendly PR bot!

You might be wondering what I'm doing commenting here on your PR.

Yes, as a matter of fact, I am...

I'm just here to help us improve the documentation. I can't respond to
questions or anything, but what I can do, I do well!

Okay... so what do you do?

I detect modules that are missing docstrings or "CLI Example" on existing docstrings!
When I was created we had a lot of these. The documentation for these
modules need some love and attention to make Salt better for our users.

So what does that have to do with my PR?

I noticed that in this PR there are some files changed that have some of these
issues. So I'm leaving this comment to let you know your options.

Okay, what are they?

Well, my favorite, is that since you were making changes here I'm hoping that
you would be the most familiar with this module and be able to add some other
examples or fix any of the reported issues.

If I can, then what?

Well, you can either add them to this PR or add them to another PR. Either way is fine!

Well... what if I can't, or don't want to?

That's also fine! We appreciate all contributions to the Salt Project. If you
can't add those other examples, either because you're too busy, or unfamiliar,
or you just aren't interested, we still appreciate the contributions that
you've made already.

Whatever approach you decide to take, just drop a comment here letting us know!

Detected Issues (click me)
[INFO] Initializing environment for https://github.com/saltstack/pip-tools-compile-impersonate.
[INFO] Initializing environment for https://github.com/asottile/pyupgrade.
[INFO] Initializing environment for https://github.com/saltstack/pre-commit-remove-import-headers.
[INFO] Initializing environment for https://github.com/s0undt3ch/salt-rewrite.
[INFO] Initializing environment for https://github.com/timothycrosley/isort.
[INFO] Initializing environment for https://github.com/timothycrosley/isort:toml.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/asottile/blacken-docs.
[INFO] Initializing environment for https://github.com/asottile/blacken-docs:black==21.7b0.
[INFO] Initializing environment for https://github.com/PyCQA/bandit.
[INFO] Initializing environment for https://github.com/saltstack/invoke-pre-commit.
[INFO] Initializing environment for https://github.com/saltstack/invoke-pre-commit:blessings,distro,jinja2,msgpack,pyyaml.
[INFO] Initializing environment for https://github.com/saltstack/mirrors-nox.
[INFO] Initializing environment for https://github.com/saltstack/mirrors-nox:pip>=20.2.4,<21.2,setuptools<58.0.
[INFO] Installing environment for https://github.com/saltstack/invoke-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Check Known Missing Docstrings...........................................Failed
- hook id: invoke
- duration: 1.51s
- exit code: 1

The function 'avail_locations' on 'salt/cloud/clouds/hetzner.py' does not have a docstring
The function 'avail_images' on 'salt/cloud/clouds/hetzner.py' does not have a docstring
The function 'avail_sizes' on 'salt/cloud/clouds/hetzner.py' does not have a docstring
The function 'list_ssh_keys' on 'salt/cloud/clouds/hetzner.py' does not have a docstring
The function 'list_nodes_full' on 'salt/cloud/clouds/hetzner.py' does not have a docstring
The function 'list_nodes' on 'salt/cloud/clouds/hetzner.py' does not have a docstring
The function 'show_instance' on 'salt/cloud/clouds/hetzner.py' does not have a docstring
Found 7 errors


Thanks again!

@Ch3LL Ch3LL added the P1 Priority 1 label Sep 19, 2022
@whytewolf
Copy link
Copy Markdown
Collaborator

@dithmer can you update the PR to the current version of the master? We are looking into these PR's and it looks like this one has some errors in lint but because of the last time the tests were run we can't see what those errors were.

twangboy
twangboy previously approved these changes Sep 21, 2022
@waynew
Copy link
Copy Markdown
Contributor

waynew commented Oct 10, 2022

Taking a look at this right now - I have a question about the test that I want to confirm real quick.

Copy link
Copy Markdown
Contributor

@waynew waynew left a comment

Choose a reason for hiding this comment

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

Okay, question was answered. I don't think that my suggestions are necessarily blocking now that they've been documented here in the issue.

Comment on lines +472 to +474
with pytest.raises(TimeoutError):
with Timeout(seconds=3):
hetzner.create(vm)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking) it would be helpful to mention something either in the comments or in the actual test name. I would say something like:

def test_when_server_status_is_not_running_create_should_never_return(vm):

Alternatively the comment could be

Create will never return unless the .status is "running", so we need a Timeout that will interrupt the loop in .create.

I'm not currently familiar with the surrounding code, so I'm assuming that the cloud code will already timeout this call?

@Ch3LL
Copy link
Copy Markdown
Contributor

Ch3LL commented Oct 31, 2022

bump @dithmer are you able to come back to this one and implement the feedback and fix up the tests?

@dithmer
Copy link
Copy Markdown
Author

dithmer commented Nov 1, 2022

bump @dithmer are you able to come back to this one and implement the feedback and fix up the tests?

Hi, I would love to take on it again. I just didn't feel that it was too urgent, cause this issue is already open for about 2 years.

It will probably take my attention during the next week! Have a nice day!

@dithmer
Copy link
Copy Markdown
Author

dithmer commented Nov 10, 2022

@Ch3LL

Will take a few more days. But I'm on it!

@dithmer
Copy link
Copy Markdown
Author

dithmer commented Nov 15, 2022

Hi @Ch3LL

I am trying to launch the tests locally but whenever I follow the tutorial for installing (https://docs.saltproject.io/en/master/topics/development/hacking.html#installing-salt-for-development) it installs salt in a version (3000.1) which is not compatible with the tests resulting in an error message:

nox -e 'pytest-zeromq-3(coverage=False)' -- tests/pytests/unit/cloud/clouds/test_hetzner.py
nox > Running session pytest-zeromq-3(coverage=False)
nox > Creating virtual environment (virtualenv) using python3 in .nox/pytest-zeromq-3-coverage-false
nox > This nox session is deprecated, please call 'test-zeromq-3(coverage=False)' instead
nox > Session pytest-zeromq-3(coverage=False) was successful.
nox > Running session test-zeromq-3(coverage=False)
nox > Creating virtual environment (virtualenv) using python3 in .nox/test-zeromq-3-coverage-false
nox > Session test-zeromq-3(coverage=False) was successful.
nox > Running session test-parametrized-3(crypto=None, transport='zeromq', coverage=False)
nox > Creating virtual environment (virtualenv) using python3 in .nox/test-parametrized-3-crypto-none-transport-zeromq-coverage-false
nox > python -m pip install --progress-bar=off -U 'pip>=20.2.4,<21.2' 'setuptools!=50.*,!=51.*,!=52.*,<59' wheel
nox > python -m pip install --progress-bar=off -r requirements/static/ci/py3.10/linux.txt
nox > python -m pytest --rootdir /home/dithmer/dev/salt --log-file-level=debug --show-capture=no -ra -s --showlocals --log-file=/home/dithmer/dev/salt/artifacts/logs/runtests-20221115213630.122146.log --transport=zeromq tests/pytests/unit/cloud/clouds/test_hetzner.py
ERROR: Only salt>=3004 is supported

nox > Command python -m pytest --rootdir /home/dithmer/dev/salt --log-file-level=debug --show-capture=no -ra -s --showlocals --log-file=/home/dithmer/dev/salt/artifacts/logs/runtests-20221115213630.122146.log --transport=zeromq tests/pytests/unit/cloud/clouds/test_hetzner.py failed with exit code 4
nox > Session test-parametrized-3(crypto=None, transport='zeromq', coverage=False) failed.
nox > Ran multiple sessions:
nox > * pytest-zeromq-3(coverage=False): success
nox > * test-zeromq-3(coverage=False): success
nox > * test-parametrized-3(crypto=None, transport='zeromq', coverage=False): failed

What am I missing here? Branch was rebased with master and I've already tried to clean cache/remove the whole virtualenv.

Best regards

@Ch3LL
Copy link
Copy Markdown
Contributor

Ch3LL commented Nov 16, 2022

Can you ensure you have rebased the lastest changes off of master? I've never seen that before.

@dithmer
Copy link
Copy Markdown
Author

dithmer commented Nov 20, 2022

Can you ensure you have rebased the lastest changes off of master? I've never seen that before.

Absolutely. Couldnt find out whats the problem yet.

@Ch3LL
Copy link
Copy Markdown
Contributor

Ch3LL commented Nov 22, 2022

One other thing you can try is to remove your .nox directory to ensure you start with a clean slate.

also @s0undt3ch any ideas at first glance on that error posted above?

@s0undt3ch
Copy link
Copy Markdown
Contributor

Make sure you have all the tags and yes, removing .nox just in case.
But most importantly, the tags.

@dwoz
Copy link
Copy Markdown
Contributor

dwoz commented Dec 10, 2023

Closing this due to inactivity. Anyone should feel free to re-open it if they want to see it through to the end in one release cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Abandoned help-wanted Community help is needed to resolve this needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases P1 Priority 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants