From d6b1fcdb5257ecb1f2a6b7577e3b5e8dcaaa3791 Mon Sep 17 00:00:00 2001 From: Jay Batra Date: Sun, 15 Mar 2020 02:46:00 +0530 Subject: [PATCH 1/2] Removes all the occurences of omitempty(cortexproject#2209) This PR removes all the occurences of omitempty from structs. Signed-off by Jay Batra Signed-off-by: Jay Batra --- CHANGELOG.md | 1 + pkg/chunk/cache/background.go | 4 +-- pkg/chunk/cache/cache.go | 16 +++++----- pkg/chunk/cache/fifo_cache.go | 4 +-- pkg/chunk/cache/memcached.go | 6 ++-- pkg/chunk/cache/memcached_client.go | 12 +++---- pkg/chunk/cache/redis_cache.go | 10 +++--- pkg/chunk/cassandra/storage_client.go | 30 ++++++++--------- pkg/chunk/chunk_store.go | 6 ++-- pkg/chunk/schema_config.go | 16 +++++----- pkg/chunk/storage/factory.go | 4 +-- pkg/compactor/compactor_ring.go | 6 ++-- pkg/cortex/cortex.go | 46 +++++++++++++-------------- pkg/distributor/distributor.go | 12 +++---- pkg/distributor/distributor_ring.go | 6 ++-- pkg/distributor/ha_tracker.go | 2 +- pkg/flusher/flusher.go | 6 ++-- pkg/ingester/client/pool.go | 4 +-- pkg/ingester/ingester.go | 6 ++-- pkg/ingester/wal.go | 10 +++--- pkg/ring/kv/client.go | 10 +++--- pkg/ring/lifecycler.go | 2 +- pkg/ring/ring.go | 6 ++-- pkg/ruler/api.go | 14 ++++---- pkg/ruler/legacy_rulefmt/rulefmt.go | 12 +++---- pkg/ruler/ruler_ring.go | 6 ++-- 26 files changed, 129 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54dada4fd5..f48338fde9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * [ENHANCEMENT] Experimental TSDB: Add support for local `filesystem` backend. #2245 * [ENHANCEMENT] Allow 1w (where w denotes week) and 1y (where y denotes year) when setting table period and retention. #2252 * [ENHANCEMENT] Added FIFO cache metrics for current number of entries and memory usage. #2270 +* [ENHANCEMENT] Output all config fields to /config API, including those with empty value". #2209 * [BUGFIX] Fixed etcd client keepalive settings. #2278 * [BUGFIX] Fixed bug in updating last element of FIFO cache. #2270 diff --git a/pkg/chunk/cache/background.go b/pkg/chunk/cache/background.go index 861d7e8160..5b101e4a4c 100644 --- a/pkg/chunk/cache/background.go +++ b/pkg/chunk/cache/background.go @@ -26,8 +26,8 @@ var ( // BackgroundConfig is config for a Background Cache. type BackgroundConfig struct { - WriteBackGoroutines int `yaml:"writeback_goroutines,omitempty"` - WriteBackBuffer int `yaml:"writeback_buffer,omitempty"` + WriteBackGoroutines int `yaml:"writeback_goroutines"` + WriteBackBuffer int `yaml:"writeback_buffer"` } // RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet diff --git a/pkg/chunk/cache/cache.go b/pkg/chunk/cache/cache.go index 5f2d0a4642..76f0eac4c9 100644 --- a/pkg/chunk/cache/cache.go +++ b/pkg/chunk/cache/cache.go @@ -22,18 +22,18 @@ type Cache interface { // Config for building Caches. type Config struct { - EnableFifoCache bool `yaml:"enable_fifocache,omitempty"` + EnableFifoCache bool `yaml:"enable_fifocache"` - DefaultValidity time.Duration `yaml:"default_validity,omitempty"` + DefaultValidity time.Duration `yaml:"default_validity"` - Background BackgroundConfig `yaml:"background,omitempty"` - Memcache MemcachedConfig `yaml:"memcached,omitempty"` - MemcacheClient MemcachedClientConfig `yaml:"memcached_client,omitempty"` - Redis RedisConfig `yaml:"redis,omitempty"` - Fifocache FifoCacheConfig `yaml:"fifocache,omitempty"` + Background BackgroundConfig `yaml:"background"` + Memcache MemcachedConfig `yaml:"memcached"` + MemcacheClient MemcachedClientConfig `yaml:"memcached_client"` + Redis RedisConfig `yaml:"redis"` + Fifocache FifoCacheConfig `yaml:"fifocache"` // This is to name the cache metrics properly. - Prefix string `yaml:"prefix,omitempty" doc:"hidden"` + Prefix string `yaml:"prefix" doc:"hidden"` // For tests to inject specific implementations. Cache Cache `yaml:"-"` diff --git a/pkg/chunk/cache/fifo_cache.go b/pkg/chunk/cache/fifo_cache.go index 9eb3cd87ec..ef2c6a3a9a 100644 --- a/pkg/chunk/cache/fifo_cache.go +++ b/pkg/chunk/cache/fifo_cache.go @@ -71,8 +71,8 @@ var ( // FifoCacheConfig holds config for the FifoCache. type FifoCacheConfig struct { - Size int `yaml:"size,omitempty"` - Validity time.Duration `yaml:"validity,omitempty"` + Size int `yaml:"size"` + Validity time.Duration `yaml:"validity"` } // RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet diff --git a/pkg/chunk/cache/memcached.go b/pkg/chunk/cache/memcached.go index 09f4f76b0f..3319110e97 100644 --- a/pkg/chunk/cache/memcached.go +++ b/pkg/chunk/cache/memcached.go @@ -41,10 +41,10 @@ func (o observableVecCollector) After(method, statusCode string, start time.Time // MemcachedConfig is config to make a Memcached type MemcachedConfig struct { - Expiration time.Duration `yaml:"expiration,omitempty"` + Expiration time.Duration `yaml:"expiration"` - BatchSize int `yaml:"batch_size,omitempty"` - Parallelism int `yaml:"parallelism,omitempty"` + BatchSize int `yaml:"batch_size"` + Parallelism int `yaml:"parallelism"` } // RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet diff --git a/pkg/chunk/cache/memcached_client.go b/pkg/chunk/cache/memcached_client.go index 2712a584bc..8501e3d7cf 100644 --- a/pkg/chunk/cache/memcached_client.go +++ b/pkg/chunk/cache/memcached_client.go @@ -39,12 +39,12 @@ type memcachedClient struct { // MemcachedClientConfig defines how a MemcachedClient should be constructed. type MemcachedClientConfig struct { - Host string `yaml:"host,omitempty"` - Service string `yaml:"service,omitempty"` - Timeout time.Duration `yaml:"timeout,omitempty"` - MaxIdleConns int `yaml:"max_idle_conns,omitempty"` - UpdateInterval time.Duration `yaml:"update_interval,omitempty"` - ConsistentHash bool `yaml:"consistent_hash,omitempty"` + Host string `yaml:"host"` + Service string `yaml:"service"` + Timeout time.Duration `yaml:"timeout"` + MaxIdleConns int `yaml:"max_idle_conns"` + UpdateInterval time.Duration `yaml:"update_interval"` + ConsistentHash bool `yaml:"consistent_hash"` } // RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet diff --git a/pkg/chunk/cache/redis_cache.go b/pkg/chunk/cache/redis_cache.go index 7ab48d2c67..e8a9fc9134 100644 --- a/pkg/chunk/cache/redis_cache.go +++ b/pkg/chunk/cache/redis_cache.go @@ -22,11 +22,11 @@ type RedisCache struct { // RedisConfig defines how a RedisCache should be constructed. type RedisConfig struct { - Endpoint string `yaml:"endpoint,omitempty"` - Timeout time.Duration `yaml:"timeout,omitempty"` - Expiration time.Duration `yaml:"expiration,omitempty"` - MaxIdleConns int `yaml:"max_idle_conns,omitempty"` - MaxActiveConns int `yaml:"max_active_conns,omitempty"` + Endpoint string `yaml:"endpoint"` + Timeout time.Duration `yaml:"timeout"` + Expiration time.Duration `yaml:"expiration"` + MaxIdleConns int `yaml:"max_idle_conns"` + MaxActiveConns int `yaml:"max_active_conns"` Password flagext.Secret `yaml:"password"` EnableTLS bool `yaml:"enable_tls"` } diff --git a/pkg/chunk/cassandra/storage_client.go b/pkg/chunk/cassandra/storage_client.go index f3aac2f86f..3c2e6f4071 100644 --- a/pkg/chunk/cassandra/storage_client.go +++ b/pkg/chunk/cassandra/storage_client.go @@ -19,22 +19,22 @@ import ( // Config for a StorageClient type Config struct { - Addresses string `yaml:"addresses,omitempty"` - Port int `yaml:"port,omitempty"` - Keyspace string `yaml:"keyspace,omitempty"` - Consistency string `yaml:"consistency,omitempty"` - ReplicationFactor int `yaml:"replication_factor,omitempty"` - DisableInitialHostLookup bool `yaml:"disable_initial_host_lookup,omitempty"` - SSL bool `yaml:"SSL,omitempty"` - HostVerification bool `yaml:"host_verification,omitempty"` - CAPath string `yaml:"CA_path,omitempty"` - Auth bool `yaml:"auth,omitempty"` - Username string `yaml:"username,omitempty"` - Password flagext.Secret `yaml:"password,omitempty"` - PasswordFile string `yaml:"password_file,omitempty"` + Addresses string `yaml:"addresses"` + Port int `yaml:"port"` + Keyspace string `yaml:"keyspace"` + Consistency string `yaml:"consistency"` + ReplicationFactor int `yaml:"replication_factor"` + DisableInitialHostLookup bool `yaml:"disable_initial_host_lookup"` + SSL bool `yaml:"SSL"` + HostVerification bool `yaml:"host_verification"` + CAPath string `yaml:"CA_path"` + Auth bool `yaml:"auth"` + Username string `yaml:"username"` + Password flagext.Secret `yaml:"password"` + PasswordFile string `yaml:"password_file"` CustomAuthenticators flagext.StringSlice `yaml:"custom_authenticators"` - Timeout time.Duration `yaml:"timeout,omitempty"` - ConnectTimeout time.Duration `yaml:"connect_timeout,omitempty"` + Timeout time.Duration `yaml:"timeout"` + ConnectTimeout time.Duration `yaml:"connect_timeout"` Retries int `yaml:"max_retries"` MaxBackoff time.Duration `yaml:"retry_max_backoff"` MinBackoff time.Duration `yaml:"retry_min_backoff"` diff --git a/pkg/chunk/chunk_store.go b/pkg/chunk/chunk_store.go index 2f9b95e78a..9080d0a86a 100644 --- a/pkg/chunk/chunk_store.go +++ b/pkg/chunk/chunk_store.go @@ -47,10 +47,10 @@ var ( // StoreConfig specifies config for a ChunkStore type StoreConfig struct { - ChunkCacheConfig cache.Config `yaml:"chunk_cache_config,omitempty"` - WriteDedupeCacheConfig cache.Config `yaml:"write_dedupe_cache_config,omitempty"` + ChunkCacheConfig cache.Config `yaml:"chunk_cache_config"` + WriteDedupeCacheConfig cache.Config `yaml:"write_dedupe_cache_config"` - CacheLookupsOlderThan time.Duration `yaml:"cache_lookups_older_than,omitempty"` + CacheLookupsOlderThan time.Duration `yaml:"cache_lookups_older_than"` // Limits query start time to be greater than now() - MaxLookBackPeriod, if set. MaxLookBackPeriod time.Duration `yaml:"max_look_back_period"` diff --git a/pkg/chunk/schema_config.go b/pkg/chunk/schema_config.go index d98f361cb9..bce069604d 100644 --- a/pkg/chunk/schema_config.go +++ b/pkg/chunk/schema_config.go @@ -36,7 +36,7 @@ type PeriodConfig struct { ObjectType string `yaml:"object_store"` // type of object client to use; if omitted, defaults to store. Schema string `yaml:"schema"` IndexTables PeriodicTableConfig `yaml:"index"` - ChunkTables PeriodicTableConfig `yaml:"chunks,omitempty"` + ChunkTables PeriodicTableConfig `yaml:"chunks"` RowShards uint32 `yaml:"row_shards"` } @@ -330,13 +330,13 @@ func (cfg PeriodicTableConfig) MarshalYAML() (interface{}, error) { // AutoScalingConfig for DynamoDB tables. type AutoScalingConfig struct { - Enabled bool `yaml:"enabled,omitempty"` - RoleARN string `yaml:"role_arn,omitempty"` - MinCapacity int64 `yaml:"min_capacity,omitempty"` - MaxCapacity int64 `yaml:"max_capacity,omitempty"` - OutCooldown int64 `yaml:"out_cooldown,omitempty"` - InCooldown int64 `yaml:"in_cooldown,omitempty"` - TargetValue float64 `yaml:"target,omitempty"` + Enabled bool `yaml:"enabled"` + RoleARN string `yaml:"role_arn"` + MinCapacity int64 `yaml:"min_capacity"` + MaxCapacity int64 `yaml:"max_capacity"` + OutCooldown int64 `yaml:"out_cooldown"` + InCooldown int64 `yaml:"in_cooldown"` + TargetValue float64 `yaml:"target"` } // RegisterFlags adds the flags required to config this to the given FlagSet. diff --git a/pkg/chunk/storage/factory.go b/pkg/chunk/storage/factory.go index e46fffee3d..23bc186198 100644 --- a/pkg/chunk/storage/factory.go +++ b/pkg/chunk/storage/factory.go @@ -61,9 +61,9 @@ type Config struct { IndexCacheValidity time.Duration - IndexQueriesCacheConfig cache.Config `yaml:"index_queries_cache_config,omitempty"` + IndexQueriesCacheConfig cache.Config `yaml:"index_queries_cache_config"` - DeleteStoreConfig purger.DeleteStoreConfig `yaml:"delete_store,omitempty"` + DeleteStoreConfig purger.DeleteStoreConfig `yaml:"delete_store"` } // RegisterFlags adds the flags required to configure this flag set. diff --git a/pkg/compactor/compactor_ring.go b/pkg/compactor/compactor_ring.go index 379db16f1c..6caa4bd501 100644 --- a/pkg/compactor/compactor_ring.go +++ b/pkg/compactor/compactor_ring.go @@ -18,9 +18,9 @@ import ( // is used to strip down the config to the minimum, and avoid confusion // to the user. type RingConfig struct { - KVStore kv.Config `yaml:"kvstore,omitempty"` - HeartbeatPeriod time.Duration `yaml:"heartbeat_period,omitempty"` - HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout,omitempty"` + KVStore kv.Config `yaml:"kvstore"` + HeartbeatPeriod time.Duration `yaml:"heartbeat_period"` + HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"` // Instance details InstanceID string `yaml:"instance_id" doc:"hidden"` diff --git a/pkg/cortex/cortex.go b/pkg/cortex/cortex.go index 1797244881..0a4a887b75 100644 --- a/pkg/cortex/cortex.go +++ b/pkg/cortex/cortex.go @@ -65,35 +65,35 @@ import ( // Config is the root config for Cortex. type Config struct { - Target moduleName `yaml:"target,omitempty"` - AuthEnabled bool `yaml:"auth_enabled,omitempty"` + Target moduleName `yaml:"target"` + AuthEnabled bool `yaml:"auth_enabled"` PrintConfig bool `yaml:"-"` HTTPPrefix string `yaml:"http_prefix"` - Server server.Config `yaml:"server,omitempty"` - Distributor distributor.Config `yaml:"distributor,omitempty"` - Querier querier.Config `yaml:"querier,omitempty"` - IngesterClient client.Config `yaml:"ingester_client,omitempty"` - Ingester ingester.Config `yaml:"ingester,omitempty"` - Flusher flusher.Config `yaml:"flusher,omitempty"` - Storage storage.Config `yaml:"storage,omitempty"` - ChunkStore chunk.StoreConfig `yaml:"chunk_store,omitempty"` - Schema chunk.SchemaConfig `yaml:"schema,omitempty" doc:"hidden"` // Doc generation tool doesn't support it because part of the SchemaConfig doesn't support CLI flags (needs manual documentation) - LimitsConfig validation.Limits `yaml:"limits,omitempty"` - Prealloc client.PreallocConfig `yaml:"prealloc,omitempty" doc:"hidden"` - Worker frontend.WorkerConfig `yaml:"frontend_worker,omitempty"` - Frontend frontend.Config `yaml:"frontend,omitempty"` - QueryRange queryrange.Config `yaml:"query_range,omitempty"` - TableManager chunk.TableManagerConfig `yaml:"table_manager,omitempty"` + Server server.Config `yaml:"server"` + Distributor distributor.Config `yaml:"distributor"` + Querier querier.Config `yaml:"querier"` + IngesterClient client.Config `yaml:"ingester_client"` + Ingester ingester.Config `yaml:"ingester"` + Flusher flusher.Config `yaml:"flusher"` + Storage storage.Config `yaml:"storage"` + ChunkStore chunk.StoreConfig `yaml:"chunk_store"` + Schema chunk.SchemaConfig `yaml:"schema" doc:"hidden"` // Doc generation tool doesn't support it because part of the SchemaConfig doesn't support CLI flags (needs manual documentation) + LimitsConfig validation.Limits `yaml:"limits"` + Prealloc client.PreallocConfig `yaml:"prealloc" doc:"hidden"` + Worker frontend.WorkerConfig `yaml:"frontend_worker"` + Frontend frontend.Config `yaml:"frontend"` + QueryRange queryrange.Config `yaml:"query_range"` + TableManager chunk.TableManagerConfig `yaml:"table_manager"` Encoding encoding.Config `yaml:"-"` // No yaml for this, it only works with flags. TSDB tsdb.Config `yaml:"tsdb"` - Compactor compactor.Config `yaml:"compactor,omitempty"` - DataPurgerConfig purger.Config `yaml:"purger,omitempty"` + Compactor compactor.Config `yaml:"compactor"` + DataPurgerConfig purger.Config `yaml:"purger"` - Ruler ruler.Config `yaml:"ruler,omitempty"` - Configs configs.Config `yaml:"configs,omitempty"` - Alertmanager alertmanager.MultitenantAlertmanagerConfig `yaml:"alertmanager,omitempty"` - RuntimeConfig runtimeconfig.ManagerConfig `yaml:"runtime_config,omitempty"` + Ruler ruler.Config `yaml:"ruler"` + Configs configs.Config `yaml:"configs"` + Alertmanager alertmanager.MultitenantAlertmanagerConfig `yaml:"alertmanager"` + RuntimeConfig runtimeconfig.ManagerConfig `yaml:"runtime_config"` MemberlistKV memberlist.KVConfig `yaml:"memberlist"` } diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index 45e3cb1dff..edaa25f085 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -120,18 +120,18 @@ type Distributor struct { // Config contains the configuration require to // create a Distributor type Config struct { - PoolConfig ingester_client.PoolConfig `yaml:"pool,omitempty"` + PoolConfig ingester_client.PoolConfig `yaml:"pool"` - HATrackerConfig HATrackerConfig `yaml:"ha_tracker,omitempty"` + HATrackerConfig HATrackerConfig `yaml:"ha_tracker"` MaxRecvMsgSize int `yaml:"max_recv_msg_size"` - RemoteTimeout time.Duration `yaml:"remote_timeout,omitempty"` - ExtraQueryDelay time.Duration `yaml:"extra_queue_delay,omitempty"` + RemoteTimeout time.Duration `yaml:"remote_timeout"` + ExtraQueryDelay time.Duration `yaml:"extra_queue_delay"` - ShardByAllLabels bool `yaml:"shard_by_all_labels,omitempty"` + ShardByAllLabels bool `yaml:"shard_by_all_labels"` // Distributors ring - DistributorRing RingConfig `yaml:"ring,omitempty"` + DistributorRing RingConfig `yaml:"ring"` // for testing ingesterClientFactory client.Factory `yaml:"-"` diff --git a/pkg/distributor/distributor_ring.go b/pkg/distributor/distributor_ring.go index fc6e4422b5..3251cdc7c4 100644 --- a/pkg/distributor/distributor_ring.go +++ b/pkg/distributor/distributor_ring.go @@ -18,9 +18,9 @@ import ( // is used to strip down the config to the minimum, and avoid confusion // to the user. type RingConfig struct { - KVStore kv.Config `yaml:"kvstore,omitempty"` - HeartbeatPeriod time.Duration `yaml:"heartbeat_period,omitempty"` - HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout,omitempty"` + KVStore kv.Config `yaml:"kvstore"` + HeartbeatPeriod time.Duration `yaml:"heartbeat_period"` + HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"` // Instance details InstanceID string `yaml:"instance_id" doc:"hidden"` diff --git a/pkg/distributor/ha_tracker.go b/pkg/distributor/ha_tracker.go index 363f16f8da..5f664c9c53 100644 --- a/pkg/distributor/ha_tracker.go +++ b/pkg/distributor/ha_tracker.go @@ -82,7 +82,7 @@ type haTracker struct { // HATrackerConfig contains the configuration require to // create a HA Tracker. type HATrackerConfig struct { - EnableHATracker bool `yaml:"enable_ha_tracker,omitempty"` + EnableHATracker bool `yaml:"enable_ha_tracker"` // We should only update the timestamp if the difference // between the stored timestamp and the time we received a sample at // is more than this duration. diff --git a/pkg/flusher/flusher.go b/pkg/flusher/flusher.go index 454d26bcb4..b9d101be93 100644 --- a/pkg/flusher/flusher.go +++ b/pkg/flusher/flusher.go @@ -17,9 +17,9 @@ import ( // Config for an Ingester. type Config struct { - WALDir string `yaml:"wal_dir,omitempty"` - ConcurrentFlushes int `yaml:"concurrent_flushes,omitempty"` - FlushOpTimeout time.Duration `yaml:"flush_op_timeout,omitempty"` + WALDir string `yaml:"wal_dir"` + ConcurrentFlushes int `yaml:"concurrent_flushes"` + FlushOpTimeout time.Duration `yaml:"flush_op_timeout"` } // RegisterFlags adds the flags required to config this to the given FlagSet diff --git a/pkg/ingester/client/pool.go b/pkg/ingester/client/pool.go index 70d55f09d2..b6aad69de3 100644 --- a/pkg/ingester/client/pool.go +++ b/pkg/ingester/client/pool.go @@ -31,8 +31,8 @@ type Factory func(addr string) (grpc_health_v1.HealthClient, error) // PoolConfig is config for creating a Pool. type PoolConfig struct { - ClientCleanupPeriod time.Duration `yaml:"client_cleanup_period,omitempty"` - HealthCheckIngesters bool `yaml:"health_check_ingesters,omitempty"` + ClientCleanupPeriod time.Duration `yaml:"client_cleanup_period"` + HealthCheckIngesters bool `yaml:"health_check_ingesters"` RemoteTimeout time.Duration `yaml:"-"` } diff --git a/pkg/ingester/ingester.go b/pkg/ingester/ingester.go index 1aa500abd9..d0b5038ab2 100644 --- a/pkg/ingester/ingester.go +++ b/pkg/ingester/ingester.go @@ -41,11 +41,11 @@ var ( // Config for an Ingester. type Config struct { - WALConfig WALConfig `yaml:"walconfig,omitempty"` - LifecyclerConfig ring.LifecyclerConfig `yaml:"lifecycler,omitempty"` + WALConfig WALConfig `yaml:"walconfig"` + LifecyclerConfig ring.LifecyclerConfig `yaml:"lifecycler"` // Config for transferring chunks. Zero or negative = no retries. - MaxTransferRetries int `yaml:"max_transfer_retries,omitempty"` + MaxTransferRetries int `yaml:"max_transfer_retries"` // Config for chunk flushing. FlushCheckPeriod time.Duration diff --git a/pkg/ingester/wal.go b/pkg/ingester/wal.go index e7e73b52f0..e3d874753c 100644 --- a/pkg/ingester/wal.go +++ b/pkg/ingester/wal.go @@ -29,11 +29,11 @@ import ( // WALConfig is config for the Write Ahead Log. type WALConfig struct { - WALEnabled bool `yaml:"wal_enabled,omitempty"` - CheckpointEnabled bool `yaml:"checkpoint_enabled,omitempty"` - Recover bool `yaml:"recover_from_wal,omitempty"` - Dir string `yaml:"wal_dir,omitempty"` - CheckpointDuration time.Duration `yaml:"checkpoint_duration,omitempty"` + WALEnabled bool `yaml:"wal_enabled"` + CheckpointEnabled bool `yaml:"checkpoint_enabled"` + Recover bool `yaml:"recover_from_wal"` + Dir string `yaml:"wal_dir"` + CheckpointDuration time.Duration `yaml:"checkpoint_duration"` metricsRegisterer prometheus.Registerer `yaml:"-"` } diff --git a/pkg/ring/kv/client.go b/pkg/ring/kv/client.go index 1c729fe15d..f18fb455d7 100644 --- a/pkg/ring/kv/client.go +++ b/pkg/ring/kv/client.go @@ -22,9 +22,9 @@ var inmemoryStore Client // Consul, Etcd, Memberlist or MultiClient. It was extracted from Config to keep // single-client config separate from final client-config (with all the wrappers) type StoreConfig struct { - Consul consul.Config `yaml:"consul,omitempty"` - Etcd etcd.Config `yaml:"etcd,omitempty"` - Multi MultiConfig `yaml:"multi,omitempty"` + Consul consul.Config `yaml:"consul"` + Etcd etcd.Config `yaml:"etcd"` + Multi MultiConfig `yaml:"multi"` // Function that returns memberlist.KV store to use. By using a function, we can delay // initialization of memberlist.KV until it is actually required. @@ -34,8 +34,8 @@ type StoreConfig struct { // Config is config for a KVStore currently used by ring and HA tracker, // where store can be consul or inmemory. type Config struct { - Store string `yaml:"store,omitempty"` - Prefix string `yaml:"prefix,omitempty"` + Store string `yaml:"store"` + Prefix string `yaml:"prefix"` StoreConfig `yaml:",inline"` Mock Client `yaml:"-"` diff --git a/pkg/ring/lifecycler.go b/pkg/ring/lifecycler.go index 62d6ca6352..2d805565c9 100644 --- a/pkg/ring/lifecycler.go +++ b/pkg/ring/lifecycler.go @@ -43,7 +43,7 @@ var ( // LifecyclerConfig is the config to build a Lifecycler. type LifecyclerConfig struct { - RingConfig Config `yaml:"ring,omitempty"` + RingConfig Config `yaml:"ring"` // Config for the ingester lifecycle control ListenPort *int `yaml:"-"` diff --git a/pkg/ring/ring.go b/pkg/ring/ring.go index 9005f4ad85..06568c0f26 100644 --- a/pkg/ring/ring.go +++ b/pkg/ring/ring.go @@ -65,9 +65,9 @@ var ErrEmptyRing = errors.New("empty ring") // Config for a Ring type Config struct { - KVStore kv.Config `yaml:"kvstore,omitempty"` - HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout,omitempty"` - ReplicationFactor int `yaml:"replication_factor,omitempty"` + KVStore kv.Config `yaml:"kvstore"` + HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"` + ReplicationFactor int `yaml:"replication_factor"` } // RegisterFlags adds the flags required to config this to the given FlagSet with a specified prefix diff --git a/pkg/ruler/api.go b/pkg/ruler/api.go index 7cb1ec3e0c..12dc1292d4 100644 --- a/pkg/ruler/api.go +++ b/pkg/ruler/api.go @@ -40,9 +40,9 @@ func (r *Ruler) RegisterRoutes(router *mux.Router) { type response struct { Status string `json:"status"` - Data interface{} `json:"data,omitempty"` - ErrorType v1.ErrorType `json:"errorType,omitempty"` - Error string `json:"error,omitempty"` + Data interface{} `json:"data"` + ErrorType v1.ErrorType `json:"errorType"` + Error string `json:"error"` } // AlertDiscovery has info for all active alerts. @@ -55,7 +55,7 @@ type Alert struct { Labels labels.Labels `json:"labels"` Annotations labels.Labels `json:"annotations"` State string `json:"state"` - ActiveAt *time.Time `json:"activeAt,omitempty"` + ActiveAt *time.Time `json:"activeAt"` Value string `json:"value"` } @@ -89,7 +89,7 @@ type alertingRule struct { Annotations labels.Labels `json:"annotations"` Alerts []*Alert `json:"alerts"` Health string `json:"health"` - LastError string `json:"lastError,omitempty"` + LastError string `json:"lastError"` Type v1.RuleType `json:"type"` LastEvaluation time.Time `json:"lastEvaluation"` EvaluationTime float64 `json:"evaluationTime"` @@ -98,9 +98,9 @@ type alertingRule struct { type recordingRule struct { Name string `json:"name"` Query string `json:"query"` - Labels labels.Labels `json:"labels,omitempty"` + Labels labels.Labels `json:"labels"` Health string `json:"health"` - LastError string `json:"lastError,omitempty"` + LastError string `json:"lastError"` Type v1.RuleType `json:"type"` LastEvaluation time.Time `json:"lastEvaluation"` EvaluationTime float64 `json:"evaluationTime"` diff --git a/pkg/ruler/legacy_rulefmt/rulefmt.go b/pkg/ruler/legacy_rulefmt/rulefmt.go index 501079862c..4a82712a9a 100644 --- a/pkg/ruler/legacy_rulefmt/rulefmt.go +++ b/pkg/ruler/legacy_rulefmt/rulefmt.go @@ -87,18 +87,18 @@ func (g *RuleGroups) Validate() (errs []error) { // RuleGroup is a list of sequentially evaluated recording and alerting rules. type RuleGroup struct { Name string `yaml:"name"` - Interval model.Duration `yaml:"interval,omitempty"` + Interval model.Duration `yaml:"interval"` Rules []Rule `yaml:"rules"` } // Rule describes an alerting or recording rule. type Rule struct { - Record string `yaml:"record,omitempty"` - Alert string `yaml:"alert,omitempty"` + Record string `yaml:"record"` + Alert string `yaml:"alert"` Expr string `yaml:"expr"` - For model.Duration `yaml:"for,omitempty"` - Labels map[string]string `yaml:"labels,omitempty"` - Annotations map[string]string `yaml:"annotations,omitempty"` + For model.Duration `yaml:"for"` + Labels map[string]string `yaml:"labels"` + Annotations map[string]string `yaml:"annotations"` } // Validate the rule and return a list of encountered errors. diff --git a/pkg/ruler/ruler_ring.go b/pkg/ruler/ruler_ring.go index dfc9970a62..fb45cb2c8b 100644 --- a/pkg/ruler/ruler_ring.go +++ b/pkg/ruler/ruler_ring.go @@ -18,9 +18,9 @@ import ( // is used to strip down the config to the minimum, and avoid confusion // to the user. type RingConfig struct { - KVStore kv.Config `yaml:"kvstore,omitempty"` - HeartbeatPeriod time.Duration `yaml:"heartbeat_period,omitempty"` - HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout,omitempty"` + KVStore kv.Config `yaml:"kvstore"` + HeartbeatPeriod time.Duration `yaml:"heartbeat_period"` + HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"` // Instance details InstanceID string `yaml:"instance_id" doc:"hidden"` From f79d5cdb389b96ddf91e0aac3dc92b0f3f8c1ce1 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Wed, 18 Mar 2020 15:56:28 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f48338fde9..05a570a1a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ * [ENHANCEMENT] Experimental TSDB: Add support for local `filesystem` backend. #2245 * [ENHANCEMENT] Allow 1w (where w denotes week) and 1y (where y denotes year) when setting table period and retention. #2252 * [ENHANCEMENT] Added FIFO cache metrics for current number of entries and memory usage. #2270 -* [ENHANCEMENT] Output all config fields to /config API, including those with empty value". #2209 +* [ENHANCEMENT] Output all config fields to /config API, including those with empty value. #2209 * [BUGFIX] Fixed etcd client keepalive settings. #2278 * [BUGFIX] Fixed bug in updating last element of FIFO cache. #2270 @@ -406,4 +406,4 @@ This release has several exciting features, the most notable of them being setti * `ha-tracker.cluster` is now `distributor.ha-tracker.cluster` * [FEATURE] You can specify "heap ballast" to reduce Go GC Churn #1489 * [BUGFIX] HA Tracker no longer always makes a request to Consul/Etcd when a request is not from the active replica #1516 -* [BUGFIX] Queries are now correctly cancelled by the query-frontend #1508 \ No newline at end of file +* [BUGFIX] Queries are now correctly cancelled by the query-frontend #1508