utils

package
v0.0.0-...-5a6eb71 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 8 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 *lcav1alpha1.ImageBasedUpgrade)

ClearInvalidTransitionStatusConditions clears any invalid transitions if exist

func ClearStatusCondition

func ClearStatusCondition(existingConditions *[]metav1.Condition, conditionType ConditionType)

func GetCompletedCondition

GetCompletedCondition returns the completed condition based on the stage

func GetInProgressCondition

GetInProgressCondition returns the in progress condition based on the stage

func GetInProgressStage

GetInProgressStage returns the stage that is currently in progress

func GetPreviousStage

GetPreviousStage returns the previous stage for the one passed in

func IsStageCompleted

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

func IsStageCompletedOrFailed

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

IsStageCompletedOrFailed checks if the completed condition for the stage is present

func IsStageFailed

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

func IsStageInProgress

IsStageInProgress checks if ibu is working on the stage

func ResetStatusConditions

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

ResetStatusConditions remove all other conditions and sets idle to true

func SetIdleStatusInProgress

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

SetIdleStatusInProgress updates the Idle status to in progress with message

func SetPrepStatusCompleted

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

SetPrepStatusCompleted updates the prep status to completed

func SetPrepStatusFailed

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

SetPrepStatusFailed updates the prep status to failed with message

func SetPrepStatusInProgress

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

SetPrepStatusInProgress updates the prep status to in progress with message

func SetRollbackStatusCompleted

func SetRollbackStatusCompleted(ibu *lcav1alpha1.ImageBasedUpgrade)

SetUpgradeStatusCompleted updates the Rollback status to completed

func SetRollbackStatusFailed

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

SetRollbackStatusFailed updates the Rollback status to failed with message

func SetRollbackStatusInProgress

func SetRollbackStatusInProgress(ibu *lcav1alpha1.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 *lcav1alpha1.ImageBasedUpgrade, msg string)

SetStatusInvalidTransition updates the given stage status to invalid transition with message

func SetUpgradeStatusCompleted

func SetUpgradeStatusCompleted(ibu *lcav1alpha1.ImageBasedUpgrade)

SetUpgradeStatusCompleted updates the upgrade status to completed

func SetUpgradeStatusFailed

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

SetUpgradeStatusFailed updates the upgrade status to failed with message

func SetUpgradeStatusInProgress

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

SetUpgradeStatusInProgress updates the upgrade status to in progress with message

func SetUpgradeStatusRollbackRequested

func SetUpgradeStatusRollbackRequested(ibu *lcav1alpha1.ImageBasedUpgrade)

SetUpgradeStatusRollbackRequested updates the upgrade status to failed with rollback requested message

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 lcav1alpha1.ImageBasedUpgradeStage) (conditionType ConditionType)

GetCompletedConditionType returns the completed condition type based on the stage

func GetInProgressConditionType

func GetInProgressConditionType(stage lcav1alpha1.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