v1

package
v0.12.13 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package v1 provides the gpud v1 client for the server.

Index

Constants

This section is empty.

Variables

View Source
var ErrServerNotReady = errors.New("server not ready, timeout waiting")

Functions

func BlockUntilServerReady

func BlockUntilServerReady(ctx context.Context, addr string, opts ...OpOption) error

func CheckHealthz

func CheckHealthz(ctx context.Context, addr string, opts ...OpOption) error

func DeregisterComponent added in v0.5.0

func DeregisterComponent(ctx context.Context, addr string, componentName string, opts ...OpOption) error

DeregisterComponent deregisters the component from the server, by using the component name. It fails if the component has not been registered yet or is not deregisterable.

func GetComponents

func GetComponents(ctx context.Context, addr string, opts ...OpOption) ([]string, error)

func GetEvents

func GetEvents(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentEvents, error)

func GetHealthStates added in v0.5.0

func GetHealthStates(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentHealthStates, error)

GetHealthStates returns health states from the server for the given components.

Example:

baseURL := "https://localhost:15132"
for _, componentName := range []string{"disk", "accelerator-nvidia-info"} {
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()
	states, err := GetHealthStates(ctx, baseURL, WithComponent(componentName))
	if err != nil {
		if errdefs.IsNotFound(err) {
			log.Logger.Warnw("component not found", "component", componentName)
			return
		}

		log.Logger.Error("error fetching component info", "error", err)
		return
	}

	for _, ss := range states {
		for _, s := range ss.States {
			log.Logger.Infof("state: %q, health: %s\n", s.Name, s.Health)
		}
	}
}

func GetInfo

func GetInfo(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentInfos, error)

GetInfo returns component information from the server.

Example:

baseURL := "https://localhost:15132"
componentName := "" // Leave empty to query all components

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
info, err := GetInfo(ctx, baseURL, WithComponent(componentName))
if err != nil {
	fmt.Println("Error fetching component info:", err)
	return
}

fmt.Println("Component Information:")
for _, i := range info {
	fmt.Printf("Component: %s\n", i.Component)
	for _, event := range i.Info.Events {
		fmt.Printf("  Event: %s - %s\n", event.Name, event.Message)
	}
	for _, metric := range i.Info.Metrics {
		fmt.Printf("  Metric: %s (labels: %q) - Value: %f\n", metric.Name, metric.Labels, metric.Value)
	}
	for _, state := range i.Info.States {
		fmt.Printf("  State: %s - Health: %s\n", state.Name, state.Health)
	}
}

func GetMachineInfo added in v0.5.0

func GetMachineInfo(ctx context.Context, addr string, opts ...OpOption) (*apiv1.MachineInfo, error)

func GetMetrics

func GetMetrics(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentMetrics, error)

func GetPackageStatus added in v0.4.3

func GetPackageStatus(ctx context.Context, url string, opts ...OpOption) ([]packages.PackageStatus, error)

GetPackageStatus fetches the GPUd package status from the GPUd admin API.

func GetPluginSpecs added in v0.5.0

func GetPluginSpecs(ctx context.Context, addr string, opts ...OpOption) (pkgcustomplugins.Specs, error)

GetPluginSpecs returns the custom plugins registered in the server.

func ReadComponents

func ReadComponents(rd io.Reader, opts ...OpOption) ([]string, error)

func ReadEvents

func ReadEvents(rd io.Reader, opts ...OpOption) (v1.GPUdComponentEvents, error)

func ReadHealthStates added in v0.5.0

func ReadHealthStates(rd io.Reader, opts ...OpOption) (v1.GPUdComponentHealthStates, error)

func ReadInfo

func ReadInfo(rd io.Reader, opts ...OpOption) (v1.GPUdComponentInfos, error)

func ReadMetrics

func ReadMetrics(rd io.Reader, opts ...OpOption) (v1.GPUdComponentMetrics, error)

func ReadPluginSpecs added in v0.5.0

func ReadPluginSpecs(rd io.Reader, opts ...OpOption) (pkgcustomplugins.Specs, error)

ReadPluginSpecs reads the custom plugin specs from the server.

func SetHealthyComponents added in v0.8.0

func SetHealthyComponents(ctx context.Context, addr string, components []string, opts ...OpOption) ([]string, error)

SetHealthyComponents sets specified components to healthy state

func TriggerComponent added in v0.5.0

func TriggerComponent(ctx context.Context, addr string, componentName string, opts ...OpOption) (v1.GPUdComponentHealthStates, error)

TriggerComponent manually triggers a component check.

func TriggerComponentCheckByTag added in v0.5.0

func TriggerComponentCheckByTag(ctx context.Context, addr string, tagName string, opts ...OpOption) error

TriggerComponentCheckByTag triggers all components that have the specified tag

Types

type Op

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

type OpOption

type OpOption func(*Op)

func WithAcceptEncodingGzip

func WithAcceptEncodingGzip() OpOption

WithAcceptEncodingGzip requests gzip encoding for the response.

func WithComponent added in v0.0.2

func WithComponent(component string) OpOption

func WithRequestContentTypeJSON

func WithRequestContentTypeJSON() OpOption

WithRequestContentTypeJSON sets the request content type to JSON.

func WithRequestContentTypeYAML

func WithRequestContentTypeYAML() OpOption

WithRequestContentTypeYAML sets the request content type to YAML.

Jump to

Keyboard shortcuts

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