Skip to content

Commit

Permalink
Rename dnsmasq-metrics to k8s-dns-sidecar
Browse files Browse the repository at this point in the history
The daemon is more generic than just dnsmasq, should just be called
`sidecar'.
  • Loading branch information
bowei committed Dec 19, 2016
1 parent e1e3843 commit 631bd46
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 33 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PKG := k8s.io/dns

# List of binaries to build. You must have a matching Dockerfile.BINARY
# for each BINARY.
BINARIES := dnsmasq-metrics
BINARIES := sidecar

# Registry to push to.
REGISTRY ?= gcr.io/google_containers
Expand Down
14 changes: 7 additions & 7 deletions cmd/dnsmasq-metrics/main.go → cmd/sidecar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"k8s.io/kubernetes/pkg/util/logs"
"k8s.io/kubernetes/pkg/version/verflag"

"k8s.io/dns/pkg/server"
"k8s.io/dns/pkg/sidecar"
"k8s.io/dns/pkg/version"
)

Expand All @@ -38,22 +38,22 @@ const (
)

func main() {
options := server.NewOptions()
options := sidecar.NewOptions()
configureFlags(options, pflag.CommandLine)
flag.InitFlags()

logs.InitLogs()
defer logs.FlushLogs()

glog.Infof("dnsmasq-metrics v%s", version.VERSION)
glog.Infof("Version v%s", version.VERSION)

verflag.PrintAndExitIfRequested()

server := server.NewServer()
server := sidecar.NewServer()
server.Run(options)
}

type probeOptions []server.DNSProbeOption
type probeOptions []sidecar.DNSProbeOption

func (po *probeOptions) String() string {
return fmt.Sprintf("%+v", *po)
Expand All @@ -65,7 +65,7 @@ func (po *probeOptions) Set(value string) error {
return fmt.Errorf("invalid format to --probe")
}

option := server.DNSProbeOption{
option := sidecar.DNSProbeOption{
Label: splits[0],
Server: splits[1],
Name: splits[2],
Expand Down Expand Up @@ -105,7 +105,7 @@ func (po *probeOptions) Type() string {

var _ pflag.Value = (*probeOptions)(nil)

func configureFlags(opt *server.Options, flagSet *pflag.FlagSet) {
func configureFlags(opt *sidecar.Options, flagSet *pflag.FlagSet) {
flagSet.StringVar(
&opt.DnsMasqAddr, "dnsmasq-addr", opt.DnsMasqAddr,
"address that the dnsmasq server is listening on")
Expand Down
2 changes: 1 addition & 1 deletion pkg/dnsmasq/dnsmasq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"
"testing"

"k8s.io/contrib/pkg/test"
"k8s.io/dns/pkg/test"

"github.com/miekg/dns"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/dnsprobe.go → pkg/sidecar/dnsprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package server
package sidecar

import (
"encoding/json"
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/dnsprobe_test.go → pkg/sidecar/dnsprobe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package server
package sidecar

import (
"fmt"
Expand All @@ -24,7 +24,7 @@ import (

"github.com/miekg/dns"

"k8s.io/contrib/pkg/test"
"k8s.io/dns/pkg/test"
)

type mockLoopDelayer struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/metrics.go → pkg/sidecar/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package server
package sidecar

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/options.go → pkg/sidecar/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package server
package sidecar

import "time"

Expand Down
2 changes: 1 addition & 1 deletion pkg/server/server.go → pkg/sidecar/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package server
package sidecar

import (
"time"
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/Dockerfile.e2e → test/e2e/sidecar/Dockerfile.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
FROM gcr.io/google_containers/kube-dnsmasq-amd64:1.4
MAINTAINER Bowei Du <bowei@google.com>

COPY test/e2e/docker-run-e2e.sh /docker-run-e2e.sh
COPY bin/amd64/dnsmasq-metrics /dnsmasq-metrics
COPY test/e2e/sidecar/docker-run-e2e.sh /docker-run-e2e.sh
COPY bin/amd64/sidecar /sidecar

RUN apk update && apk add curl bind-tools

Expand Down
24 changes: 12 additions & 12 deletions test/e2e/docker-run-e2e.sh → test/e2e/sidecar/docker-run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Docker side of the E2E test for dnsmasq-metrics. This runs an
# instance of dnsmasq and dnsmasq-metrics, sends some DNS queries to
# Docker side of the E2E test for sidecar. This runs an
# instance of dnsmasq and sidecar, sends some DNS queries to
# the daemon and dumps the output of the prometheus /metrics URI.
run() {
echo RUN "$@"
"$@"
}

dnsmasq="/usr/sbin/dnsmasq"
dnsmasq_metrics="/dnsmasq-metrics"
sidecar="/sidecar"
dnsmasq_port=10053

dig_out="/tmp/dig.out"
dnsmasq_out="/tmp/dnsmasq.out"
dnsmasq_metrics_out="/tmp/dnsmasq_metrics.out"
sidecar_out="/tmp/sidecar.out"
metrics_out="/tmp/metrics.out"

curl="/usr/bin/curl"
Expand All @@ -47,14 +47,14 @@ run ${dnsmasq} \
dnsmasq_pid=$!
echo "dnsmasq_pid=${dnsmasq_pid}"

run ${dnsmasq_metrics} \
run ${sidecar} \
--dnsmasq-port ${dnsmasq_port} -v 4 \
--probe "ok,127.0.0.1:${dnsmasq_port},ok.local,1" \
--probe "nxdomain,127.0.0.1:${dnsmasq_port},nx.local,1" \
--probe "notpresent,127.0.0.1:$((dnsmasq_port + 1)),notpresent.local,1" \
2> ${dnsmasq_metrics_out} &
dnsmasq_metrics_pid=$!
echo "dnsmasq_metrics_pid=${dnsmasq_metrics_pid}"
2> ${sidecar_out} &
sidecar_pid=$!
echo "sidecar_pid=${sidecar_pid}"

# Do a bunch of digs to make sure the cache is hit.
for i in `seq 100`; do
Expand All @@ -63,7 +63,7 @@ done

kill -SIGUSR1 ${dnsmasq_pid}

# Give dnsmasq_metrics some time to updates its metrics.
# Give sidecar some time to updates its metrics.
echo "Waiting ${sleep_interval} seconds"
sleep ${sleep_interval}

Expand All @@ -79,9 +79,9 @@ echo "BEGIN dnsmasq ===="
cat ${dnsmasq_out}
echo "END dnsmasq ===="
echo
echo "BEGIN dnsmasq_metrics ===="
cat ${dnsmasq_metrics_out}
echo "END dnsmasq_metrics ===="
echo "BEGIN sidecar ===="
cat ${sidecar_out}
echo "END sidecar ===="
echo
echo "BEGIN metrics ===="
cat ${metrics_out}
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/e2e.sh → test/e2e/sidecar/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ if ! which awk >/dev/null; then
exit 1
fi

if [ ! -e bin/amd64/dnsmasq-metrics ]; then
echo "dnsmasq-metrics not found (need to build?)"
if [ ! -e "bin/amd64/sidecar" ]; then
echo "binary not found (need to build?)"
exit 1
fi

uuid=`date +%s`
image_tag="kubernetes-contrib-dnsmasq-metrics-e2e-${uuid}"
image_tag="k8s-dns-sidecar-e2e-${uuid}"
output_dir=`mktemp -d`
e2e_dir=test/e2e
e2e_dir=test/e2e/sidecar

if [ "$CLEANUP" != 'no' ]; then
cleanup() {
Expand Down

0 comments on commit 631bd46

Please sign in to comment.