action

package
v1.7.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MPL-2.0 Imports: 24 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MachineReadyEventFn is the predicate function that returns true if the event indicates the machine is ready.
	MachineReadyEventFn = func(event client.EventResult) bool {
		machineStatusEvent, ok := event.Event.Payload.(*machineapi.MachineStatusEvent)
		if !ok {
			return false
		}

		return machineStatusEvent.GetStage() == machineapi.MachineStatusEvent_RUNNING &&
			machineStatusEvent.GetStatus().GetReady()
	}

	// StopAllServicesEventFn is the predicate function that returns true if the event indicates that all services are being stopped.
	StopAllServicesEventFn = func(event client.EventResult) bool {
		taskEvent, ok := event.Event.Payload.(*machineapi.TaskEvent)
		if !ok {
			return false
		}

		return taskEvent.GetTask() == "stopAllServices"
	}

	// BootIDChangedPostCheckFn is a post check function that returns nil if the boot ID has changed.
	BootIDChangedPostCheckFn = func(ctx context.Context, c *client.Client, preActionBootID string) error {
		currentBootID, err := getBootID(ctx, c)
		if err != nil {
			return err
		}

		if preActionBootID == currentBootID {
			return retry.ExpectedErrorf("didn't reboot yet")
		}

		return nil
	}
)

Functions

This section is empty.

Types

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker runs the action in the actionFn on the nodes and tracks its progress using the provided expectedEventFn and postCheckFn.

func NewTracker

func NewTracker(
	cliContext *global.Args,
	expectedEventFn func(event client.EventResult) bool,
	actionFn func(ctx context.Context, c *client.Client) (string, error),
	opts ...TrackerOption,
) *Tracker

NewTracker creates a new Tracker.

func (*Tracker) Run

func (a *Tracker) Run() error

Run executes the action on nodes and tracks its progress by watching events with retries. After receiving the expected event, if provided, it tracks the progress by running the post check with retries.

type TrackerOption

type TrackerOption func(*Tracker)

TrackerOption is the functional option for the Tracker.

func WithDebug

func WithDebug(debug bool) TrackerOption

WithDebug enables debug mode.

func WithPostCheck

func WithPostCheck(postCheckFn func(ctx context.Context, c *client.Client, preActionBootID string) error) TrackerOption

WithPostCheck sets the post check function.

func WithTimeout

func WithTimeout(timeout time.Duration) TrackerOption

WithTimeout sets the timeout for the tracker.

Jump to

Keyboard shortcuts

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