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

Fixes #21449 - Drop host from known hosts on proxies #451

Merged
merged 1 commit into from May 5, 2020

Conversation

adamruzicka
Copy link
Contributor

No description provided.

@tux93
Copy link

tux93 commented Dec 9, 2019

I tested this by applying it on a foreman-1.22.1 server and it seems currently the keys are only removed from known_hosts upon deletion but kept when only re-building a host.

To completely solve #21449 I believe the keys need to also be removed when re-building a host.

@adamruzicka
Copy link
Contributor Author

adamruzicka commented Dec 9, 2019

@tux93 thank you for testing this. As far as I understood, with these changes the keys should be removed even on rebuild. Looks like I'll have to look into it a bit more

EDIT: Oh, I see. Good catch

@adamruzicka
Copy link
Contributor Author

Tests are green-ish

@tux93
Copy link

tux93 commented Dec 10, 2019

I tried again with the current state and keys are still only removed upon deletion, not rebuild, though that could also be due to the old foreman version on my test system

extend ActiveSupport::Concern

included do
register_rebuild(:rebuild_ssh, N_("SSH_#{self.to_s.split('::').first}"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is this good for? I wasn't able to trigger anything using just this, I had to trigger things from after_validation callback

@tux93
Copy link

tux93 commented Dec 20, 2019

I got around to re-test today and it works now for rebuilding too!

Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

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

Thanks @adamruzicka and @tux93 for testing, merging now!

@ares
Copy link
Member

ares commented Jan 10, 2020

oh actually not merging, tests failures are related NameError: undefined local variable or method queue' for #Nic::Base:0x000000000beb5180`

ares
ares previously requested changes Jan 10, 2020
Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

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

tests

@adamruzicka
Copy link
Contributor Author

[test foreman_remote_execution]

@adamruzicka
Copy link
Contributor Author

@tux93 could you please try this one more time?

@tux93
Copy link

tux93 commented Feb 25, 2020

Re-tested with the latest version of the patch and it still works for me

@adamruzicka
Copy link
Contributor Author

[test foreman_remote_execution]

1 similar comment
@adamruzicka
Copy link
Contributor Author

[test foreman_remote_execution]

@adamruzicka adamruzicka force-pushed the known-hosts branch 2 times, most recently from 7446648 to 9e42dad Compare March 24, 2020 13:59

def should_drop_from_known_hosts?
host, = host_kind_target
host && host.build && host.changes.key?('build') && !orchestration_errors?

Choose a reason for hiding this comment

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

Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method.

end

def queue_ssh_destroy
return unless should_drop_from_known_hosts?

Choose a reason for hiding this comment

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

Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.

Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we disable this cop? We've decided to disable it in core.. (theforeman/foreman#7518) this is exactly the case where it doesn't deserve the blank line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm all in for this


def should_drop_from_known_hosts?
host, = host_kind_target
host && host.build && host.changes.key?('build')

Choose a reason for hiding this comment

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

Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method.

Copy link
Member

Choose a reason for hiding this comment

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

this is still on, even though I'm not sure I like the new style more 🤔

Suggested change
host && host.build && host.changes.key?('build')
host&.build && host&.changes&.key?('build')

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Just nitpicks, but 👮‍♂️ is unhappy now.


def should_drop_from_known_hosts?
host, = host_kind_target
host && host.build && host.changes.key?('build')
Copy link
Member

Choose a reason for hiding this comment

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

this is still on, even though I'm not sure I like the new style more 🤔

Suggested change
host && host.build && host.changes.key?('build')
host&.build && host&.changes&.key?('build')

end

def queue_ssh_destroy
return unless should_drop_from_known_hosts?
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we disable this cop? We've decided to disable it in core.. (theforeman/foreman#7518) this is exactly the case where it doesn't deserve the blank line.

@adamruzicka
Copy link
Contributor Author

We're finally 🍏

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

works as expected, just don't understand why do we care about Ansible proxies here 🤔

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

We could simplify, apart of it, I'm good and I can ignore redmine and squash on merge 👍

@ezr-ondrej
Copy link
Member

WWFJ
hurry-up

@ezr-ondrej
Copy link
Member

nooo! now we go again! xD I wanted to squash xD

@adamruzicka
Copy link
Contributor Author

I can always dig through reflog and un-squash it if you want it that bad :)

@ezr-ondrej
Copy link
Member

I can always dig through reflog and un-squash it if you want it that bad :)

Nah xD It was just about Jenkins being almost done xD and now he goes again 🕐

@adamruzicka
Copy link
Contributor Author

🍏

@ezr-ondrej ezr-ondrej dismissed ares’s stale review May 5, 2020 15:22

tests are green

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Thanks @adamruzicka !
plusone

@ezr-ondrej ezr-ondrej merged commit 734acd4 into theforeman:master May 5, 2020
@adamruzicka adamruzicka deleted the known-hosts branch May 6, 2020 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants