Skip to content

allow user to ask for FQDN as public hostname (SOC-9616) #1901

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

Merged
merged 1 commit into from
Aug 26, 2019
Merged

allow user to ask for FQDN as public hostname (SOC-9616) #1901

merged 1 commit into from
Aug 26, 2019

Conversation

guangyee
Copy link
Contributor

@guangyee guangyee commented Aug 19, 2019

Currently CrowbarHelper.get_host_for_public_url() indiscriminately
return the IP instead of FQDN in the situation where the
node's public_name is not set and SSL is not being used.
This behavior was introduced in

crowbar/barclamp-glance@22d3c19

to address certain situations where the crowbar generated hostnames are not
resolveable externally. For SSL, we need the FQDN or hostname for
certificate validation. However, for WebSSO, certain identity providers
(i.e. Google) requires FQDN to match the authorized domain, regardless of
whether SSL is used.

In theory, we could change the behavior of get_host_for_public_url() to
always return the FQDN instead of IP as we should be supporting
external name resolution by now, but doing so may risk breaking
backward compatibility. Therefore, this patch introduce an option to allow
users to ask for FQDN regardless whether SSL is used without breaking
backward compatibility.

if public_name.nil? || public_name.empty?
if use_ssl
if use_ssl || want_fqdn
Copy link

Choose a reason for hiding this comment

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

Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison.

@@ -33,7 +33,8 @@ def self.get_host_for_admin_url(node, use_cluster = false)
end
end

def self.get_host_for_public_url(node, use_ssl, use_cluster = false)
def self.get_host_for_public_url(node, use_ssl, use_cluster = false,
Copy link

Choose a reason for hiding this comment

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

Metrics/CyclomaticComplexity: Cyclomatic complexity for get_host_for_public_url is too high. [7/6]
Metrics/PerceivedComplexity: Perceived complexity for get_host_for_public_url is too high. [9/7]

@guangyee guangyee requested review from cmurphy and rhafer August 19, 2019 21:21
cmurphy
cmurphy previously approved these changes Aug 19, 2019
toabctl
toabctl previously approved these changes Aug 20, 2019
rhafer
rhafer previously approved these changes Aug 20, 2019
@toabctl
Copy link
Contributor

toabctl commented Aug 20, 2019

@rsalevsky do we plan to fix travis? Currently failing because of CVE-2019-5477 (see https://travis-ci.org/crowbar/crowbar-core/jobs/574040609#L1570 )

Copy link
Contributor

@dirkmueller dirkmueller left a comment

Choose a reason for hiding this comment

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

can you please explain this a bit more? if you set the public name on the cluster or the host then that one should be picked?

I am not necessarily adding another option, but it seems incorrect to me to do that only for keystone/websso then. we should generalize the solution (for example by simply always returning the hostname rather than ip addresses).

@rhafer
Copy link
Contributor

rhafer commented Aug 20, 2019

can you please explain this a bit more? if you set the public name on the cluster or the host then that one should be picked?

Yes, and AFAICS this PR doesn't change that behavior. It only changes what is returned when no public name is set.

I am not necessarily adding another option, but it seems incorrect to me to do that only for keystone/websso then. we should generalize the solution (for example by simply always returning the hostname rather than ip addresses).

IIRC we specifically introduced the behavior to return IP addresses for the endpoints by default, to be able to work when no public name is set and the crowbar generated hostnames are not resolveable externally (see: crowbar/barclamp-glance@22d3c19 for some very old history). Not sure if that is really a good reason still (or if it ever was :) ). But we might break existing setups if we set fqdn for the public endpoints everywhere now. That's why I hinted in crowbar/crowbar-openstack#2188 (comment) at making this optional.

@guangyee
Copy link
Contributor Author

can you please explain this a bit more? if you set the public name on the cluster or the host then that one should be picked?

Yes, and AFAICS this PR doesn't change that behavior. It only changes what is returned when no public name is set.

I am not necessarily adding another option, but it seems incorrect to me to do that only for keystone/websso then. we should generalize the solution (for example by simply always returning the hostname rather than ip addresses).

IIRC we specifically introduced the behavior to return IP addresses for the endpoints by default, to be able to work when no public name is set and the crowbar generated hostnames are not resolveable externally (see: crowbar/barclamp-glance@22d3c19 for some very old history). Not sure if that is really a good reason still (or if it ever was :) ). But we might break existing setups if we set fqdn for the public endpoints everywhere now. That's why I hinted in crowbar/crowbar-openstack#2188 (comment) at making this optional.

Probably won't break as we are already returning the FQDN if SSL is enabled. That is unless we do a bunch of other hacks to DNS if SSL is enabled.

@dirkmueller
Copy link
Contributor

Probably won't break as we are already returning the FQDN if SSL is enabled. That is unless we do a bunch of other hacks to DNS if SSL is enabled.

right, which is why I was wondering why we need to make it extra complicated. But I do accept and agree with ralfs comment that this is on a maintenance branch so we should be careful with changing default behavior in a maintenance update. so I'll no longer object. would still be nice to capture this in the commit message rather than in a comment on the PR..

@dirkmueller dirkmueller dismissed their stale review August 21, 2019 16:26

see last comment

Copy link
Contributor

@rhafer rhafer left a comment

Choose a reason for hiding this comment

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

@guangyee Would you mind addressing @dirkmueller's last comment and putting some of the reasoning into the commit message. I then this would be ready for merging.

Currently CrowbarHelper.get_host_for_public_url() indiscriminately
return the IP instead of FQDN in the situation where the
node's public_name is not set and SSL is not being used.
This behavior was introduced in

crowbar/barclamp-glance@22d3c19

to address certain situations where the crowbar generated hostnames are not
resolveable externally. For SSL, we need the FQDN or hostname for
certificate validation. However, for WebSSO, certain identity providers
(i.e. Google) requires FQDN to match the authorized domain, regardless of
whether SSL is used.

In theory, we could change the behavior of get_host_for_public_url() to
always return the FQDN instead of IP as we *should be* supporting
external name resolution by now, but doing so may risk breaking
backward compatibility. Therefore, this patch introduce an option to allow
users to ask for FQDN regardless whether SSL is used without breaking
backward compatibility.
@guangyee guangyee dismissed stale reviews from rhafer, toabctl, and cmurphy via 4ad0e46 August 23, 2019 15:26
@guangyee
Copy link
Contributor Author

@rhafer thanks for the reminder. I've updated the commit msg.

@toabctl toabctl merged commit 3e1e65b into crowbar:master Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants