kamilchm / nixops-dns

DNS server for resolving NixOps machines
MIT License
4 stars 4 forks source link

Machines with the same name on different deployments #3

Closed GlennS closed 5 years ago

GlennS commented 6 years ago

Hi,

Firstly, nice work, I'm finding nixops-dns very useful.

I'm wondering if there's a way to make it work when you have machines with the same name on different deployments.

For example, say I'm working on project-X. I might have deployments called project-x-live and project-x-test. Each of these has a machine in them called project-x-server.

It looks like, at present, nixops-dns will use the first IP it gets back from the database to make project-x-server.ops.

I'm wondering if it would be better to make something like project-x-server.project-x-test.ops, for example using something like this query:

SELECT RA.value AS ipv4
FROM Resources R
INNER JOIN ResourceAttrs RA ON RA.machine = R.id AND RA.name = 'privateIpv4'
INNER JOIN DeploymentAttrs DA ON DA.deployment = R.deployment AND DA.name = 'name'
WHERE R.name = ?
AND DA.value = ?;

What do you think?

If you like the idea, but don't want to do it yourself, I can try to make a pull request. I don't really know Go, but it looks reasonably straight forward.

Thanks, Glenn

GlennS commented 6 years ago

I had a bit of spare time, so I made this modification.

Let me know if you want a pull request.

kamilchm commented 6 years ago

Your change looks good. I added one question there and more importantly one more general in https://github.com/kamilchm/nixops-dns/issues/4#issuecomment-434809057 :)