orchestration

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Pending    = "pending"
	InProgress = "in progress"
	Canceling  = "canceling"
	Retrying   = "retrying" // to signal a retry sign before marking it to pending
	Canceled   = "canceled"
	Succeeded  = "succeeded"
	Failed     = "failed"
)

Orchestration states

View Source
const (
	// StateParam parameter used in list orchestrations / operations queries to filter by state
	StateParam = "state"
)
View Source
const TargetAll = "all"

TargetAll all SKRs provisioned successfully and not deprovisioning

Variables

This section is empty.

Functions

func ConvertSliceOfDaysToMap

func ConvertSliceOfDaysToMap(days []string) map[time.Weekday]bool

func FirstAvailableDayDiff

func FirstAvailableDayDiff(currentDay time.Weekday, availableDays map[time.Weekday]bool) int

func NextAvailableDayDiff

func NextAvailableDayDiff(currentDay time.Weekday, availableDays map[time.Weekday]bool) int

Types

type Client

type Client interface {
	ListOrchestrations(params ListParameters) (StatusResponseList, error)
	GetOrchestration(orchestrationID string) (StatusResponse, error)
	ListOperations(orchestrationID string, params ListParameters) (OperationResponseList, error)
	GetOperation(orchestrationID, operationID string) (OperationDetailResponse, error)
	UpgradeKyma(params Parameters) (UpgradeResponse, error)
	UpgradeCluster(params Parameters) (UpgradeResponse, error)
	CancelOrchestration(orchestrationID string) error
	RetryOrchestration(orchestrationID string, operationIDs []string, now bool) (RetryResponse, error)
}

Client is the interface to interact with the KEB /orchestrations and /upgrade API as an HTTP client using OIDC ID token in JWT format.

func NewClient

func NewClient(ctx context.Context, url string, auth oauth2.TokenSource) Client

NewClient constructs and returns new Client for KEB /runtimes API It takes the following arguments:

  • ctx : context in which the http request will be executed
  • url : base url of all KEB APIs, e.g. https://kyma-env-broker.kyma.local
  • auth : TokenSource object which provides the ID token for the HTTP request

type GardenerRuntimeResolver

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

GardenerRuntimeResolver is the default resolver which implements the RuntimeResolver interface. This resolver uses the Shoot resources on the Gardener cluster to resolve the runtime targets.

Naive implementation, listing all the shoots and perfom filtering on the result. The logic could be optimized with k8s client cache using shoot lister / indexer. The implementation is thread safe, i.e. it is safe to call Resolve() from multiple threads concurrently.

func NewGardenerRuntimeResolver

func NewGardenerRuntimeResolver(gardenerClient dynamic.Interface, gardenerNamespace string, lister RuntimeLister, logger logrus.FieldLogger) *GardenerRuntimeResolver

NewGardenerRuntimeResolver constructs a GardenerRuntimeResolver with the mandatory input parameters.

func (*GardenerRuntimeResolver) Resolve

func (resolver *GardenerRuntimeResolver) Resolve(targets TargetSpec) ([]Runtime, error)

Resolve given an input slice of target specs to include and exclude, returns back a list of unique Runtime objects

type KubernetesParameters

type KubernetesParameters struct {
	KubernetesVersion   string `json:"kubernetesVersion"`
	MachineImage        string `json:"machineImage"`
	MachineImageVersion string `json:"machineImageVersion"`
}

type KymaParameters

type KymaParameters struct {
	Version string `json:"version,omitempty"`
}

KymaParameters hold the attributes of kyma upgrade specific orchestration create requests.

type ListParameters

type ListParameters struct {
	Page     int
	PageSize int
	States   []string
}

ListParameters hold attributes of list orchestrations / operations queries.

type MaintenancePolicy

type MaintenancePolicy struct {
	Rules   []MaintenancePolicyRule `json:"rules"`
	Default MaintenancePolicyEntry  `json:"default"`
}

type MaintenancePolicyEntry

type MaintenancePolicyEntry struct {
	Days      []string `json:"days"`
	TimeBegin string   `json:"timeBegin"`
	TimeEnd   string   `json:"timeEnd"`
}

type MaintenancePolicyMatch

type MaintenancePolicyMatch struct {
	GlobalAccountID string `json:"globalAccountID"`
	Plan            string `json:"plan"`
	Region          string `json:"region"`
}

type MaintenancePolicyRule

type MaintenancePolicyRule struct {
	Match                  MaintenancePolicyMatch `json:"match"`
	MaintenancePolicyEntry `json:""`
}

type NotificationStateType

type NotificationStateType string
const (
	NotificationPending   NotificationStateType = "pending"
	NotificationCreated   NotificationStateType = "created"
	NotificationCancelled NotificationStateType = "cancelled"
)

type OperationDetailResponse

type OperationDetailResponse struct {
	OperationResponse

	KymaConfig    *gqlschema.KymaConfigInput     `json:"kymaConfig,omitempty"`
	ClusterConfig *gqlschema.GardenerConfigInput `json:"clusterConfig,omitempty"`
}

type OperationExecutor

type OperationExecutor interface {
	Execute(operationID string) (time.Duration, error)
	Reschedule(operationID string, maintenanceWindowBegin, maintenanceWindowEnd time.Time) error
}

OperationExecutor implements methods to perform the operation corresponding to a Runtime.

type OperationResponse

type OperationResponse struct {
	OperationID            string    `json:"operationID"`
	RuntimeID              string    `json:"runtimeID"`
	GlobalAccountID        string    `json:"globalAccountID"`
	SubAccountID           string    `json:"subAccountID"`
	OrchestrationID        string    `json:"orchestrationID"`
	ServicePlanID          string    `json:"servicePlanID"`
	ServicePlanName        string    `json:"servicePlanName"`
	DryRun                 bool      `json:"dryRun"`
	ShootName              string    `json:"shootName"`
	MaintenanceWindowBegin time.Time `json:"maintenanceWindowBegin"`
	MaintenanceWindowEnd   time.Time `json:"maintenanceWindowEnd"`
	State                  string    `json:"state"`
	Description            string    `json:"description"`
}

type OperationResponseList

type OperationResponseList struct {
	Data       []OperationResponse `json:"data"`
	Count      int                 `json:"count"`
	TotalCount int                 `json:"totalCount"`
}

type ParallelStrategySpec

type ParallelStrategySpec struct {
	Workers int `json:"workers"`
}

ParallelStrategySpec defines parameters for the parallel orchestration strategy

type Parameters

type Parameters struct {
	Targets    TargetSpec            `json:"targets"`
	Strategy   StrategySpec          `json:"strategy,omitempty"`
	DryRun     bool                  `json:"dryRun,omitempty"`
	Kubernetes *KubernetesParameters `json:"kubernetes,omitempty"`
	// upgrade kyma specific parameters
	Kyma           *KymaParameters          `json:"kyma,omitempty"`
	RetryOperation RetryOperationParameters `json:"retryoperation,omitempty"`
	// customer notification
	Notification bool `json:"notification,omitempty"`
}

Parameters hold the attributes of orchestration create (upgrade) requests.

type RetryOperationParameters

type RetryOperationParameters struct {
	RetryOperations []string      `json:"retryoperations,omitempty"`
	Immediate       stringBoolean `json:"immediate,omitempty"`
}

type RetryResponse

type RetryResponse struct {
	OrchestrationID   string   `json:"orchestrationID"`
	RetryShoots       []string `json:"retryShoots"`
	OldOperations     []string `json:"oldOperations"`
	InvalidOperations []string `json:"invalidOperations"`
	Msg               string   `json:"msg"`
}

type Runtime

type Runtime struct {
	InstanceID      string `json:"instanceId,omitempty"`
	RuntimeID       string `json:"runtimeId"`
	GlobalAccountID string `json:"globalAccountId"`
	SubAccountID    string `json:"subaccountId"`
	// The corresponding shoot cluster's .metadata.name value
	ShootName string `json:"shootName"`
	// The corresponding shoot cluster's .spec.maintenance.timeWindow.Begin value, which is in in "HHMMSS+[HHMM TZ]" format, e.g. "040000+0000"
	MaintenanceWindowBegin time.Time `json:"maintenanceWindowBegin"`
	// The corresponding shoot cluster's .spec.maintenance.timeWindow.End value, which is in "HHMMSS+[HHMM TZ]" format, e.g. "040000+0000"
	MaintenanceWindowEnd time.Time `json:"maintenanceWindowEnd"`
	MaintenanceDays      []string  `json:"maintenanceDays"`
	Plan                 string    `json:"plan"`
	Region               string    `json:"region"`
}

Runtime is the data type which captures the needed runtime specific attributes to perform orchestrations on a given runtime.

type RuntimeLister

type RuntimeLister interface {
	ListAllRuntimes() ([]runtime.RuntimeDTO, error)
}

RuntimeLister is the interface to get runtime objects from KEB

type RuntimeListerMock

type RuntimeListerMock struct {
	mock.Mock
}

RuntimeListerMock is an autogenerated mock type for the RuntimeLister type

func NewRuntimeListerMock

func NewRuntimeListerMock(t mockConstructorTestingTNewRuntimeListerMock) *RuntimeListerMock

NewRuntimeListerMock creates a new instance of RuntimeListerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*RuntimeListerMock) ListAllRuntimes

func (_m *RuntimeListerMock) ListAllRuntimes() ([]runtime.RuntimeDTO, error)

ListAllRuntimes provides a mock function with given fields:

type RuntimeOperation

type RuntimeOperation struct {
	Runtime `json:""`
	ID      string `json:"-"`
	DryRun  bool   `json:"dryRun"`
	//customer notification
	Notification      bool                  `json:"notification,omitempty"`
	NotificationState NotificationStateType `json:"notificationstate,omitempty"`
}

RuntimeOperation holds information about operation performed on a runtime

type RuntimeResolver

type RuntimeResolver interface {
	Resolve(targets TargetSpec) ([]Runtime, error)
}

RuntimeResolver given an input slice of target specs to include and exclude, resolves and returns a list of unique Runtime objects.

type RuntimeTarget

type RuntimeTarget struct {
	// Valid values: "all"
	Target string `json:"target,omitempty"`
	// Regex pattern to match against the runtime's GlobalAccount field. E.g. CA50125541TID000000000741207136, CA.*
	GlobalAccount string `json:"globalAccount,omitempty"`
	// Regex pattern to match against the runtime's SubAccount field. E.g. 0d20e315-d0b4-48a2-9512-49bc8eb03cd1
	SubAccount string `json:"subAccount,omitempty"`
	// Regex pattern to match against the shoot cluster's Region field (not SCP platform-region). E.g. "europe|eu-"
	Region string `json:"region,omitempty"`
	// RuntimeID is used to indicate a specific runtime
	RuntimeID string `json:"runtimeID,omitempty"`
	// PlanName is used to match runtimes with the same plan
	PlanName string `json:"planName,omitempty"`
	// Shoot is used to indicate a sepcific runtime by shoot name
	Shoot string `json:"shoot,omitempty"`
	// InstanceID is used to identify an instance by it's instance ID
	InstanceID string `json:"instanceID,omitempty"`
}

RuntimeTarget captures a specification of SKR targets to resolve for an orchestration. When a RuntimeTarget defines multiple fields, all should match to any given runtime to be selected (i.e. the terms are AND-ed).

type ScheduleType

type ScheduleType string
const (
	Immediate         ScheduleType = "immediate"
	Now               ScheduleType = "now"
	MaintenanceWindow ScheduleType = "maintenanceWindow"
)

type StatusResponse

type StatusResponse struct {
	OrchestrationID string         `json:"orchestrationID"`
	Type            Type           `json:"type"`
	State           string         `json:"state"`
	Description     string         `json:"description"`
	CreatedAt       time.Time      `json:"createdAt"`
	UpdatedAt       time.Time      `json:"updatedAt"`
	Parameters      Parameters     `json:"parameters"`
	OperationStats  map[string]int `json:"operationStats,omitempty"`
}

type StatusResponseList

type StatusResponseList struct {
	Data       []StatusResponse `json:"data"`
	Count      int              `json:"count"`
	TotalCount int              `json:"totalCount"`
}

type Strategy

type Strategy interface {
	// Execute invokes OperationExecutor's Execute(operationID string) method for each operation according to the encapsulated strategy.
	// The strategy is executed asynchronously. Successful call to the function returns a unique identifier, which can be used in a subsequent call to Wait().
	Execute(operations []RuntimeOperation, strategySpec StrategySpec) (string, error)
	// Wait blocks and waits until the execution with the given ID is finished.
	Wait(executionID string)
	// Cancel shutdowns a given execution.
	Cancel(executionID string)
	// Insert operations into the delaying queue of a given execution ID
	Insert(execID string, operations []RuntimeOperation, strategySpec StrategySpec) error
	// SpeedUp makes the retries speedFactor times faster, used for unit testing
	SpeedUp(speedFactor int)
}

Strategy interface encapsulates the strategy how the orchestration is performed.

type StrategySpec

type StrategySpec struct {
	Type              StrategyType `json:"type"`
	Schedule          string       `json:"schedule,omitempty"`
	ScheduleTime      time.Time
	MaintenanceWindow bool                 `json:"maintenanceWindow,omitempty"`
	Parallel          ParallelStrategySpec `json:"parallel,omitempty"`
}

StrategySpec is the strategy part common for all orchestration trigger/status API

type StrategyType

type StrategyType string
const (
	ParallelStrategy StrategyType = "parallel"
)

type TargetSpec

type TargetSpec struct {
	Include []RuntimeTarget `json:"include"`
	Exclude []RuntimeTarget `json:"exclude,omitempty"`
}

TargetSpec is the targets part common for all orchestration trigger/status API

type Type

type Type string
const (
	UpgradeKymaOrchestration    Type = "upgradeKyma"
	UpgradeClusterOrchestration Type = "upgradeCluster"
)

type UpgradeResponse

type UpgradeResponse struct {
	OrchestrationID string `json:"orchestrationID"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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