api

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentName = "hivedscheduler"
	GroupName     = "hivedscheduler.microsoft.com"

	UnlimitedValue = -1

	// To leverage this scheduler, at least one container in the Pod should contain
	// below resource limit with any positive int16 value.
	ResourceNamePodSchedulingEnable = GroupName + "/pod-scheduling-enable"

	// To leverage this scheduler, the Pod should contain below annotation in
	// PodSchedulingSpec YAML format.
	AnnotationKeyPodSchedulingSpec = GroupName + "/pod-scheduling-spec"

	// To leverage this scheduler, the Pod could reference below annotation to
	// use the allocated leaf cells for the whole Pod.
	AnnotationKeyPodLeafCellIsolation      = GroupName + "/pod-leaf-cell-isolation"
	DeprecatedAnnotationKeyPodGpuIsolation = GroupName + "/pod-gpu-isolation"

	// Populated by this scheduler, used to track and recover allocated placement.
	// It is in PodBindInfo YAML format.
	AnnotationKeyPodBindInfo = GroupName + "/pod-bind-info"

	// Priority Range of Guaranteed Pod.
	MaxGuaranteedPriority = int32(1000)
	MinGuaranteedPriority = int32(0)

	// Priority of Opportunistic Pod.
	OpportunisticPriority = int32(-1)
)

///////////////////////////////////////////////////////////////////////////////////// General Constants /////////////////////////////////////////////////////////////////////////////////////

View Source
const (
	RootPath    = "/"
	VersionPath = RootPath + "v1"

	// Scheduler Extender API: API with K8S Default Scheduler
	ExtenderPath = VersionPath + "/extender"
	FilterPath   = ExtenderPath + "/filter"
	BindPath     = ExtenderPath + "/bind"
	PreemptPath  = ExtenderPath + "/preempt"

	// Scheduler Inspect API: API to inspect current scheduling status
	// Notes:
	// 1. Both Binding and Bound AffinityGroups/Pods are considered as Allocated.
	InspectPath = VersionPath + "/inspect"
	// Inspect current allocated AffinityGroup(s)
	AffinityGroupsPath = InspectPath + "/affinitygroups/"
	// Inspect current cluster status
	ClusterStatusPath = InspectPath + "/clusterstatus"
	// Inspect current physical cluster status
	PhysicalClusterPath = ClusterStatusPath + "/physicalcluster"
	// Inspect current virtual cluster(s)' status
	VirtualClustersPath = ClusterStatusPath + "/virtualclusters/"
)

///////////////////////////////////////////////////////////////////////////////////// WebServer Constants /////////////////////////////////////////////////////////////////////////////////////

Variables

View Source
var EnvValueConfigFilePath = common.GetEnv("CONFIG", "./hivedscheduler.yaml")
View Source
var EnvValueKubeApiServerAddress = common.GetEnv("KUBE_APISERVER_ADDRESS", "")
View Source
var EnvValueKubeConfigFilePath = common.GetEnv("KUBECONFIG", os.Getenv("HOME")+"/.kube/config")

Functions

func BuildKubeConfig

func BuildKubeConfig(sConfig *Config) *rest.Config

func WatchConfig added in v0.3.4

func WatchConfig(configPath *string, c *Config)

Types

type AffinityGroup

type AffinityGroup struct {
	ObjectMeta `json:"metadata"`
	Status     AffinityGroupStatus `json:"status"`
}

type AffinityGroupList added in v0.2.4

type AffinityGroupList struct {
	Items []AffinityGroup `json:"items"`
}

type AffinityGroupMemberBindInfo added in v0.2.0

type AffinityGroupMemberBindInfo struct {
	PodPlacements []PodPlacementInfo `yaml:"podPlacements"`
}

type AffinityGroupMemberSpec added in v0.2.0

type AffinityGroupMemberSpec struct {
	PodNumber      int32 `yaml:"podNumber"`
	LeafCellNumber int32 `yaml:"leafCellNumber"`
}

type AffinityGroupSpec added in v0.2.0

type AffinityGroupSpec struct {
	Name    string                    `yaml:"name"`
	Members []AffinityGroupMemberSpec `yaml:"members"`
}

type AffinityGroupState added in v0.3.1

type AffinityGroupState string

type AffinityGroupStatus added in v0.2.4

type AffinityGroupStatus struct {
	VC                   VirtualClusterName            `json:"vc"`
	Priority             int32                         `json:"priority"`
	State                AffinityGroupState            `json:"state"`
	PhysicalPlacement    map[string][]int32            `json:"physicalPlacement,omitempty"` // node -> leaf cell indices
	VirtualPlacement     map[CellAddress][]CellAddress `json:"virtualPlacement,omitempty"`  // preassigned cell -> leaf cells
	AllocatedPods        []types.UID                   `json:"allocatedPods,omitempty"`
	PreemptingPods       []types.UID                   `json:"preemptingPods,omitempty"`
	LazyPreemptionStatus *LazyPreemptionStatus         `json:"lazyPreemptionStatus,omitempty"`
}

