cmd

package
v1.13.0-rc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 76 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// IsLeader is an atomic boolean value that is true when the Operator is
	// elected leader. Otherwise, it is false.
	IsLeader atomic.Value
)
View Source
var MetricsCmd = &cobra.Command{
	Use:   "metrics",
	Short: "Access metric status of the operator",
}

MetricsCmd represents the metrics command for the operator.

View Source
var MetricsListCmd = &cobra.Command{
	Use:   "list",
	Short: "List all metrics for the operator",
	Run: func(cmd *cobra.Command, args []string) {
		c := client.NewHTTPClientWithConfig(
			strfmt.Default, client.DefaultTransportConfig().WithHost(operatorAddr))

		res, err := c.Metrics.GetMetrics(nil)
		if err != nil {
			log.Fatalf("Cannot get metrics list: %s", err)
		}

		re, err := regexp.Compile(matchPattern)
		if err != nil {
			log.Fatalf("Cannot compile regex: %s", err)
		}

		metrics := make([]*models.Metric, 0, len(res.Payload))
		for _, metric := range res.Payload {
			if re.MatchString(metric.Name) {
				metrics = append(metrics, metric)
			}
		}

		if command.OutputOption() {
			if err := command.PrintOutput(metrics); err != nil {
				os.Exit(1)
			}
			return
		}

		w := tabwriter.NewWriter(os.Stdout, 5, 0, 3, ' ', 0)

		fmt.Fprintln(w, "Metric\tLabels\tValue")
		for _, metric := range metrics {
			label := ""
			if len(metric.Labels) > 0 {
				labelArray := []string{}
				for key, value := range metric.Labels {
					labelArray = append(labelArray, fmt.Sprintf(`%s="%s"`, key, value))
				}
				label = strings.Join(labelArray, " ")
			}
			fmt.Fprintf(w, "%s\t%s\t%f\n", metric.Name, label, metric.Value)
		}
		w.Flush()
	},
}

MetricsListCmd dumps all metrics into stdout

View Source
var (
	Vp *viper.Viper = viper.New()
)

Functions

func Execute

func Execute()

func OnOperatorStartLeading

func OnOperatorStartLeading(ctx context.Context)

OnOperatorStartLeading is the function called once the operator starts leading in HA mode.

func Populate added in v1.10.0

func Populate()

Populate options required by cilium-operator command line only.

func ResetCiliumNodesCacheSyncedStatus

func ResetCiliumNodesCacheSyncedStatus()

ResetCiliumNodesCacheSyncedStatus resets the current status of cache synchronization in Cilium nodes as "not synced". Should be used in control-plane testing only to reset the operator status before executing the next test case.

func RunCNPNodeStatusGC

func RunCNPNodeStatusGC(nodeStore cache.Store)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL