neoave / mrack

Multicloud use-case based multihost async provisioner for CIs and testing during development
Apache License 2.0
11 stars 14 forks source link

Issue: fqdn in name is ignored and mrack guesses the name instead #237

Closed jakub-vavra-cz closed 1 year ago

jakub-vavra-cz commented 1 year ago

When the name is fqdn it is ignored and mrack creates name by getting the first part of the name and then add domain instead of using it directly.

https://github.com/neoave/mrack/blob/main/src/mrack/outputs/ansible_inventory.py#L146

pvoborni commented 1 year ago

To clarify what is the expected issue and behavior - as the issue description doesn't provide it explicitly.

Atm, the current behavior is the following, right?

Input: Host's name Input: Host's domain name Output: meta_hostname Output: meta_domain Output meta_fqdn comment
abc.example.test example.test abc example.test abc.example.test looks good
abc example.test abc example.test abc.example.test looks good
abc.sub.example.test sub.example.test abc sub.example.test abc.sub.example.test looks good
abc sub.example.test abc sub.example.test abc.sub.example.test looks good
abc.sub example.test abc example.test abc.example.test the reported "issue" - "sub" is lost

So the reported issue is the last case. I.e. mix of shortname and subdomain name in host's name and a parent domain in the domain part.

Is the expected behavior of the fix to be the following?

Input: Host's name Input: Host's domain name Output: meta_hostname Output: meta_domain Output meta_fqdn
abc.sub example.test abc sub.example.test abc.sub.example.test
jakub-vavra-cz commented 1 year ago

When there is "." in the name mrack should recognize it as a fqdn and just return it. Otherwise it should append the domain to the name. I want to be able to use fqdn in the name as a "override".

238

pvoborni commented 1 year ago

From my PoV, mrack should rather fail than to this. Such behavior is even more confusing. Somebody else would open a bug exactly about this - saying: why is the FQDN of the host not containing the domain where the host is in.

pvoborni commented 1 year ago

What also looks correct to me is:

Fail on validation if hostname is e.g. "abc.foo" and domain is "example.test" - i.e. if host tries to be FQDN but doesn't contain it's parent domain name.

Support the following case:

Input: Host's name Input: Host's domain name Output: meta_hostname Output: meta_domain Output: meta_fqdn
abc.sub.example.test example.test abc sub.example.test abc.sub.example.test

Mrack would keep supporting either FQDN or shortname in hostname, but would not allow mismatches between domains.

jakub-vavra-cz commented 1 year ago

I have modified the code . If the host has mismatched fqdn with the domain to raise a MetadataError. When fqdn has a subdomain I am putting it to meta_domain.

Tiboris commented 1 year ago

@jakub-vavra-cz does the above commit solve this issue for you?

jakub-vavra-cz commented 1 year ago

@jakub-vavra-cz does the above commit solve this issue for you?

Yes

jakub-vavra-cz commented 1 year ago

Resolved.