bridge

package
v0.0.0-...-4c20933 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// NATSBackoffInitialInterval is the initial interval at which to start the backoff retry.
	NATSBackoffInitialInterval = 30 * time.Second
	// NATSBackoffMultipler is the multiplier for the backoff interval.
	NATSBackoffMultipler = 2
	// NATSBackoffMaxElapsedTime is the maximum elapsed time that we should retry.
	NATSBackoffMaxElapsedTime = 10 * time.Minute
)
View Source
const (

	// HeartbeatTopic is the topic that heartbeats are written to.
	HeartbeatTopic = "heartbeat"
)
View Source
const UpdaterJobYAML string = `` /* 1515-byte string literal not displayed */

UpdaterJobYAML is the YAML that should be applied for the updater job.

Variables

View Source
var ErrRegistrationTimeout = errors.New("Registration timeout")

ErrRegistrationTimeout is the registration timeout error.

Functions

func NewVZConnClient

func NewVZConnClient(vzOperator VizierOperatorInfo) (vzconnpb.VZConnServiceClient, error)

NewVZConnClient creates a new vzconn RPC client stub.

Types

type Bridge

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

Bridge is the NATS<->GRPC bridge.

func New

func New(vizierID uuid.UUID, assignedClusterName string, jwtSigningKey string, deployKey string, sessionID int64, vzClient vzconnpb.VZConnServiceClient, vzInfo VizierInfo, vzOperator VizierOperatorInfo, nc *nats.Conn, checker VizierHealthChecker, metricsCh <-chan *messagespb.MetricsMessage) *Bridge

New creates a cloud connector to cloud bridge.

func (*Bridge) DebugLog

DebugLog is the GRPC stream method to fetch debug logs from vizier.

func (*Bridge) DebugPods

DebugPods is the GRPC method to fetch the list of Vizier pods (and statuses) from a cluster.

func (*Bridge) GetStatus

func (s *Bridge) GetStatus() vzstatus.VizierReason

GetStatus returns a reason for the current state of the cloud bridge. If an empty string is returned, assume healthy.

func (*Bridge) HandleNATSBridging

func (s *Bridge) HandleNATSBridging(stream vzconnpb.VZConnService_NATSBridgeClient, done chan bool) error

HandleNATSBridging routes message to and from cloud NATS.

func (*Bridge) RegisterDeployment

func (s *Bridge) RegisterDeployment() error

RegisterDeployment registers the vizier cluster using the deployment key.

func (*Bridge) RunStream

func (s *Bridge) RunStream()

RunStream manages starting and restarting the stream to VZConn.

func (*Bridge) StartStream

func (s *Bridge) StartStream() error

StartStream starts the stream between the cloud connector and Vizier connector.

func (*Bridge) Stop

func (s *Bridge) Stop()

Stop terminates the server. Don't reuse this server object after stop has been called.

func (*Bridge) WaitForUpdater

func (s *Bridge) WaitForUpdater()

WaitForUpdater waits for the update job to complete, if any.

func (*Bridge) WatchDog

func (s *Bridge) WatchDog()

WatchDog watches and make sure the bridge is functioning. If not commits suicide to try to self-heal.

type K8sJobHandler

type K8sJobHandler interface {
	CleanupCronJob(string, time.Duration, chan bool)
}

K8sJobHandler manages k8s jobs.

type K8sState

type K8sState struct {
	// Pod statuses for Vizier control plane pods.
	ControlPlanePodStatuses map[string]*cvmsgspb.PodStatus
	// Pod statuses for a sample (10) of unhealthy Vizier pods.
	UnhealthyDataPlanePodStatuses map[string]*cvmsgspb.PodStatus
	// The current K8s version of Vizier.
	K8sClusterVersion string
	// The number of nodes on the cluster.
	NumNodes int32
	// The number of nodes on the cluster that are running a PEM.
	NumInstrumentedNodes int32
	// The last time this information was updated.
	LastUpdated time.Time
}

K8sState describes the Kubernetes state of the Vizier instance.

type K8sVizierInfo

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

K8sVizierInfo is responsible for fetching Vizier information through K8s.

func NewK8sVizierInfo

func NewK8sVizierInfo(clusterName, ns string) (*K8sVizierInfo, error)

NewK8sVizierInfo creates a new K8sVizierInfo.

func (*K8sVizierInfo) CleanupCronJob

func (v *K8sVizierInfo) CleanupCronJob(cronJob string, duration time.Duration, quitCh chan bool)

CleanupCronJob periodically cleans up any completed jobs that were run by the specified cronjob.

func (*K8sVizierInfo) CreateSecret

func (v *K8sVizierInfo) CreateSecret(name string, literals map[string]string) error

CreateSecret creates the K8s secret.

func (*K8sVizierInfo) DeleteJob

func (v *K8sVizierInfo) DeleteJob(name string) error

DeleteJob deletes the job with the specified name.

func (*K8sVizierInfo) GetClusterUID

func (v *K8sVizierInfo) GetClusterUID() (string, error)

