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

Enable and fix carbon and graphite docker integration test #1319

Merged
merged 1 commit into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ docker-integration-test:
@./scripts/docker-integration-tests/setup.sh
@./scripts/docker-integration-tests/simple/test.sh
@./scripts/docker-integration-tests/prometheus/test.sh
# TODO(rartoul): Re-enable once the query P.R lands and we can fix this test.
# @./scripts/docker-integration-tests/carbon/test.sh
@./scripts/docker-integration-tests/carbon/test.sh

.PHONY: site-build
site-build:
Expand Down
5 changes: 4 additions & 1 deletion scripts/development/m3_stack/m3coordinator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ ingest:
logSampleRate: 0.01
m3msg:
server:
listenAddress: 0.0.0.0:7507
listenAddress: "0.0.0.0:7507"
retry:
maxBackoff: 10s
jitter: true
handler:
protobufEnabled: true

carbon:
ingester:
listenAddress: "0.0.0.0:7204"
3 changes: 2 additions & 1 deletion scripts/docker-integration-tests/carbon/m3coordinator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ clusters:
backgroundHealthCheckFailThrottleFactor: 0.5

carbon:
enabled: true
ingester:
listenAddress: "0.0.0.0:7204"
8 changes: 4 additions & 4 deletions scripts/docker-integration-tests/carbon/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ trap defer EXIT
setup_single_m3db_node

echo "Writing out a carbon metric"
echo "foo.bar.baz 1 `date +%s`" | nc 0.0.0.0 7204
echo "foo.bar.baz 42 `date +%s`" | nc 0.0.0.0 7204

echo "Attempting to read carbon metric back"
function read_carbon {
end=$(date +%s)
start=$(($end-3000))
RESPONSE=$(curl -sSfg "http://localhost:7201/api/v1/query_range?start=$start&end=$end&step=10&query={__g0__='foo',__g1__='bar',__g2__='baz'}")
echo "$RESPONSE" | jq '.data.result[0].values[][1]=="1"' | grep -q "true"
start=$(($end-1000))
RESPONSE=$(curl -sSfg "http://localhost:7201/api/v1/graphite/render?target=foo.bar.*&from=$start&until=$end")
test "$(echo "$RESPONSE" | jq ".[0].datapoints | .[][0] | select(. != null)" | tail -n 1)" = "42"
return $?
}
ATTEMPTS=10 TIMEOUT=1 retry_with_backoff read_carbon
7 changes: 4 additions & 3 deletions scripts/docker-integration-tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ function setup_single_m3db_node {
}

function wait_for_db_init {
echo "Sleeping for a bit to ensure db up"
sleep 15 # TODO Replace sleeps with logic to determine when to proceed
echo "Wait for API to be available"
ATTEMPTS=10 TIMEOUT=2 retry_with_backoff \
'[ "$(curl -sSf 0.0.0.0:7201/api/v1/namespace | jq ".namespaces | length")" == "0" ]'

echo "Adding namespace"
curl -vvvsSf -X POST 0.0.0.0:7201/api/v1/namespace -d '{
Expand All @@ -70,7 +71,7 @@ function wait_for_db_init {
}
}'

echo "Sleep until namespace is init'd"
echo "Wait until namespace is init'd"
ATTEMPTS=4 TIMEOUT=1 retry_with_backoff \
'[ "$(curl -sSf 0.0.0.0:7201/api/v1/namespace | jq .registry.namespaces.agg.indexOptions.enabled)" == true ]'

Expand Down
48 changes: 13 additions & 35 deletions src/cmd/services/m3query/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ const (
)

