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

Poll ncat tunnel pid #15056

Merged
merged 1 commit into from
Jun 5, 2024
Merged

Poll ncat tunnel pid #15056

merged 1 commit into from
Jun 5, 2024

Conversation

dosas
Copy link
Collaborator

@dosas dosas commented May 14, 2024

Problem Statement

when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started

Solution

polling the ncat pid

Some tests using the feature

  • tests/foreman/cli/test_organization.py::test_positive_add_and_remove_capsules
  • tests/foreman/api/test_location.py::TestLocation::test_positive_create_update_and_remove_capsule

@dosas dosas requested a review from a team as a code owner May 14, 2024 07:13
@dosas dosas added CherryPick PR needs CherryPick to previous branches 6.12.z Introduced in or relating directly to Satellite 6.12 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 labels May 14, 2024
@omkarkhatavkar
Copy link

Can one of the admins verify this patch?

@dosas
Copy link
Collaborator Author

dosas commented May 14, 2024

trigger: test-robottelo
pytest: tests/foreman/cli/test_organization.py::test_positive_add_and_remove_capsules

@ogajduse ogajduse requested a review from lpramuk May 14, 2024 08:08
Copy link
Member

@rplevka rplevka left a comment

Choose a reason for hiding this comment

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

Mind leveraging wait_for in the retry logic?

btw, Am a bit surprised that we got this far with the pid listing diff logic. Looks quite race-condition-prone to me now. If we had multiple (xdist) tests running against the same machine (that is configurable), such check could be easily fooled by listing other xdist worker's PIDs.
However, since we hadn't run into any issues for so many years, I'd not fiddle with it ;)

robottelo/host_helpers/satellite_mixins.py Outdated Show resolved Hide resolved
when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem
@dosas
Copy link
Collaborator Author

dosas commented May 15, 2024

Mind leveraging wait_for in the retry logic?

Not at all.

btw, Am a bit surprised that we got this far with the pid listing diff logic. Looks quite race-condition-prone to me now. If we had multiple (xdist) tests running against the same machine (that is configurable), such check could be easily fooled by listing other xdist worker's PIDs. However, since we hadn't run into any issues for so many years, I'd not fiddle with it ;)

Yes, now that you mentioned it. Probably the session (broker) should take care of keeping track of started processes.

@dosas dosas requested a review from rplevka May 15, 2024 09:17
@rplevka
Copy link
Member

rplevka commented May 15, 2024

Mind leveraging wait_for in the retry logic?

Not at all.

btw, Am a bit surprised that we got this far with the pid listing diff logic. Looks quite race-condition-prone to me now. If we had multiple (xdist) tests running against the same machine (that is configurable), such check could be easily fooled by listing other xdist worker's PIDs. However, since we hadn't run into any issues for so many years, I'd not fiddle with it ;)

Yes, now that you mentioned it. Probably the session (broker) should take care of keeping track of started processes.

I'd rather make the check to look at the target port directly, as that's what we ultimately wait for. There still would be some room for race conditions, but the chances of hitting one might be much, much slimmer.
(example scenario of a possible rc would be: worker1 tries to spawn ncat to listen to randomly selected port 123456 but ncat fails to start the process for immediately, while worker2 accidentally chooses the same port and succeeds - this would lead to both workers to 'think', their ncat command was successful). One way around this could be to implement some sort of lockfile (e.g. function could create a file .ncat_<port_number> in a tempdir, after it chooses an available port and the same function would also check for the eventual lockfiles inside the port-picking logic).

Anyway, as I mentioned before - as long as nobody has hit the RC yet, it's probably a corner-case scenario (perhaps it might be worth adding a comment about it, so it's not lost) and i would not over-engineer it.

@omkarkhatavkar
Copy link

trigger: test-robottelo
pytest: tests/foreman/cli/test_organization.py::test_positive_add_and_remove_capsules

@rplevka rplevka added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Passed Indicates that latest PRT run is passed for the PR labels May 15, 2024
@rplevka
Copy link
Member

rplevka commented May 15, 2024

trigger: test-robottelo
pytest: tests/foreman/cli/test_organization.py::test_positive_add_and_remove_capsules

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6947
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/cli/test_organization.py::test_positive_add_and_remove_capsules --external-logging
Test Result : ================== 1 passed, 9 warnings in 848.81s (0:14:08) ===================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label May 15, 2024
@rplevka
Copy link
Member

rplevka commented May 16, 2024

@lpramuk mind giving this a review?
I am fine with an extra wait_for.

@lpramuk lpramuk merged commit e918739 into SatelliteQE:master Jun 5, 2024
12 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 5, 2024
when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem

(cherry picked from commit e918739)
github-actions bot pushed a commit that referenced this pull request Jun 5, 2024
when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem

(cherry picked from commit e918739)
github-actions bot pushed a commit that referenced this pull request Jun 5, 2024
when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem

(cherry picked from commit e918739)
github-actions bot pushed a commit that referenced this pull request Jun 5, 2024
when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem

(cherry picked from commit e918739)
lpramuk pushed a commit that referenced this pull request Jun 6, 2024
Poll ncat tunnel pid (#15056)

when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem

(cherry picked from commit e918739)

Co-authored-by: dosas <dosas@users.noreply.github.com>
lpramuk pushed a commit that referenced this pull request Jun 6, 2024
Poll ncat tunnel pid (#15056)

when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem

(cherry picked from commit e918739)

Co-authored-by: dosas <dosas@users.noreply.github.com>
lpramuk pushed a commit that referenced this pull request Jun 6, 2024
Poll ncat tunnel pid (#15056)

when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem

(cherry picked from commit e918739)

Co-authored-by: dosas <dosas@users.noreply.github.com>
lpramuk pushed a commit that referenced this pull request Jun 6, 2024
Poll ncat tunnel pid (#15056)

when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem

(cherry picked from commit e918739)

Co-authored-by: dosas <dosas@users.noreply.github.com>
jyejare pushed a commit to jyejare/robottelo that referenced this pull request Oct 19, 2024
when checking the pid right after ncat startup
it could happen that no pid was found despite ncat being started.
Polling solves this problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.12.z Introduced in or relating directly to Satellite 6.12 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants