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 #6396: an error removing a DHCP record (record doesn't exist) stop... #174

Closed
wants to merge 2 commits into from

Conversation

pccowboy
Copy link

...s the delete process for a host

@domcleal
Copy link
Contributor

[test]

There's a check above in dhcp_api.rb for records that don't exist, any idea why that isn't matching? The correct response for a record that doesn't exist should be a 404, which Foreman itself handles and ignores.

@pccowboy
Copy link
Author

I believe this behavior is actually due to #175 (6412?) - when the host being checked is marked as 'deleted' in the dhcp data, but was originally from a different subnet than the subnet under evaluation, it is not found, and throws this error.

@@ -113,6 +113,8 @@ def load_subnet
else
redirect "/dhcp/#{params[:network]}"
end
rescue Proxy::DHCP::InvalidRecord
# Record doesn't exist, no need to do anything
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 should log_halt 404.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, would a 404 here not cause much the same issue? The foreman code parses proxy responses with this:

if response and response.code >= 200 and response.code < 300

So a 404 will still trigger the same result as the catchall 400 below.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah true, in that case, +1 for a 404, for consistency

@GregSutcliffe
Copy link
Member

@pccowboy i'm with @domcleal on the 404, and a test would be awesome, if you can.

@pccowboy
Copy link
Author

pccowboy commented Jul 2, 2014

@greg I'll try and think one up, I only thing that occurs to me is
checking the return type of the

find_record_by_hostname

method to make sire it is zero or one host object, and not an array.

Do you have any other suggestions?

Greg Sutcliffe mailto:notifications@github.com
Wednesday, July 02, 2014 9:12 AM

@pccowboy https://github.com/pccowboy i'm with @domcleal
https://github.com/domcleal on the 404, and a test would be awesome,
if you can.


Reply to this email directly or view it on GitHub
#174 (comment).

@GregSutcliffe
Copy link
Member

@pccowboy i think we want to stub out some methods and then check that delete actually raises a Proxy::DHCP::InvalidRecord error. Something like https://github.com/theforeman/smart-proxy/blob/develop/test/tftp/tftp_test.rb#L35-L42 where we check the raise type of a piece of tftp code. Ping me on IRC if you need a hand, I'd like to get this merged :)

@domcleal
Copy link
Contributor

[test]

@domcleal
Copy link
Contributor

Merged as 67bfd9a for Foreman 1.5.2, thanks @pccowboy and @sodabrew!

@domcleal domcleal closed this Jul 11, 2014
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.

3 participants