var (
defaultCarbonIngesterTimeout = 5 * time.Second
defaultCarbonIngesterEnabled = true
defaultCarbonIngesterWriteTimeout = 15 * time.Second

// defaultLimitsConfiguration is applied if `limits` isn't specified.
defaultLimitsConfiguration = &LimitsConfiguration{
Expand Down Expand Up @@ -102,7 +101,7 @@ type Configuration struct {
Ingest *IngestConfiguration `yaml:"ingest"`

// Carbon is the carbon configuration.
Carbon CarbonConfiguration `yaml:"carbon"`
Carbon *CarbonConfiguration `yaml:"carbon"`

// Limits specifies limits on per-query resource usage.
Limits LimitsConfiguration `yaml:"limits"`
Expand Down Expand Up @@ -145,45 +144,24 @@ type IngestConfiguration struct {

// CarbonConfiguration is the configuration for the carbon server.
type CarbonConfiguration struct {
Ingestion CarbonIngestionConfiguration
Ingester *CarbonIngesterConfiguration `yaml:"ingester"`
}

// CarbonIngestionConfiguration is the configuration struct for carbon ingestion.
type CarbonIngestionConfiguration struct {
Enabled *bool `yaml:"enabled"`
MaxConcurrency int `yaml:"maxConcurrency"`
// CarbonIngesterConfiguration is the configuration struct for carbon ingestion.
type CarbonIngesterConfiguration struct {
ListenAddress string `yaml:"listenAddress"`
Timeout *time.Duration `yaml:"timeout"`
}

// EnabledOrDefault returns the configured value for Enabled, if set, or the default
// value otherwise.
func (c *CarbonIngestionConfiguration) EnabledOrDefault() bool {
if c.Enabled != nil {
return *c.Enabled
}

return defaultCarbonIngesterEnabled
}

// TimeoutOrDefault returns the configured value for Timeout, if set, or the default
// value otherwise.
func (c *CarbonIngestionConfiguration) TimeoutOrDefault() time.Duration {
if c.Timeout != nil {
return *c.Timeout
}

return defaultCarbonIngesterTimeout
MaxConcurrency int `yaml:"maxConcurrency"`
WriteTimeout *time.Duration `yaml:"writeTimeout"`
}

// ListenAddressOrDefault returns the configured value for ListenAddress, if set, or the default
// value otherwise.
func (c *CarbonIngestionConfiguration) ListenAddressOrDefault() string {
if c.ListenAddress != "" {
return c.ListenAddress
// WriteTimeoutOrDefault returns the configured value for the write timeout,
// if set, or the default value otherwise.
func (c *CarbonIngesterConfiguration) WriteTimeoutOrDefault() time.Duration {
if c.WriteTimeout != nil {
return *c.WriteTimeout
}

return defaultCarbonIngesterListenAddress
return defaultCarbonIngesterWriteTimeout
}

// LocalConfiguration is the local embedded configuration if running
Expand Down
16 changes: 10 additions & 6 deletions src/query/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"net/http"
"os"
"os/signal"
"strings"
"syscall"
"time"

Expand Down Expand Up @@ -267,8 +268,8 @@ func Run(runOpts RunOptions) {
logger.Info("no m3msg server configured")
}

carbonIngestConfig := cfg.Carbon.Ingestion
if carbonIngestConfig.EnabledOrDefault() {
if cfg.Carbon != nil && cfg.Carbon.Ingester != nil {
ingesterCfg := cfg.Carbon.Ingester
logger.Info("carbon ingestion enabled")

var (
Expand All @@ -277,12 +278,12 @@ func Run(runOpts RunOptions) {
carbonWorkerPoolOpts xsync.PooledWorkerPoolOptions
carbonWorkerPoolSize int
)
if carbonIngestConfig.MaxConcurrency > 0 {
if ingesterCfg.MaxConcurrency > 0 {
// Use a bounded worker pool if they requested a specific maximum concurrency.
carbonWorkerPoolOpts = xsync.NewPooledWorkerPoolOptions().
SetGrowOnDemand(false).
SetInstrumentOptions(carbonIOpts)
carbonWorkerPoolSize = carbonIngestConfig.MaxConcurrency
carbonWorkerPoolSize = ingesterCfg.MaxConcurrency
} else {
carbonWorkerPoolOpts = xsync.NewPooledWorkerPoolOptions().
SetGrowOnDemand(true).
Expand All @@ -301,17 +302,20 @@ func Run(runOpts RunOptions) {
ingester, err := ingestcarbon.NewIngester(carbonIngestDownsamplerAndWriter, ingestcarbon.Options{
InstrumentOptions: carbonIOpts,
WorkerPool: workerPool,
Timeout: carbonIngestConfig.TimeoutOrDefault(),
Timeout: ingesterCfg.WriteTimeoutOrDefault(),
})
if err != nil {
logger.Fatal("unable to create carbon ingester", zap.Error(err))
}

var (
serverOpts = xserver.NewOptions().SetInstrumentOptions(carbonIOpts)
carbonListenAddress = carbonIngestConfig.ListenAddressOrDefault()
carbonListenAddress = ingesterCfg.ListenAddress
carbonServer = xserver.NewServer(carbonListenAddress, ingester, serverOpts)
)
if strings.TrimSpace(carbonListenAddress) == "" {
logger.Fatal("no listen address specified for carbon ingester")
}

logger.Info("starting carbon ingestion server", zap.String("listenAddress", carbonListenAddress))
err = carbonServer.ListenAndServe()
Expand Down
2 changes: 1 addition & 1 deletion src/query/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ listenAddress:
value: "127.0.0.1:17201"

carbon:
ingestion:
ingester:
listenAddress: "127.0.0.1:17204"

metrics:
Expand Down