app

package
v0.0.0-...-36422b4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BridgesToNicCommand = cli.Command{
	Name:  "bridges-to-nic",
	Usage: "Delete ovs bridge and move IP/routes to underlying NIC",
	Flags: []cli.Flag{},
	Action: func(context *cli.Context) error {
		args := context.Args()
		if args.Len() == 0 {
			return fmt.Errorf("please specify list of bridges")
		}

		if err := util.SetSpecificExec(kexec.New(), "ovs-vsctl"); err != nil {
			return err
		}

		var errorList []error
		for _, bridge := range args.Slice() {
			if err := util.BridgeToNic(bridge); err != nil {
				errorList = append(errorList, err)
			}
		}

		return utilerrors.Join(errorList...)
	},
}

BridgesToNicCommand removes a NIC interface from OVS bridge and deletes the bridge

View Source
var NicsToBridgeCommand = cli.Command{
	Name:  "nics-to-bridge",
	Usage: "Create ovs bridge for nic interfaces",
	Flags: []cli.Flag{},
	Action: func(context *cli.Context) error {
		args := context.Args()
		if args.Len() == 0 {
			return fmt.Errorf("please specify list of nic interfaces")
		}

		if err := util.SetSpecificExec(kexec.New(), "ovs-vsctl"); err != nil {
			return err
		}

		var errorList []error
		for _, nic := range args.Slice() {
			if _, err := util.NicToBridge(nic); err != nil {
				errorList = append(errorList, err)
			}
		}

		return utilerrors.Join(errorList...)
	},
}

NicsToBridgeCommand creates ovs bridge for provided nic interfaces.

View Source
var OvsExporterCommand = cli.Command{
	Name:  "ovs-exporter",
	Usage: "",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "metrics-bind-address",
			Usage: `The IP address and port for the metrics server to serve on (default ":9310")`,
		},
		&cli.IntFlag{
			Name:        "metrics-interval",
			Usage:       "The interval in seconds at which ovs metrics are collected",
			Value:       30,
			Destination: &metricsScrapeInterval,
		},
	},
	Action: func(ctx *cli.Context) error {
		stopChan := make(chan struct{})
		bindAddress := ctx.String("metrics-bind-address")
		if bindAddress == "" {
			bindAddress = "0.0.0.0:9310"
		}

		if err := util.SetExec(kexec.New()); err != nil {
			return err
		}

		ovsClient, err := libovsdb.NewOVSClient(stopChan)
		if err != nil {
			klog.Errorf("Error initializing ovs client: %v", err)
		}

		mux := http.NewServeMux()
		mux.Handle("/metrics", promhttp.Handler())

		metrics.RegisterStandaloneOvsMetrics(ovsClient, metricsScrapeInterval, stopChan)

		server := &http.Server{Addr: bindAddress, Handler: mux}
		go func() {
			if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
				klog.Exitf("Metrics server exited with error: %v", err)
			}
		}()

		<-ctx.Context.Done()
		close(stopChan)
		shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
		defer cancel()
		if err := server.Shutdown(shutdownCtx); err != nil {
			klog.Errorf("Error stopping metrics server: %v", err)
		}

		return nil
	},
}
View Source
var ReadinessProbeCommand = cli.Command{
	Name:  "readiness-probe",
	Usage: "check readiness of the specified target daemon",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "target",
			Aliases: []string{"t"},
			Usage:   "target daemon to check for readiness",
		},
	},
	Action: func(ctx *cli.Context) error {
		target := ctx.String("target")
		if err := util.SetExec(kexec.New()); err != nil {
			return err
		}
		if cbfunc, ok := callbacks[target]; ok {
			return cbfunc(target)
		}
		return fmt.Errorf("incorrect target specified")
	},
}

ReadinessProbeCommand runs readiness probes against various targets

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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