GetClusterUID gets UID for the cluster, represented by the kube-system namespace UID.

func (*K8sVizierInfo) GetJob

func (v *K8sVizierInfo) GetJob(name string) (*batchv1.Job, error)

GetJob gets the job with the specified name.

func (*K8sVizierInfo) GetK8sState

func (v *K8sVizierInfo) GetK8sState() *K8sState

GetK8sState gets the pod statuses and the last time they were updated.

func (*K8sVizierInfo) GetVizierCRD

func (v *K8sVizierInfo) GetVizierCRD() (*v1alpha1.Vizier, error)

GetVizierCRD gets the Vizier CRD for the running Vizier, if running using an operator.

func (*K8sVizierInfo) GetVizierClusterInfo

func (v *K8sVizierInfo) GetVizierClusterInfo() (*cvmsgspb.VizierClusterInfo, error)

GetVizierClusterInfo gets the K8s cluster info for the current running vizier.

func (*K8sVizierInfo) GetVizierPodLogs

func (v *K8sVizierInfo) GetVizierPodLogs(podName string, previous bool, container string) (string, error)

GetVizierPodLogs gets the k8s logs for the Vizier pod with the given name.

func (*K8sVizierInfo) GetVizierPods

func (v *K8sVizierInfo) GetVizierPods() ([]*vizierpb.VizierPodStatus, []*vizierpb.VizierPodStatus, error)

GetVizierPods gets the Vizier pods and their statuses.

func (*K8sVizierInfo) LaunchJob

func (v *K8sVizierInfo) LaunchJob(j *batchv1.Job) (*batchv1.Job, error)

LaunchJob starts the specified job.

func (*K8sVizierInfo) ParseJobYAML

func (v *K8sVizierInfo) ParseJobYAML(yamlStr string, imageTag map[string]string, envSubtitutions map[string]string) (*batchv1.Job, error)

ParseJobYAML parses the yaml string into a k8s job and applies the image tag and env subtitutions.

func (*K8sVizierInfo) UpdateCRDVizierVersion

func (v *K8sVizierInfo) UpdateCRDVizierVersion(version string) (bool, error)

UpdateCRDVizierVersion updates the version of the Vizier CRD in the namespace. Returns an error if the CRD was not found, or if an error occurred while updating the CRD. Returns whether or not an update was actually initiated. This is used to determine whether the vizier should actually be in "UPDATING" status, in the case of falsely initated update requests. This will be fixed as we move to having the operator fully manage vizier statuses.

func (*K8sVizierInfo) UpdateClusterID

func (v *K8sVizierInfo) UpdateClusterID(id string) error

UpdateClusterID updates the cluster ID in the cluster secrets.

func (*K8sVizierInfo) UpdateClusterIDAnnotation

func (v *K8sVizierInfo) UpdateClusterIDAnnotation(id string) error

UpdateClusterIDAnnotation updates the `cluster-id` annotation for the cloudconnector.

func (*K8sVizierInfo) UpdateClusterName

func (v *K8sVizierInfo) UpdateClusterName(id string) error

UpdateClusterName updates the cluster ID in the cluster secrets.

func (*K8sVizierInfo) UpdateK8sState

func (v *K8sVizierInfo) UpdateK8sState()

UpdateK8sState gets the relevant state of the cluster, such as pod statuses, at the current moment in time.

func (*K8sVizierInfo) WaitForJobCompletion

func (v *K8sVizierInfo) WaitForJobCompletion(name string) (bool, error)

WaitForJobCompletion waits for the job with given name to complete.

type VizierHealthChecker

type VizierHealthChecker interface {
	GetStatus() (time.Time, error)
}

VizierHealthChecker is the interface that gets information on health of a Vizier.

type VizierInfo

type VizierInfo interface {
	GetVizierClusterInfo() (*cvmsgspb.VizierClusterInfo, error)
	GetK8sState() *K8sState
	ParseJobYAML(yamlStr string, imageTag map[string]string, envSubtitutions map[string]string) (*batchv1.Job, error)
	LaunchJob(j *batchv1.Job) (*batchv1.Job, error)
	CreateSecret(string, map[string]string) error
	WaitForJobCompletion(string) (bool, error)
	DeleteJob(string) error
	GetJob(string) (*batchv1.Job, error)
	GetClusterUID() (string, error)
	UpdateClusterID(string) error
	UpdateClusterName(string) error
	UpdateClusterIDAnnotation(string) error
	GetVizierPodLogs(string, bool, string) (string, error)
	GetVizierPods() ([]*vizierpb.VizierPodStatus, []*vizierpb.VizierPodStatus, error)
}

VizierInfo fetches information about Vizier.

type VizierOperatorInfo

type VizierOperatorInfo interface {
	UpdateCRDVizierVersion(string) (bool, error)
	GetVizierCRD() (*v1alpha1.Vizier, error)
}

VizierOperatorInfo updates and fetches info about the Vizier CRD.

Jump to

Keyboard shortcuts

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