barrier

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ComponentName           = "frameworkbarrier"
	FrameworkObjectFilePath = "./framework.json"
	InjectorFilePath        = "./injector.sh"

	EnvNameBarrierCheckIntervalSec = "BARRIER_CHECK_INTERVAL_SEC"
	EnvNameBarrierCheckTimeoutSec  = "BARRIER_CHECK_TIMEOUT_SEC"
)

///////////////////////////////////////////////////////////////////////////////////// Constants /////////////////////////////////////////////////////////////////////////////////////

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// See the same fields in pkg/apis/frameworkcontroller/v1/config.go
	KubeApiServerAddress string `yaml:"kubeApiServerAddress"`
	KubeConfigFilePath   string `yaml:"kubeConfigFilePath"`

	// The Framework for which the barrier waits.
	FrameworkNamespace string `yaml:"frameworkNamespace"`
	FrameworkName      string `yaml:"frameworkName"`

	// Check interval and timeout to expect all Tasks in the Framework reach the
	// barrier, i.e. are ready with not nil PodIP.
	BarrierCheckIntervalSec int64 `yaml:"barrierCheckIntervalSec"`
	BarrierCheckTimeoutSec  int64 `yaml:"barrierCheckTimeoutSec"`
}

///////////////////////////////////////////////////////////////////////////////////// Config /////////////////////////////////////////////////////////////////////////////////////

type FrameworkBarrier

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

FrameworkController Extension: FrameworkBarrier

Best Practice: It is usually used as the initContainer to provide a simple way to:

  1. Do Gang Execution without resource deadlock. So that the AppContainers of all Tasks in the Framework will be executed in an all-or-nothing fashion without the need for Gang Scheduling.
  2. Start the AppContainers in the Pod only after its PodUID is persisted in the Framework object by FrameworkController. So that the completion or deletion event of a Pod with started AppContainers will never be missed by FrameworkController to further trigger RetryPolicy or FrameworkAttemptCompletionPolicy.
  3. Inject peer-to-peer service discovery information into the AppContainers. So that any Task in the Framework is able to discover all other Tasks in the same Framework without the need for k8s DNS.

Usage: It waits until all Tasks in the specified Framework object are ready with not nil PodIP and then dumps the Framework object to local file: ./framework.json, besides it also generates the injector script to local file: ./injector.sh which provides a default way to inject some Framework information into caller process.

./injector.sh exports below environment variables: For each {TaskRoleName} in the Framework:

FB_{UpperCase({TaskRoleName})}_IPS=
  {Task[0].PodIP},...,
  {Task[TaskRole.TaskNumber-1].PodIP}
FB_{UpperCase({TaskRoleName})}_ADDRESSES=
  {Task[0].PodIP}:${FB_{UpperCase({TaskRoleName})}_PORT},...,
  {Task[TaskRole.TaskNumber-1].PodIP}:${FB_{UpperCase({TaskRoleName})}_PORT}
Note, the environment variable FB_{UpperCase({TaskRoleName})}_PORT should be
provided by the caller in advance.

Caller can also write its own injector script to inject other Framework information from the ./framework.json.

func NewFrameworkBarrier

func NewFrameworkBarrier() *FrameworkBarrier

///////////////////////////////////////////////////////////////////////////////////// Methods /////////////////////////////////////////////////////////////////////////////////////

func (*FrameworkBarrier) Run

func (b *FrameworkBarrier) Run()

Jump to

Keyboard shortcuts

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