orchestration

package
v0.0.0-...-dc8ed20 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0, Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pending    = "pending"
	InProgress = "in progress"
	Canceling  = "canceling"
	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

This section is empty.

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
}

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 gardenerclient.CoreV1beta1Interface, 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 KymaParameters

type KymaParameters struct {
	Version string `json:"kymaVersion,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 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"`
	// upgrade kyma specific parameters
	Kyma KymaParameters `json:""`
}

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

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"`
}

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 (*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"`
}

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"`
}

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"
	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)
}

Strategy interface encapsulates the strategy how the orchestration is performed.

type StrategySpec

type StrategySpec struct {
	Type     StrategyType         `json:"type"`
	Schedule ScheduleType         `json:"schedule,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