bbs

package module
v0.0.0-...-d12ace5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

BBS

Bulletin Board System (BBS) is the API to access the database for Diego. It communicates via protocol-buffer-encoded RPC-style calls over HTTP.

[!NOTE]

This repository should be imported as code.cloudfoundry.org/bbs.

Docs

Contributing

See the Contributing.md for more information on how to contribute.

Working Group Charter

This repository is maintained by App Runtime Platform under Diego area.

[!IMPORTANT]

Content in this file is managed by the CI task sync-readme and is generated by CI following a convention.

Documentation

Index

Constants

View Source
const (
	ContentTypeHeader    = "Content-Type"
	XCfRouterErrorHeader = "X-Cf-Routererror"
	ProtoContentType     = "application/x-protobuf"
	KeepContainer        = true
	DeleteContainer      = false
	DefaultRetryCount    = 3

	InvalidResponseMessage = "Invalid Response with status code: %d"
)
View Source
const (
	// Ping
	PingRoute_r0 = "Ping"

	// Domains
	DomainsRoute_r0      = "Domains"
	UpsertDomainRoute_r0 = "UpsertDomain"

	// Actual LRPs
	ActualLRPsRoute_r0 = "ActualLRPs"
	// Deprecated: use the ActualLRPInstances API instead
	ActualLRPGroupsRoute_r0 = "ActualLRPGroups"
	// Deprecated: use the ActualLRPInstances API instead
	ActualLRPGroupsByProcessGuidRoute_r0 = "ActualLRPGroupsByProcessGuid"
	// Deprecated: use the ActualLRPInstances API instead
	ActualLRPGroupByProcessGuidAndIndexRoute_r0 = "ActualLRPGroupsByProcessGuidAndIndex"

	// Actual LRP Lifecycle
	ClaimActualLRPRoute_r0 = "ClaimActualLRP"
	StartActualLRPRoute_r1 = "StartActualLRP"
	// Deprecated: use StartActaulLRPRoute_r1 instead
	StartActualLRPRoute_r0  = "StartActualLRP_r0"
	CrashActualLRPRoute_r0  = "CrashActualLRP"
	FailActualLRPRoute_r0   = "FailActualLRP"
	RemoveActualLRPRoute_r0 = "RemoveActualLRP"
	RetireActualLRPRoute_r0 = "RetireActualLRP"

	// Evacuation
	RemoveEvacuatingActualLRPRoute_r0 = "RemoveEvacuatingActualLRP"
	EvacuateClaimedActualLRPRoute_r0  = "EvacuateClaimedActualLRP"
	EvacuateCrashedActualLRPRoute_r0  = "EvacuateCrashedActualLRP"
	EvacuateStoppedActualLRPRoute_r0  = "EvacuateStoppedActualLRP"
	EvacuateRunningActualLRPRoute_r1  = "EvacuateRunningActualLRP"
	// Deprecated: use EvacuateRunningActualLRPRoute_r1 instead
	EvacuateRunningActualLRPRoute_r0 = "EvacuateRunningActualLRP_r0"

	// Desired LRPs
	DesiredLRPsRoute_r3                      = "DesiredLRPs"
	DesiredLRPSchedulingInfosRoute_r0        = "DesiredLRPSchedulingInfos"
	DesiredLRPSchedulingInfoByProcessGuid_r0 = "DesiredLRPSchedulingInfoByProcessGuid"
	DesiredLRPRoutingInfosRoute_r0           = "DesiredLRPRoutingInfos"
	DesiredLRPByProcessGuidRoute_r3          = "DesiredLRPByProcessGuid"
	// Deprecated: use DsiredLRPByProcessGuidRoute_r3 instead
	DesiredLRPsRoute_r2 = "DesiredLRPs_r2"
	// Deprecated: use DsiredLRPByProcessGuidRoute_r3 instead
	DesiredLRPByProcessGuidRoute_r2 = "DesiredLRPByProcessGuid_r2"

	// Desire LRP Lifecycle
	DesireDesiredLRPRoute_r2 = "DesireDesiredLRP"
	UpdateDesiredLRPRoute_r0 = "UpdateDesireLRP"
	RemoveDesiredLRPRoute_r0 = "RemoveDesiredLRP"

	// Tasks
	TasksRoute_r3      = "Tasks"
	TaskByGuidRoute_r3 = "TaskByGuid"
	DesireTaskRoute_r2 = "DesireTask"
	StartTaskRoute_r0  = "StartTask"
	CancelTaskRoute_r0 = "CancelTask"
	// Deprecated: use CancelTaskRotue_r0 instead
	FailTaskRoute_r0      = "FailTask"
	RejectTaskRoute_r0    = "RejectTask"
	CompleteTaskRoute_r0  = "CompleteTask"
	ResolvingTaskRoute_r0 = "ResolvingTask"
	DeleteTaskRoute_r0    = "DeleteTask"
	// Deprecated: use TaskRoute_r3 instead
	TasksRoute_r2 = "Tasks_r2"
	// Deprecated: use TaskByGuid_r3 instead
	TaskByGuidRoute_r2 = "TaskByGuid_r2"

	// Event Streaming
	//Deprecated: use LRPInstanceEventStreamRoute_1 instead
	LRPGroupEventStreamRoute_r1    = "EventStream"
	TaskEventStreamRoute_r1        = "TaskEventStream"
	LRPInstanceEventStreamRoute_r1 = "LRPInstanceEventStream"
	//Deprecated: use LRPInstanceEventStreamRoute_1 instead
	EventStreamRoute_r0 = "EventStream_r0"
	// Deprecated: use TaskEventStreamRoute_r1 instead
	TaskEventStreamRoute_r0 = "TaskEventStream_r0"
	//Deprecated: use LrpInstanceEventStreamRoute_r1 instead
	LrpInstanceEventStreamRoute_r0 = "LrpInstanceEventStream_r0"

	// Cell Presence
	CellsRoute_r0 = "Cells"
)