type CellAddress

type CellAddress string

///////////////////////////////////////////////////////////////////////////////////// General Types /////////////////////////////////////////////////////////////////////////////////////

type CellHealthiness added in v0.3.0

type CellHealthiness string
const (
	CellHealthy CellHealthiness = "Healthy"
	CellBad     CellHealthiness = "Bad"
)

type CellState added in v0.3.0

type CellState string

type CellStatus added in v0.3.0

type CellStatus struct {
	LeafCellType string   `json:"leafCellType,omitempty"`
	CellType     CellType `json:"cellType"`
	IsNodeLevel  bool     `json:"isNodeLevel,omitempty"`
	// Address of a physical cell consists of its address (or index) in each level
	// (e.g., node0/0/0/0 may represent node0, CPU socket 0, PCIe switch 0, GPU 0.
	// Address of a virtual cell consists of its VC name, index of the preassigned cell,
	// and the relative index in each level inside the preassigned cell
	// (e.g., VC1/0/0 may represent VC1, preassigned cell 0, index 0 among its children)
	CellAddress CellAddress `json:"cellAddress"`
	// CellState and CellHealthiness are two orthogonal fields.
	// CellState represents whether the cell is used (or reserved) by an affinity group.
	// CellHealthiness represents whether the physical hardware is working normally.
	CellState       CellState       `json:"cellState"`
	CellHealthiness CellHealthiness `json:"cellHealthiness"`
	CellPriority    int32           `json:"cellPriority"`
}

type CellType

type CellType string

///////////////////////////////////////////////////////////////////////////////////// General Types /////////////////////////////////////////////////////////////////////////////////////

type CellTypeSpec

type CellTypeSpec struct {
	ChildCellType   CellType `yaml:"childCellType"`
	ChildCellNumber int32    `yaml:"childCellNumber"`
	IsNodeLevel     bool     `yaml:"isNodeLevel"`
}

type ClusterStatus added in v0.3.0

type ClusterStatus struct {
	// Status of cells in the physical cluster
	PhysicalCluster PhysicalClusterStatus `json:"physicalCluster"`
	// Status of cells in each VC
	VirtualClusters map[VirtualClusterName]VirtualClusterStatus `json:"virtualClusters"`
}

type Config

type Config struct {
	// KubeApiServerAddress is default to ${KUBE_APISERVER_ADDRESS}.
	// KubeConfigFilePath is default to ${KUBECONFIG} then falls back to ${HOME}/.kube/config.
	//
	// If both KubeApiServerAddress and KubeConfigFilePath after defaulting are still empty, falls back to the
	// [k8s inClusterConfig](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod).
	//
	// If both KubeApiServerAddress and KubeConfigFilePath after defaulting are not empty,
	// KubeApiServerAddress overrides the server address specified in the file referred by KubeConfigFilePath.
	//
	// If only KubeApiServerAddress after defaulting is not empty, it should be an insecure ApiServer address (can be got from
	// [Insecure ApiServer](https://kubernetes.io/docs/reference/access-authn-authz/controlling-access/#api-server-ports-and-ips) or
	// [kubectl proxy](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#using-kubectl-proxy))
	// which does not enforce authentication.
	//
	// If only KubeConfigFilePath after defaulting is not empty, it should be an valid
	// [KubeConfig File](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#explore-the-home-kube-directory)
	// which inlines or refers the valid
	// [ApiServer Credential Files](https://kubernetes.io/docs/reference/access-authn-authz/controlling-access/#transport-security).
	//
	// Address should be in format http[s]://host:port
	KubeApiServerAddress *string `yaml:"kubeApiServerAddress"`
	KubeConfigFilePath   *string `yaml:"kubeConfigFilePath"`

	// WebServer
	// Default to :9096
	WebServerAddress *string `yaml:"webServerAddress"`

	// Specify a threshold for PodBindAttempts, that after it is exceeded, an extra
	// Pod binding will be executed forcefully.
	ForcePodBindThreshold *int32 `yaml:"forcePodBindThreshold"`

	// If a Pod is decided to be PodWaiting, it will block the whole scheduling by
	// WaitingPodSchedulingBlockMilliSec.
	// Large value can be used to achieve stronger FIFO scheduling by sacrificing
	// the scheduling throughput.
	// This is a workaround until PodMaxBackoffSeconds can be configured for
	// K8S Default Scheduler.
	WaitingPodSchedulingBlockMilliSec *int64 `yaml:"waitingPodSchedulingBlockMilliSec"`

	// Specify the whole physical cluster
	// TODO: Automatically construct it based on node info from Device Plugins
	PhysicalCluster *PhysicalClusterSpec `yaml:"physicalCluster"`

	// Specify all the virtual clusters belongs to the physical cluster
	VirtualClusters *map[VirtualClusterName]VirtualClusterSpec `yaml:"virtualClusters"`
}

func InitRawConfig added in v0.2.4

func InitRawConfig(configPath *string) *Config

func NewConfig

func NewConfig(rawConfig *Config) *Config

