Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

add weave dns-add/remove commands #627

Merged
merged 1 commit into from
May 7, 2015

Conversation

grkvlt
Copy link
Contributor

@grkvlt grkvlt commented May 3, 2015

Added two new commands dns-add and dns-remove that call the tell_dns function method to store addresses and optionally a specific FQDN for a container ID.

This is useful for circumstances where containers may be configured with IP addresses outside weave, perhaps by some contaienr orchestration service or using a different SDN, but those addresses should still be resolvable and usable by the weaveDNS.

@grkvlt
Copy link
Contributor Author

grkvlt commented May 3, 2015

@errordeveloper Can you have a look and review this, please? it is for the use case we discussed where weaveDNS is being used without the weave SDN, but I think it might be useful in other circumstances also.

@rade
Copy link
Member

rade commented May 3, 2015

Why do you want to make IP addresses for containers outside the weave network resolvable in the weave domain?

# This function is only called where we know $2 is a valid container name
tell_dns() {
METHOD="$1"
CONTAINER_ID="$2"
shift 2

collect_cidr_args "$@"
shift $CIDR_COUNT

This comment was marked as abuse.

This comment was marked as abuse.

@rade
Copy link
Member

rade commented May 3, 2015

Is put-dns the best command name we can come up with?

Also, surely there should be an inverse operation.

@rade
Copy link
Member

rade commented May 4, 2015

NB: this partially addresses #364. Note the major caveat listed there: all these "manually" inserted records are lost on weavedns restart. Nevertheless, I suggest that this PR closes #364, and that we open separate issues for the two remaining points identified there (lossy restart, and lack of support for CNAMEs).

@grkvlt
Copy link
Contributor Author

grkvlt commented May 4, 2015

@rade @errordeveloper For the inverse, I assume I just call tell_dns but with DELETE as the method. Do I need to worry about FQDNs in the delete call?

@grkvlt
Copy link
Contributor Author

grkvlt commented May 4, 2015

@rade How about add-dns and rm-dns as the two commands?

@grkvlt grkvlt force-pushed the feature/add-dns-entry branch 2 times, most recently from e115e97 to 9adad5d Compare May 4, 2015 19:57
@rade
Copy link
Member

rade commented May 4, 2015

For the inverse, I assume I just call tell_dns but with DELETE as the method. Do I need to worry about FQDNs in the delete call?

You should have to worry about the FQDN. After all, what if you have one IP under multiple names and want to remove just one of records? However, it looks like this functionality is missing from the DNS API.

@grkvlt
Copy link
Contributor Author

grkvlt commented May 4, 2015

You should have to worry about the FQDN

I pass in the domain name inside $MORE_DATA for the http_call in tell_dns_fqdn no matter what the $METHOD was set to. I think this means that once the DNS API supports it things will work as expected?

@@ -28,6 +28,8 @@ usage() {
echo "weave start <cidr> [<cidr> ...] <container_id>"
echo "weave attach <cidr> [<cidr> ...] <container_id>"
echo "weave detach <cidr> [<cidr> ...] <container_id>"
echo "weave add-dns <cidr> [<cidr> ...] <container_id> [-fqdn fqdn]"

This comment was marked as abuse.

@rade
Copy link
Member

rade commented May 4, 2015

still not sure about the command names. add/remove-name? It's not perfect, but add-dns-A-record(s)-for-container-under-name-and-given-ip(s) is a bit long.

@grkvlt
Copy link
Contributor Author

grkvlt commented May 4, 2015

@rade happy to change to add-name and remove-name or what about rm-name instead?

@rade
Copy link
Member

rade commented May 4, 2015

Let's see what other suggestions come up from interested bike shed painters.

@grkvlt
Copy link
Contributor Author

grkvlt commented May 4, 2015

OK, I have left it as add-name and rm-name for the moment. I also didn't include the ability to set an FQDN for the rm-name command, since as you pointed out it's not supported in the DNS API yet.

Thanks for taking the time to review this @rade

@grkvlt grkvlt force-pushed the feature/add-dns-entry branch 2 times, most recently from 1568ddd to 46ca784 Compare May 4, 2015 21:30
@grkvlt
Copy link
Contributor Author

grkvlt commented May 4, 2015

I added a test script (called 240_dns_add_name_test.sh) but was not able to run it properly, although manual testing of the add-name command works for me on a local Vargrant build of Weave. Are these tests run automatically anywhere?

@awh
Copy link
Contributor

awh commented May 5, 2015

Are add-name etc a bit generic for the top level? How about contextualising them like this:

weave dns add
weave dns remove

@awh
Copy link
Contributor

awh commented May 5, 2015

Just discussing with @squaremo - further to this line of thought we could contextualise the existing router commands:

weave router launch
weave router attach
weave dns launch

obviously we'd still support the existing script commands, but they would become deprecated - this would allow us to address #602 cleanly...

@inercia
Copy link
Contributor

inercia commented May 5, 2015

I like @awh proposal. I think we should move to a format like weave

@grkvlt
Copy link
Contributor Author

grkvlt commented May 5, 2015

@awh @inercia OK, but we should do that in a different PR. For this feature I think the current command names will be fine, although they could use something likr the @Beta annotation Java has?

@rade
Copy link
Member

rade commented May 5, 2015

let's go with dns-add and dns-remove. This introduces an inconsistency w.r.t. other composite commands, which are "verb-noun", but all the alternatives we can think of are either longer (e.g. add-dns-record) or misleading (e.g. add-dns).

@rade rade self-assigned this May 6, 2015

```bash
$ docker stop $shell2
$ weave dns-remove 10.2.1.27/24 $shell2

This comment was marked as abuse.

This comment was marked as abuse.

@grkvlt
Copy link
Contributor Author

grkvlt commented May 6, 2015

$ ./240_dns_add_name_test.sh 
Cleaning up on 192.168.48.11: removing all containers and resetting weave
Cleaning up on 192.168.48.12: removing all containers and resetting weave
Add and remove names on a single host
Weave on 192.168.48.11: launch-dns 10.2.254.1/24
9a8f3007c9166ce78815f2c2e56336fa0ebdcb9215f0c27c731f2b65fb8a1849
Weave on 192.168.48.11: run 10.2.0.34/24 -t --name=c2 ubuntu
9a8a29ee877e11acdaa4ef309c3d9344553ce941e9fee3189049b5cc3fc68296
Weave on 192.168.48.11: run --with-dns 10.2.0.78/24 -t --name=c1 aanand/docker-dnsutils /bin/sh
cf10f945925795426b5a14463fedcc4acb5a8fba9662fff39240ca42dbd0bdff
Weave on 192.168.48.11: dns-add 10.2.0.34/24 c2 -h seetwo.weave.local
Weave on 192.168.48.11: dns-remove 10.2.0.34/24 c2
all 3 tests passed in 8.012s.

@grkvlt grkvlt force-pushed the feature/add-dns-entry branch 2 times, most recently from 265e1d1 to d6f9410 Compare May 6, 2015 13:27
@grkvlt
Copy link
Contributor Author

grkvlt commented May 6, 2015

@rade should be ready to merge, rebased and sqashed, with tests passing

@rade rade changed the title Add new put-dns weave command that calls tell_dns add weave dns-add/remove commands May 6, 2015

weave_on $HOST1 dns-remove $C2/24 c2

assert_raises "exec_on $HOST1 c1 getent hosts $C2 | grep $NAME"

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@rade
Copy link
Member

rade commented May 6, 2015

add/remove-dns should take IP addresses (<ip_address> in weave usage terminology), not CIDRs.

I suspect this is going to make things a fair bit more involved since all the existing functions you are calling expect CIDRs. :(

weave_on $HOST1 dns-add $C2/24 c2 -h $NAME2
weave_on $HOST1 dns-remove $C2/24 c2

assert_raises "exec_on $HOST1 c1 getent hosts $NAME2 | grep $C2" 1

This comment was marked as abuse.

@grkvlt grkvlt force-pushed the feature/add-dns-entry branch 3 times, most recently from 0ec9b63 to 457866f Compare May 6, 2015 22:10
@grkvlt
Copy link
Contributor Author

grkvlt commented May 6, 2015

@rade try again 🐨 this has IP addresses instead of CIDRs and improved tests as suggested.

@grkvlt grkvlt force-pushed the feature/add-dns-entry branch from 457866f to 2fee13c Compare May 6, 2015 22:18
@@ -97,6 +99,32 @@ collect_cidr_args() {
fi
}

is_ip() {
# The regexp here is far from precise, but good enough.
echo "$1" | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' >/dev/null

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@grkvlt grkvlt force-pushed the feature/add-dns-entry branch from 61dabd7 to 8fad155 Compare May 7, 2015 11:10
- Commands dns-add and dns-remove added to weave script
- Updated documentation for WeaveDNS
- Added test script for dns-add and dns-remove
- Added IP address functions matching existing CIDR ones
@grkvlt grkvlt force-pushed the feature/add-dns-entry branch from 8fad155 to 633d539 Compare May 7, 2015 11:14
@grkvlt
Copy link
Contributor Author

grkvlt commented May 7, 2015

@rade we'll get there eventually... thanks again for helping me get this straightened out

rade added a commit that referenced this pull request May 7, 2015
add `weave dns-add/remove` commands

Closes #364.
@rade rade merged commit 5e5e932 into weaveworks:master May 7, 2015
@rade
Copy link
Member

rade commented May 7, 2015

@grkvlt thanks for your patience. Merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants