utils

package
v0.0.0-...-d416164 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	InProgress        = "In progress"
	Finalizing        = "Finalizing"
	Aborting          = "Aborting"
	PrepCompleted     = "Prep completed"
	PrepFailed        = "Prep failed"
	UpgradeCompleted  = "Upgrade completed"
	UpgradeFailed     = "Upgrade failed"
	RollbackCompleted = "Rollback completed"
	RollbackFailed    = "Rollback failed"
	RollbackRequested = "Rollback requested"
)

Common condition messages Note: This is not a complete list and does not include the custom messages

View Source
const (
	IBUWorkspacePath string = common.LCAConfigDir + "/workspace"
	// IBUName defines the valid name of the CR for the controller to reconcile
	IBUName     string = "upgrade"
	IBUFilePath string = common.LCAConfigDir + "/ibu.json"

	ManualCleanupAnnotation    string = "lca.openshift.io/manual-cleanup-done"
	TriggerReconcileAnnotation string = "lca.openshift.io/trigger-reconcile"

	// SeedGenName defines the valid name of the CR for the controller to reconcile
	SeedGenName          string = "seedimage"
	SeedGenSecretName    string = "seedgen"
	SeedgenWorkspacePath string = common.LCAConfigDir + "/ibu-seedgen-orch" // The LCAConfigDir folder is excluded from the var.tgz backup in seed image creation
)

Variables

View Source
var (
	SeedGenStoredCR       = filepath.Join(SeedgenWorkspacePath, "seedgen-cr.json")
	SeedGenStoredSecretCR = filepath.Join(SeedgenWorkspacePath, "seedgen-secret.json")

	StoredPullSecret = filepath.Join(SeedgenWorkspacePath, "pull-secret.json")
)
View Source
var ConditionReasons = struct {
	Idle              ConditionReason
	Completed         ConditionReason
	Failed            ConditionReason
	TimedOut          ConditionReason
	InProgress        ConditionReason
	Aborting          ConditionReason
	AbortCompleted    ConditionReason
	AbortFailed       ConditionReason
	Finalizing        ConditionReason
	FinalizeCompleted ConditionReason
	FinalizeFailed    ConditionReason
	InvalidTransition ConditionReason
}{
	Idle:              "Idle",
	Completed:         "Completed",
	Failed:            "Failed",
	TimedOut:          "TimedOut",
	InProgress:        "InProgress",
	Aborting:          "Aborting",
	AbortCompleted:    "AbortCompleted",
	AbortFailed:       "AbortFailed",
	Finalizing:        "Finalizing",
	FinalizeCompleted: "FinalizeCompleted",
	FinalizeFailed:    "FinalizeFailed",
	InvalidTransition: "InvalidTransition",
}

ConditionReasons define the different reasons that conditions will be set for

View Source
var ConditionTypes = struct {
	Idle               ConditionType
	PrepInProgress     ConditionType
	PrepCompleted      ConditionType
	UpgradeInProgress  ConditionType
	UpgradeCompleted   ConditionType
	RollbackInProgress ConditionType
	RollbackCompleted  ConditionType
	SeedGenInProgress  ConditionType
	SeedGenCompleted   ConditionType
}{
	Idle:               "Idle",
	PrepInProgress:     "PrepInProgress",
	PrepCompleted:      "PrepCompleted",
	UpgradeInProgress:  "UpgradeInProgress",
	UpgradeCompleted:   "UpgradeCompleted",
	RollbackInProgress: "RollbackInProgress",
	RollbackCompleted:  "RollbackCompleted",
	SeedGenInProgress:  "SeedGenInProgress",
	SeedGenCompleted:   "SeedGenCompleted",
}

ConditionTypes define the different types of conditions that will be set

View Source
var FinalConditionTypes = []ConditionType{ConditionTypes.UpgradeCompleted, ConditionTypes.RollbackCompleted}

FinalConditionTypes defines the valid conditions for transitioning back to idle

View Source
var SeedGenConditionReasons = struct {
	Completed  ConditionReason
	Failed     ConditionReason
	InProgress ConditionReason
}{
	Completed:  "Completed",
	Failed:     "Failed",
	InProgress: "InProgress",
}
View Source
var SeedGenConditionTypes = struct {
	SeedGenInProgress ConditionType
	SeedGenCompleted  ConditionType
}{
	SeedGenInProgress: "SeedGenInProgress",
	SeedGenCompleted:  "SeedGenCompleted",
}

Functions

func ClearInvalidTransitionStatusConditions

func ClearInvalidTransitionStatusConditions(ibu *ibuv1.ImageBasedUpgrade)

ClearInvalidTransitionStatusConditions clears any invalid transitions if exist

func GetCompletedCondition

func GetCompletedCondition(ibu *ibuv1.ImageBasedUpgrade, stage ibuv1.ImageBasedUpgradeStage) *metav1.Condition

GetCompletedCondition returns the completed condition based on the stage

func GetInProgressCondition

func GetInProgressCondition(ibu *ibuv1.ImageBasedUpgrade, stage ibuv1.ImageBasedUpgradeStage) *metav1.Condition

GetInProgressCondition returns the in progress condition based on the stage

func GetInProgressStage

func GetInProgressStage(ibu *ibuv1.ImageBasedUpgrade) ibuv1.ImageBasedUpgradeStage

GetInProgressStage returns the stage that is currently in progress

func IsStageCompleted

func IsStageCompleted(ibu *ibuv1.ImageBasedUpgrade, stage ibuv1.ImageBasedUpgradeStage) bool

IsStageCompleted checks if the completed condition status for the stage is true

func IsStageCompletedOrFailed

func IsStageCompletedOrFailed(ibu *ibuv1.ImageBasedUpgrade, stage ibuv1.ImageBasedUpgradeStage) bool

IsStageCompletedOrFailed checks if the completed condition for the stage is present

func IsStageFailed

func IsStageFailed(ibu *ibuv1.ImageBasedUpgrade, stage ibuv1.ImageBasedUpgradeStage) bool

IsStageFailed checks if the completed condition status for the stage is false

func IsStageInProgress

func IsStageInProgress(ibu *ibuv1.ImageBasedUpgrade, stage ibuv1.ImageBasedUpgradeStage) bool

IsStageInProgress checks if ibu is working on the stage

func ResetHistory

func ResetHistory(client client.Client, log logr.Logger, ibu *ibuv1.ImageBasedUpgrade)

ResetHistory reset the .status.history by setting the list to empty

func ResetStatusConditions

func ResetStatusConditions(existingConditions *[]metav1.Condition, generation int64)

ResetStatusConditions remove all other conditions and sets idle to true

func SetIdleStatusInProgress

func SetIdleStatusInProgress(ibu *ibuv1.ImageBasedUpgrade, reason ConditionReason, msg string)

SetIdleStatusInProgress updates the Idle status to in progress with message

func SetPrepStatusCompleted

func SetPrepStatusCompleted(ibu *ibuv1.ImageBasedUpgrade, msg string)

SetPrepStatusCompleted updates the prep status to completed

func SetPrepStatusFailed

func SetPrepStatusFailed(ibu *ibuv1.ImageBasedUpgrade, msg string)

SetPrepStatusFailed updates the prep status to failed with message

func SetPrepStatusInProgress

func SetPrepStatusInProgress(ibu *ibuv1.ImageBasedUpgrade, msg string)

SetPrepStatusInProgress updates the prep status to in progress with message

func SetRollbackStatusCompleted

func SetRollbackStatusCompleted(ibu *ibuv1.ImageBasedUpgrade)

SetUpgradeStatusCompleted updates the Rollback status to completed

func SetRollbackStatusFailed

func SetRollbackStatusFailed(ibu *ibuv1.ImageBasedUpgrade, msg string)

SetRollbackStatusFailed updates the Rollback status to failed with message

func SetRollbackStatusInProgress

func SetRollbackStatusInProgress(ibu *ibuv1.ImageBasedUpgrade, msg string)

SetRollbackStatusInProgress updates the Rollback status to in progress with message

func SetStatusCondition

func SetStatusCondition(existingConditions *[]metav1.Condition, conditionType ConditionType, conditionReason ConditionReason, conditionStatus metav1.ConditionStatus, message string, generation int64)

SetStatusCondition is a convenience wrapper for meta.SetStatusCondition that takes in the types defined here and converts them to strings

func SetStatusInvalidTransition

func SetStatusInvalidTransition(ibu *ibuv1.ImageBasedUpgrade, msg string)

SetStatusInvalidTransition updates the given stage status to invalid transition with message

func SetUpgradeStatusCompleted

func SetUpgradeStatusCompleted(ibu *ibuv1.ImageBasedUpgrade)

SetUpgradeStatusCompleted updates the upgrade status to completed

func SetUpgradeStatusFailed

func SetUpgradeStatusFailed(ibu *ibuv1.ImageBasedUpgrade, msg string)

SetUpgradeStatusFailed updates the upgrade status to failed with message

func SetUpgradeStatusInProgress

func SetUpgradeStatusInProgress(ibu *ibuv1.ImageBasedUpgrade, msg string)

SetUpgradeStatusInProgress updates the upgrade status to in progress with message

func SetUpgradeStatusRollbackRequested

func SetUpgradeStatusRollbackRequested(ibu *ibuv1.ImageBasedUpgrade)

SetUpgradeStatusRollbackRequested updates the upgrade status to failed with rollback requested message

func StartPhase

func StartPhase(client client.Client, log logr.Logger, ibu *ibuv1.ImageBasedUpgrade, phase string)

StartPhase This can be called after StartStageHistory to allow for a more granular view of the important phases that are performed when moving a desired Stage. Phase timer is stopped when the phase completes successfully using StopPhase

func StartStageHistory

func StartStageHistory(client client.Client, log logr.Logger, ibu *ibuv1.ImageBasedUpgrade)

StartStageHistory this is called before a stage handler is called for the first time, which starts a timer know how long a stage took to complete. Time timer stopped when the stage completes successfully using StopStageHistory

func StopPhase

func StopPhase(client client.Client, log logr.Logger, ibu *ibuv1.ImageBasedUpgrade, phase string)

StopPhase call when a phase completes successfully. This is a no op unless StartPhase is called first

func StopStageHistory

func StopStageHistory(client client.Client, log logr.Logger, ibu *ibuv1.ImageBasedUpgrade)

StopStageHistory call when a stage completes successfully. This is a no op unless StartStageHistory is called first

func UpdateIBUStatus

func UpdateIBUStatus(ctx context.Context, c client.Client, ibu *ibuv1.ImageBasedUpgrade) error

Types

type ConditionReason

type ConditionReason string

ConditionReason is a string representing the condition's reason

type ConditionType

type ConditionType string

ConditionType is a string representing the condition's type

func GetCompletedConditionType

func GetCompletedConditionType(stage ibuv1.ImageBasedUpgradeStage) (conditionType ConditionType)

GetCompletedConditionType returns the completed condition type based on the stage

func GetInProgressConditionType

func GetInProgressConditionType(stage ibuv1.ImageBasedUpgradeStage) (conditionType ConditionType)

GetInProgressConditionType returns the in progress condition type based on the stage

Jump to

Keyboard shortcuts

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