type LazyPreemptionStatus added in v0.2.4

type LazyPreemptionStatus struct {
	// The AffinityGroup who has lazy preempted it.
	Preemptor string `json:"preemptor"`
	// It was lazy preempted at PreemptionTime.
	PreemptionTime meta.Time `json:"preemptionTime"`
}

type ObjectMeta added in v0.2.4

type ObjectMeta struct {
	Name string `json:"name"`
}

WebServer Exposed Objects: Align with K8S Objects

type PhysicalCellSpec

type PhysicalCellSpec struct {
	CellType     CellType           `yaml:"cellType"`
	CellAddress  CellAddress        `yaml:"cellAddress"`
	PinnedCellId PinnedCellId       `yaml:"pinnedCellId"`
	CellChildren []PhysicalCellSpec `yaml:"cellChildren,omitempty"`
}

Specify physical Cell instances.

type PhysicalCellStatus added in v0.3.0

type PhysicalCellStatus struct {
	CellStatus
	CellChildren []*PhysicalCellStatus `json:"cellChildren,omitempty"`
	VC           VirtualClusterName    `json:"vc,omitempty"`
	VirtualCell  *VirtualCellStatus    `json:"virtualCell,omitempty"`
}

type PhysicalClusterSpec

type PhysicalClusterSpec struct {
	CellTypes     map[CellType]CellTypeSpec `yaml:"cellTypes"`
	PhysicalCells []PhysicalCellSpec        `yaml:"physicalCells"`
}

Physical cluster definition

type PhysicalClusterStatus added in v0.3.0

type PhysicalClusterStatus []*PhysicalCellStatus

func (PhysicalClusterStatus) DeepCopy added in v0.3.0

type PinnedCellId added in v0.3.3

type PinnedCellId string

///////////////////////////////////////////////////////////////////////////////////// General Types /////////////////////////////////////////////////////////////////////////////////////

type PinnedCellSpec added in v0.3.3

type PinnedCellSpec struct {
	PinnedCellId PinnedCellId `yaml:"pinnedCellId"`
}

type PodBindInfo

type PodBindInfo struct {
	Node                  string                        `yaml:"node"`              // node to bind
	LeafCellIsolation     []int32                       `yaml:"leafCellIsolation"` // leaf cells to bind
	CellChain             string                        `yaml:"cellChain"`         // cell chain selected
	AffinityGroupBindInfo []AffinityGroupMemberBindInfo `yaml:"affinityGroupBindInfo"`
}

Used to recover scheduler allocated resource

type PodPlacementInfo added in v0.2.0

type PodPlacementInfo struct {
	PhysicalNode            string  `yaml:"physicalNode"`
	PhysicalLeafCellIndices []int32 `yaml:"physicalLeafCellIndices"`
	// preassigned cell types used by the pods. used to locate the virtual cells
	// when adding an allocated pod
	PreassignedCellTypes []CellType `yaml:"preassignedCellTypes"`
}

type PodSchedulingSpec

type PodSchedulingSpec struct {
	VirtualCluster          VirtualClusterName `yaml:"virtualCluster"`
	Priority                int32              `yaml:"priority"`
	PinnedCellId            PinnedCellId       `yaml:"pinnedCellId"`
	LeafCellType            string             `yaml:"leafCellType"`
	LeafCellNumber          int32              `yaml:"leafCellNumber"`
	GangReleaseEnable       bool               `yaml:"gangReleaseEnable"`
	LazyPreemptionEnable    bool               `yaml:"lazyPreemptionEnable"`
	IgnoreK8sSuggestedNodes bool               `yaml:"ignoreK8sSuggestedNodes" default:"true"`
	AffinityGroup           *AffinityGroupSpec `yaml:"affinityGroup"`
}

type VirtualCellSpec

type VirtualCellSpec struct {
	CellNumber int32    `yaml:"cellNumber"`
	CellType   CellType `yaml:"cellType"`
}

type VirtualCellStatus added in v0.3.0

type VirtualCellStatus struct {
	CellStatus
	CellChildren []*VirtualCellStatus `json:"cellChildren,omitempty"`
	PhysicalCell *PhysicalCellStatus  `json:"physicalCell,omitempty"`
}

type VirtualClusterName

type VirtualClusterName string

Virtual cluster definition

type VirtualClusterSpec

type VirtualClusterSpec struct {
	VirtualCells []VirtualCellSpec `yaml:"virtualCells"`
	PinnedCells  []PinnedCellSpec  `yaml:"pinnedCells,omitempty"`
}

type VirtualClusterStatus added in v0.3.0

type VirtualClusterStatus []*VirtualCellStatus

func (VirtualClusterStatus) DeepCopy added in v0.3.0

type WebServerError

type WebServerError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func NewWebServerError

func NewWebServerError(code int, message string) *WebServerError

func (*WebServerError) Error

func (err *WebServerError) Error() string

type WebServerPaths

type WebServerPaths struct {
	Paths []string `json:"paths"`
}

Jump to

Keyboard shortcuts

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