Skip to content

Commit

Permalink
Meta changes (will squash)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Nov 6, 2022
1 parent e27bb70 commit c2d4dbb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/cli-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Usage of ./kube-state-metrics:
--namespaces string Comma-separated list of namespaces to be enabled. Defaults to ""
--namespaces-denylist string Comma-separated list of namespaces not to be enabled. If namespaces and namespaces-denylist are both set, only namespaces that are excluded in namespaces-denylist will be used.
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
--options-config-file string Path to the kube-state-metrics options config file
--pod string Name of the pod that contains the kube-state-metrics container. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice.
--pod-namespace string Name of the namespace of the pod specified by --pod. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice.
--port int Port to expose metrics on. (default 8080)
Expand Down
6 changes: 4 additions & 2 deletions pkg/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package app
import (
"context"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/http/pprof"
"os"
"path/filepath"
"strconv"
"time"

Expand Down Expand Up @@ -69,6 +70,7 @@ func (pl promLogger) Log(v ...interface{}) error {
return nil
}

// RunKubeStateMetricsWrapper runs KSM with context cancellation.
func RunKubeStateMetricsWrapper(ctx context.Context, opts *options.Options, factories ...customresource.RegistryFactory) error {
err := runKubeStateMetrics(ctx, opts, factories...)
if <-ctx.Done() == struct{}{} && ctx.Err() == context.Canceled {
Expand Down Expand Up @@ -102,7 +104,7 @@ func runKubeStateMetrics(ctx context.Context, opts *options.Options, factories .
// TODO: Should the options config file override flags?
got := options.GetOptsConfigFile(*opts)
if got != "" {
optsConfigFile, err := ioutil.ReadFile(got)
optsConfigFile, err := os.ReadFile(filepath.Clean(got))
if err != nil {
return fmt.Errorf("failed to read opts config file: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type Options struct {
TotalShards int
Pod string
Namespace string
MetricDenylist MetricSet `yaml:"metric_denylist"`
MetricAllowlist MetricSet `yaml:"metric_allowlist"`
MetricDenylist MetricSet
MetricAllowlist MetricSet
MetricOptInList MetricSet
Version bool
AnnotationsAllowList LabelsAllowList
Expand All @@ -62,6 +62,7 @@ type Options struct {
flags *pflag.FlagSet
}

// GetOptsConfigFile is the getter for --options-config-file value.
func GetOptsConfigFile(opt Options) string {
return opt.optsConfigFile
}
Expand Down

0 comments on commit c2d4dbb

Please sign in to comment.