metadataserver

package
v0.0.0-...-4729a3b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package metadataserver performs requests to the metadata server of a GCE instance.

Interfacing with the metadata server is necessary to obtain project-level and per-instance metadata for use by the gcagent. Requests to the metadata server will also be used as a logging mechanism for gcagent usage metrics.

Index

Constants

View Source
const (
	ImageUnknown       = "unknown"
	MachineTypeUnknown = "unknown"
)

Default values if information cannot be obtained from the metadata server.

View Source
const (

	// PlatformCloudRun identifies Google Cloud Run environments.
	PlatformCloudRun = "CLOUD_RUN"
)

Variables

This section is empty.

Functions

func DiskTypeWithRetry

func DiskTypeWithRetry(bo backoff.BackOff, disk string) string

DiskTypeWithRetry fetches disk information from the GCE metadata server with a retry mechanism.

If there are any persistent errors in fetching this information, then the error will be logged and the return value will be "".

func FetchGCEMaintenanceEvent

func FetchGCEMaintenanceEvent() (string, error)

FetchGCEMaintenanceEvent retrieves information about pending host maintenance events.

func FetchGCEUpcomingMaintenance

func FetchGCEUpcomingMaintenance() (string, error)

FetchGCEUpcomingMaintenance retrieves information about upcoming host maintenance events.

func InstanceAttributeWithRetry

func InstanceAttributeWithRetry(bo backoff.BackOff, key string) string

InstanceAttributeWithRetry fetches instance attributes from the GCE metadata server with a retry mechanism.

If there are any persistent errors in fetching this information, then the error will be logged and the return value will be "".

Types

type CloudProperties

type CloudProperties struct {
	ProjectID, NumericProjectID, InstanceID, Zone, InstanceName, Image, MachineType, Region string
	// Platform identifies the compute environment, e.g., default = GCE can be CLOUD_RUN.
	Platform            string
	JobName             string // Cloud Run job name
	Scopes              []string
	ServiceAccountEmail string
}

CloudProperties contains the cloud properties of the instance.

func FetchCloudProperties

func FetchCloudProperties() *CloudProperties

FetchCloudProperties retrieves the cloud properties using a backoff policy.

func ReadCloudPropertiesWithRetry

func ReadCloudPropertiesWithRetry(bo backoff.BackOff) *CloudProperties

ReadCloudPropertiesWithRetry fetches information from the GCE metadata server with a retry mechanism.

If there are any persistent errors in fetching this information, then the error will be logged and the return value will be nil.

type GetCloudProperties

type GetCloudProperties func() *CloudProperties

GetCloudProperties abstracts metadataserver.FetchCloudProperties function for testability.

Jump to

Keyboard shortcuts

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