Variables

View Source
var Routes = rata.Routes{

	{Path: "/v1/ping", Method: "POST", Name: PingRoute_r0},

	{Path: "/v1/domains/list", Method: "POST", Name: DomainsRoute_r0},
	{Path: "/v1/domains/upsert", Method: "POST", Name: UpsertDomainRoute_r0},

	{Path: "/v1/actual_lrps/list", Method: "POST", Name: ActualLRPsRoute_r0},
	{Path: "/v1/actual_lrp_groups/list", Method: "POST", Name: ActualLRPGroupsRoute_r0},
	{Path: "/v1/actual_lrp_groups/list_by_process_guid", Method: "POST", Name: ActualLRPGroupsByProcessGuidRoute_r0},
	{Path: "/v1/actual_lrp_groups/get_by_process_guid_and_index", Method: "POST", Name: ActualLRPGroupByProcessGuidAndIndexRoute_r0},

	{Path: "/v1/actual_lrps/claim", Method: "POST", Name: ClaimActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/start.r1", Method: "POST", Name: StartActualLRPRoute_r1},
	{Path: "/v1/actual_lrps/start", Method: "POST", Name: StartActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/crash", Method: "POST", Name: CrashActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/fail", Method: "POST", Name: FailActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/remove", Method: "POST", Name: RemoveActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/retire", Method: "POST", Name: RetireActualLRPRoute_r0},

	{Path: "/v1/actual_lrps/remove_evacuating", Method: "POST", Name: RemoveEvacuatingActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/evacuate_claimed", Method: "POST", Name: EvacuateClaimedActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/evacuate_crashed", Method: "POST", Name: EvacuateCrashedActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/evacuate_stopped", Method: "POST", Name: EvacuateStoppedActualLRPRoute_r0},
	{Path: "/v1/actual_lrps/evacuate_running.r1", Method: "POST", Name: EvacuateRunningActualLRPRoute_r1},
	{Path: "/v1/actual_lrps/evacuate_running", Method: "POST", Name: EvacuateRunningActualLRPRoute_r0},

	{Path: "/v1/desired_lrp_scheduling_infos/list", Method: "POST", Name: DesiredLRPSchedulingInfosRoute_r0},
	{Path: "/v1/desired_lrp_scheduling_infos/get_by_process_guid", Method: "POST", Name: DesiredLRPSchedulingInfoByProcessGuid_r0},
	{Path: "/v1/desired_lrp_routing_infos/list", Method: "POST", Name: DesiredLRPRoutingInfosRoute_r0},

	{Path: "/v1/desired_lrps/list.r3", Method: "POST", Name: DesiredLRPsRoute_r3},
	{Path: "/v1/desired_lrps/get_by_process_guid.r3", Method: "POST", Name: DesiredLRPByProcessGuidRoute_r3},
	{Path: "/v1/desired_lrps/list.r2", Method: "POST", Name: DesiredLRPsRoute_r2},
	{Path: "/v1/desired_lrps/get_by_process_guid.r2", Method: "POST", Name: DesiredLRPByProcessGuidRoute_r2},

	{Path: "/v1/desired_lrp/desire.r2", Method: "POST", Name: DesireDesiredLRPRoute_r2},
	{Path: "/v1/desired_lrp/update", Method: "POST", Name: UpdateDesiredLRPRoute_r0},
	{Path: "/v1/desired_lrp/remove", Method: "POST", Name: RemoveDesiredLRPRoute_r0},

	{Path: "/v1/tasks/list.r3", Method: "POST", Name: TasksRoute_r3},
	{Path: "/v1/tasks/get_by_task_guid.r3", Method: "POST", Name: TaskByGuidRoute_r3},
	{Path: "/v1/tasks/list.r2", Method: "POST", Name: TasksRoute_r2},
	{Path: "/v1/tasks/get_by_task_guid.r2", Method: "POST", Name: TaskByGuidRoute_r2},

	{Path: "/v1/tasks/desire.r2", Method: "POST", Name: DesireTaskRoute_r2},
	{Path: "/v1/tasks/start", Method: "POST", Name: StartTaskRoute_r0},
	{Path: "/v1/tasks/cancel", Method: "POST", Name: CancelTaskRoute_r0},
	{Path: "/v1/tasks/fail", Method: "POST", Name: FailTaskRoute_r0},
	{Path: "/v1/tasks/reject", Method: "POST", Name: RejectTaskRoute_r0},
	{Path: "/v1/tasks/complete", Method: "POST", Name: CompleteTaskRoute_r0},
	{Path: "/v1/tasks/resolving", Method: "POST", Name: ResolvingTaskRoute_r0},
	{Path: "/v1/tasks/delete", Method: "POST", Name: DeleteTaskRoute_r0},

	{Path: "/v1/events.r1", Method: "GET", Name: LRPGroupEventStreamRoute_r1},
	{Path: "/v1/events/tasks.r1", Method: "POST", Name: TaskEventStreamRoute_r1},
	{Path: "/v1/events/lrp_instances.r1", Method: "POST", Name: LRPInstanceEventStreamRoute_r1},
	{Path: "/v1/events", Method: "GET", Name: EventStreamRoute_r0},
	{Path: "/v1/events/tasks", Method: "POST", Name: TaskEventStreamRoute_r0},
	{Path: "/v1/events/lrp_instances", Method: "POST", Name: LrpInstanceEventStreamRoute_r0},

	{Path: "/v1/cells/list.r1", Method: "POST", Name: CellsRoute_r0},
}

Functions

This section is empty.

Types

type Client

type Client interface {
	ExternalTaskClient
	ExternalDomainClient
	ExternalActualLRPClient
	ExternalDesiredLRPClient
	ExternalEventClient

	// Returns true if the BBS server is reachable
	Ping(logger lager.Logger, traceID string) bool

	// Lists all Cells
	Cells(logger lager.Logger, traceID string) ([]*models.CellPresence, error)
}

The External InternalClient can be used to access the BBS's public functionality. It exposes methods for basic LRP and Task Lifecycles, Domain manipulation, and event subscription.

type ClientConfig

type ClientConfig struct {
	URL                    string
	IsTLS                  bool
	CAFile                 string
	CertFile               string
	KeyFile                string
	ClientSessionCacheSize int
	MaxIdleConnsPerHost    int
	InsecureSkipVerify     bool
	Retries                int
	RetryInterval          time.Duration // Only affects streaming client, not the http client
	RequestTimeout         time.Duration // Only affects the http client, not the streaming client
}

type ExternalActualLRPClient

type ExternalActualLRPClient interface {
	// Returns all ActualLRPs matching the given ActualLRPFilter
	ActualLRPs(lager.Logger, string, models.ActualLRPFilter) ([]*models.ActualLRP, error)

	// Returns all ActualLRPGroups matching the given ActualLRPFilter
	//lint:ignore SA1019 - deprecated function returning deprecated data
	// Deprecated: use ActualLRPs instead
	ActualLRPGroups(lager.Logger, string, models.ActualLRPFilter) ([]*models.ActualLRPGroup, error)

	// Returns all ActualLRPGroups that have the given process guid
	//lint:ignore SA1019 - deprecated function returning deprecated data
	// Deprecated: use ActualLRPs instead
	ActualLRPGroupsByProcessGuid(logger lager.Logger, traceID string, processGuid string) ([]*models.ActualLRPGroup, error)

	// Returns the ActualLRPGroup with the given process guid and instance index
	//lint:ignore SA1019 - deprecated function returning deprecated data
	// Deprecated: use ActualLRPs instead
	ActualLRPGroupByProcessGuidAndIndex(logger lager.Logger, traceID string, processGuid string, index int) (*models.ActualLRPGroup, error)

	// Shuts down the ActualLRP matching the given ActualLRPKey, but does not modify the desired state
	RetireActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey) error
}

The ExternalActualLRPClient is used to access and retire Actual LRPs

type ExternalDesiredLRPClient

type ExternalDesiredLRPClient interface {
	// Lists all DesiredLRPs that match the given DesiredLRPFilter
	DesiredLRPs(lager.Logger, string, models.DesiredLRPFilter) ([]*models.DesiredLRP, error)

	// Returns the DesiredLRP with the given process guid
	DesiredLRPByProcessGuid(logger lager.Logger, traceID string, processGuid string) (*models.DesiredLRP, error)

	// Returns all DesiredLRPSchedulingInfos that match the given DesiredLRPFilter
	DesiredLRPSchedulingInfos(lager.Logger, string, models.DesiredLRPFilter) ([]*models.DesiredLRPSchedulingInfo, error)

	//Returns the DesiredLRPSchedulingInfo that matches the given process guid
	DesiredLRPSchedulingInfoByProcessGuid(logger lager.Logger, traceID string, processGuid string) (*models.DesiredLRPSchedulingInfo, error)

	// Returns all DesiredLRPRoutingInfos that match the given DesiredLRPFilter
	DesiredLRPRoutingInfos(lager.Logger, string, models.DesiredLRPFilter) ([]*models.DesiredLRP, error)

	// Creates the given DesiredLRP and its corresponding ActualLRPs
	DesireLRP(lager.Logger, string, *models.DesiredLRP) error

	// Updates the DesiredLRP matching the given process guid
	UpdateDesiredLRP(logger lager.Logger, traceID string, processGuid string, update *models.DesiredLRPUpdate) error

	// Removes the DesiredLRP matching the given process guid
	RemoveDesiredLRP(logger lager.Logger, traceID string, processGuid string) error
}

The ExternalDesiredLRPClient is used to access and manipulate Desired LRPs.

type ExternalDomainClient

type ExternalDomainClient interface {
	// Lists the active domains
	Domains(logger lager.Logger, traceID string) ([]string, error)

	// Creates a domain or bumps the ttl on an existing domain
	UpsertDomain(logger lager.Logger, traceID string, domain string, ttl time.Duration) error
}

The ExternalDomainClient is used to access and update Diego's domains.

type ExternalEventClient

type ExternalEventClient interface {
	// Deprecated: use SubscribeToInstanceEvents instead
	SubscribeToEvents(logger lager.Logger) (events.EventSource, error)

	SubscribeToInstanceEvents(logger lager.Logger) (events.EventSource, error)
	SubscribeToTaskEvents(logger lager.Logger) (events.EventSource, error)

	// Deprecated: use SubscribeToInstanceEventsByCellID instead
	SubscribeToEventsByCellID(logger lager.Logger, cellId string) (events.EventSource, error)

	SubscribeToInstanceEventsByCellID(logger lager.Logger, cellId string) (events.EventSource, error)
}

The ExternalEventClient is used to subscribe to groups of Events.

type ExternalTaskClient

type ExternalTaskClient interface {
	// Creates a Task from the given TaskDefinition
	DesireTask(logger lager.Logger, traceID string, guid string, domain string, def *models.TaskDefinition) error

	// Lists all Tasks
	Tasks(logger lager.Logger, traceID string) ([]*models.Task, error)

	// List all Tasks that match filter
	TasksWithFilter(logger lager.Logger, traceID string, filter models.TaskFilter) ([]*models.Task, error)

	// Lists all Tasks of the given domain
	TasksByDomain(logger lager.Logger, traceID string, domain string) ([]*models.Task, error)

	// Lists all Tasks on the given cell
	TasksByCellID(logger lager.Logger, traceID string, cellId string) ([]*models.Task, error)

	// Returns the Task with the given guid
	TaskByGuid(logger lager.Logger, traceID string, guid string) (*models.Task, error)

	// Cancels the Task with the given task guid
	CancelTask(logger lager.Logger, traceID string, taskGuid string) error

	// Resolves a Task with the given guid
	ResolvingTask(logger lager.Logger, traceID string, taskGuid string) error

	// Deletes a completed task with the given guid
	DeleteTask(logger lager.Logger, traceID string, taskGuid string) error
}

The ExternalTaskClient is used to access Diego's ability to run one-off tasks. More information about this API can be found in the bbs docs:

https://code.cloudfoundry.org/bbs/tree/master/doc/tasks.md

type InternalClient

type InternalClient interface {
	Client

	ClaimActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey) error
	StartActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey, netInfo *models.ActualLRPNetInfo, internalRoutes []*models.ActualLRPInternalRoute, metricTags map[string]string, routable bool, availabilityZone string) error
	CrashActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey, errorMessage string) error
	FailActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, errorMessage string) error
	RemoveActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey) error

	EvacuateClaimedActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey) (bool, error)
	EvacuateRunningActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey, netInfo *models.ActualLRPNetInfo, internalRoutes []*models.ActualLRPInternalRoute, metricTags map[string]string, routable bool, availabilityZone string) (bool, error)
	EvacuateStoppedActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey) (bool, error)
	EvacuateCrashedActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey, errorMessage string) (bool, error)
	RemoveEvacuatingActualLRP(logger lager.Logger, traceID string, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey) error

	StartTask(logger lager.Logger, traceID string, taskGuid string, cellID string) (bool, error)
	FailTask(logger lager.Logger, traceID string, taskGuid, failureReason string) error
	RejectTask(logger lager.Logger, traceID string, taskGuid, failureReason string) error
	CompleteTask(logger lager.Logger, traceID string, taskGuid, cellId string, failed bool, failureReason, result string) error
}

The InternalClient interface exposes all available endpoints of the BBS server, including private endpoints which should be used exclusively by internal Diego components. To interact with the BBS from outside of Diego, the Client should be used instead.

func NewClient

func NewClient(url, caFile, certFile, keyFile string, clientSessionCacheSize, maxIdleConnsPerHost int) (InternalClient, error)

func NewClientWithConfig

func NewClientWithConfig(cfg ClientConfig) (InternalClient, error)

func NewSecureSkipVerifyClient

func NewSecureSkipVerifyClient(url, certFile, keyFile string, clientSessionCacheSize, maxIdleConnsPerHost int) (InternalClient, error)

Directories

Path Synopsis
cmd
bbs
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
fake_controllers
Code generated by counterfeiter.
Code generated by counterfeiter.
db
dbfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
sqldb/fakesqldriver/fakesqldriverfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
sqldb/helpers/helpersfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
sqldb/helpers/monitor/monitorfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
encryptionfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
eventfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
guidproviderfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
fake_controllers
Code generated by counterfeiter.
Code generated by counterfeiter.
middleware/fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
metricsfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
migrationfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
serviceclientfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
taskworkpoolfakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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