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

basename: missing operand when launching scope when weavedns is running #137

Closed
rade opened this issue May 31, 2015 · 2 comments
Closed
Assignees
Labels
bug Broken end user or developer functionality; not working as the developers intended it

Comments

@rade
Copy link
Member

rade commented May 31, 2015

$ weave launch
476e00691ca1a5d9423f03377f0b18527478aff716e1ff867c70cec6724a8c17
$ weave launch-dns 10.2.0.1/24
e572552f539cd417d10e7c656b4854d65a752921498b27a733e83c65bcdff81a
$ ./scope launch
basename: missing operand
Try 'basename --help' for more information.
73f80066456faeb694ff119fa1de4dd3604f7b731d3fd8bb65a05e0a46cb96a1

This is with version 2e8df4a, built according to the instructions.

tracing the exeuction with sh -x produces

...
+ dns_running
+ docker inspect --format={{.State.Running}} weavedns
+ status=true
+ [ true = true ]
+ return 0
+ + xargs -n1 basename
find /sys/class/net -name eth*
+ grep inet
+ + xargsgrep echo
 -oE [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
+ + awkxargs { print $2 } -n1 ip
 addrbasename: missing operand
Try 'basename --help' for more information.
 show
...

Looking at this and the code, I think the issue is that the script doesn't cope with my machine not having an eth* interface.

@rade rade added the bug Broken end user or developer functionality; not working as the developers intended it label May 31, 2015
@peterbourgon
Copy link
Contributor

Via my own educational archaeology, the offending block

        if dns_running; then
            IP_ADDRS=$(find /sys/class/net -name eth* | xargs -n1 basename | xargs -n1 ip addr show |
                grep inet | awk '{ print $2 }' | grep -oE "$IP_REGEXP" | xargs echo)
            tell_dns_fqdn PUT $CONTAINER $FQDN $IP_ADDRS
        fi

Compare against the weave script's invocation

    dns-add)
        collect_ip_args "$@"
        shift $IP_COUNT
        [ $# -ge 1 ] || usage
        CONTAINER_ID="$1"
        if [ $# -eq 1 ] ; then
            tell_dns PUT $CONTAINER_ID $IP_ARGS
        else
            [ $# -eq 3 -a "$2" = "-h" ] || usage
            FQDN="$3"
            tell_dns_fqdn PUT $CONTAINER_ID $FQDN $IP_ARGS # <== here
        fi
        ;;

Where collect_ip_args takes from the commandline

collect_ip_args() {
    IP_ARGS=""
    IP_COUNT=0
    while is_ip "$1" ; do
        IP_ARGS="$IP_ARGS $1"
        IP_COUNT=$((IP_COUNT + 1))
        shift 1
    done
    if [ $IP_COUNT -eq 0 ] ; then
        [ $# -gt 0 ] && validate_ip "$1" || usage
    fi
}

I guess we can do the same, if there's not a smarter way?

@tomwilkie
Copy link
Contributor

This is because @rade doesn't have any eth devices, only vlan devices.

Alternatives:

  • do reverse dns on hostname to find our IP(s) - downside is that on my vagrant VM, this doesn't work:
$ host $(hostname)
Host ubuntu-14 not found: 3(NXDOMAIN)
  • include vlan (or all, except the docker bridge) devices in this advertisement. The app and probe are listening on everything anyway...
  • add a command line option for when this doesn't work, and make it fail gracefully.
  • use ifconfig (basically doing the same as above)
$ ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
172.17.42.1
10.0.2.15
172.16.0.3

I don't feel like I know the best answer. In the meantime I'll make this fail less spectacularly.

@tomwilkie tomwilkie self-assigned this Jun 1, 2015
bboreham added a commit that referenced this issue Aug 10, 2018
2bbc9a08 Merge pull request #140 from weaveworks/sched-http-retry
c3726dea Add retries to sched util http calls
2cc7b5ac Merge pull request #139 from meghalidhoble/master
fd9b0a72 Change : Modified the lint tools to skip the shfmt check if not installed. Why the change : For ppc64le the specific version of shfmt is not available, hence skipped completely the installation of shfmt tool. Thus this change made.
bc645c70 Merge pull request #138 from dholbach/add-license-file
a642e022 license: add Apache 2.0 license text
9bf59568 Merge pull request #109 from hallum/master
d971d821 Merge pull request #134 from weaveworks/2018-07-03-gcloud-regepx
32e7aa2d Merge pull request #137 from weaveworks/gcp-fw-allow-kube-apiserver
bbb6735e Allow CI to access k8s API server on GCP instances
764d46ca Merge pull request #135 from weaveworks/2018-07-04-docker-ansible-playbook
ecc2a4e3 Merge pull request #136 from weaveworks/2018-07-05-gcp-private-ips
209b7fb6 tools: Add private_ips to the terraform output
369a655f tools: Add an ansible playbook that just installs docker
a643e270 tools: Use --filter instead of --regexp with gcloud
b8eca887 Merge pull request #128 from weaveworks/actually-say-whats-wrong
379ce2bb Merge pull request #133 from weaveworks/fix-decrypt
3b906b54 Fix incompatibility with recent versions of OpenSSL
f091ab43 Merge pull request #132 from weaveworks/add-opencontainers-labels-to-dockerfiles
248def1b Inject git revision in Dockerfiles
64f2c280 Add org.opencontainers.image.* labels to Dockerfiles
ea96d8ed add information about how to get help (#129)
f066ccdd Make yapf diff failure look like an error
34d81d70 Merge pull request #127 from weaveworks/golang-1.10.0-stretch
89a0b4f8 Use golang:1.10.0-stretch image.
ca69607f Merge pull request #126 from weaveworks/disable-apt-daily-test
f5dc5d54 Create "setup-apt" role
7fab4413 Rename bazel to bazel-rules (#125)
ccc83168 Revert "Gocyclo should return error code if issues detected" (#124)
1fe184f1 Bazel rules for building gogo protobufs (#123)
b917bb89 Merge pull request #122 from weaveworks/fix-scope-gc
c029ce01 Add regex to match scope VMs
0d4824b1 Merge pull request #121 from weaveworks/provisioning-readme-terraform
5a82d64c Move terraform instructions to tf section
d285d78d Merge pull request #120 from weaveworks/gocyclo-return-value
76b94a47 Do not spawn subshell when reading cyclo output
93b3c0d5 Use golang:1.9.2-stretch image
d40728f6 Gocyclo should return error code if issues detected
c4ac1c3f Merge pull request #114 from weaveworks/tune-spell-check
89806560 Only check files
12ebc73a Don't spell-check pki files
578904ab Special-case spell-check the same way we do code checks
e772ed59 Special-case on mime type and extension using just patterns
ae82b50c Merge pull request #117 from weaveworks/test-verbose
89434738 Propagate verbose flag to 'go test'.
7c79b43c Merge pull request #113 from weaveworks/update-shfmt-instructions
258ef015 Merge pull request #115 from weaveworks/extra-linting
e690202b Use tools in built image to lint itself
126eb561 Add shellcheck to bring linting in line with scope
63ad68f0 Don't run lint on files under .git
51d908a3 Update shfmt instructions
e91cb0d3 Merge pull request #112 from weaveworks/add-python-lint-tools
0c87554d Add yapf and flake8 to golang build image
35679ee5 Merge pull request #110 from weaveworks/parallel-push-errors
3ae41b6f Remove unneeded if block
51ff31a5 Exit on first error
0faad9f7 Check for errors when pushing images in parallel
d87cd026 Add arg flag override for destination socks host:port in pacfile.

git-subtree-dir: tools
git-subtree-split: 2bbc9a08a7f672eae62cfe110d7f536c6cc53ce3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken end user or developer functionality; not working as the developers intended it
Projects
None yet
Development

No branches or pull requests

3 participants