cloudcommon

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlertAutoScaleUp                         = "AutoScaleUp"
	AlertAutoScaleDown                       = "AutoScaleDown"
	AlertClusterAutoScale                    = "ClusterAutoScale"
	AlertAppInstDown                         = "AppInstDown"
	AlertClusterSvcAppInstFailure            = "ClusterSvcAppInstFailure"
	AlertAutoUndeploy                        = "AutoProvUndeploy"
	AlertCloudletDown                        = "CloudletDown"
	AlertCloudletDownDescription             = "Cloudlet resource manager is offline"
	AlertClusterSvcAppInstFailureDescription = "Cluster-svc create AppInst failed"
	AlertCloudletResourceUsage               = "CloudletResourceUsage"
	AlertTypeUserDefined                     = "UserDefined"
)

Alert names

View Source
const (
	AlertAnnotationTitle       = "title"
	AlertAnnotationDescription = "description"
	AlertAnnotationErrorString = "error"
	AlertScopeTypeTag          = "scope"
	AlertSeverityLabel         = "severity"
	AlertScopeApp              = "Application"
	AlertScopeCloudlet         = "Cloudlet"
	AlertTypeLabel             = "type"
	AlertScopePlatform         = "Platform"
)

Alert types

View Source
const (
	AlertSeverityError = "error"
	AlertSeverityWarn  = "warning"
	AlertSeverityInfo  = "info"
	// List in the order of increasing severity
	ValidAlertSeverityString = `"info", "warning", "error"`
)
View Source
const (
	// Important: key strings used here for grpc metadata keys
	// MUST be lower-case.
	CallerAutoProv         = "caller-auto-prov"
	AutoProvReason         = "auto-prov-reason"
	AutoProvReasonDemand   = "demand"
	AutoProvReasonMinMax   = "minmax"
	AutoProvReasonOrphaned = "orphaned"
	AutoProvPolicyName     = "auto-prov-policy-name"
	AccessKeyData          = "access-key-data"
	AccessKeySig           = "access-key-sig"
	VaultKeySig            = "vault-key-sig"
)
View Source
const (
	AlreadyUnderDeletionMsg          = "busy, already under deletion"
	StreamActionAlreadyInProgressMsg = "An action is already in progress for the object"
)
View Source
const (
	CRMCompatibilityAutoReservableCluster uint32 = 1
	CRMCompatibilitySharedRootLBFQDN      uint32 = 2
	CRMCompatibilityNewAppInstKey         uint32 = 3
)
View Source
const (
	AppInstCompatibilityInitial             uint32 = 0
	AppInstCompatibilityUniqueNameKey       uint32 = 1
	AppInstCompatibilityUniqueNameKeyConfig uint32 = 2
	AppInstCompatibilityRegionScopeName     uint32 = 3
)

AppInsts created before certain upgrades have generated names (like namespaces, infra-specific objects etc) that are based on the older version of the AppInst. To maintain backwards compatibility even after upgrading the AppInst object, these dynamically generated names must be generated the same way as before.

View Source
const (
	ClusterInstCompatibilityInitial         uint32 = 0
	ClusterInstCompatibilityRegionScopeName uint32 = 1
)

ClusterInst compatibility versions, same as above for AppInsts.

View Source
const (
	MetricTagRegion          = "region"
	MetricTagOrg             = "org"
	MetricTagEvent           = "event"
	MetricTagStatus          = "status"
	MetricTagStart           = "start"
	MetricTagEnd             = "end"
	MetricTagStartTime       = "starttime"
	MetricTagEndTime         = "endtime"
	MetricTagDuration        = "duration"
	MetricTagUptime          = "uptime"
	MetricTagFlavor          = "flavor"
	MetricTagDeployment      = "deployment"
	MetricTagRAM             = "ram"
	MetricTagVCPU            = "vcpu"
	MetricTagDisk            = "disk"
	MetricTagNodeCount       = "nodecount"
	MetricTagNumNodes        = "numnodes"
	MetricTagOther           = "other"
	MetricTagNote            = "note"
	MetricTagIpAccess        = "ipaccess"
	MetricTagPort            = "port"
	MetricTagDmeId           = "dmeId"
	MetricTagMethod          = "method"
	MetricTagLocationTile    = "locationtile"
	MetricTagDataNetworkType = "datanetworktype"
	MetricTagDeviceCarrier   = "devicecarrier"
	MetricTagDeviceOS        = "deviceos"
	MetricTagDeviceModel     = "devicemodel"
	MetricTagFoundCloudlet   = "foundCloudlet"
	MetricTagFoundOperator   = "foundOperator"
	MetricTagDmeCloudlet     = "dmecloudlet"
	MetricTagDmeCloudletOrg  = "dmecloudletorg"
	MetricTagStatName        = "statname"
)
View Source
const (
	AnnotationCloudletScopedName = "cloudlet-scoped-name"
	AnnotationBadUpgrade55Name   = "bad-upgrade55-name"
	AnnotationPreviousDNSName    = "previous-dns-name"
)
View Source
const (
	NoAuth              = "noauth"
	BasicAuth           = "basic"
	TokenAuth           = "token"
	ApiKeyAuth          = "apikey"
	DockerHub           = "docker.io"
	DockerHubRegistry   = "registry-1.docker.io"
	MaxOvfVmVersion     = 14
	AllOrgs             = ""
	AuthRespToken       = "token"
	AuthRespAccessToken = "access_token"
)
View Source
const (
	GetCloudletManifest         = "GetCloudletManifest"
	GetRestrictedCloudletStatus = "GetRestrictedCloudletStatus"
)
View Source
const AppFederatedIdMaxLen = 50
View Source
const AutoProvPrefix = "autoprov"
View Source
const CertName = "envoyTlsCerts"

Common cert name. Cannot use common name as filename since envoy doesn't know if the app is dedicated or not

View Source
const DefaultClust string = "defaultclust"
View Source
const DefaultMultiTenantCluster string = "defaultmtclust"
View Source
const DnsCloudletLabelMaxLen = 50
View Source
const DnsCloudletObjectLabelMaxLen = 63
View Source
const DnsDomainLabelMaxLen = 40

Fully Qualified Domain Names (FQDNs) primarily come in the the following format of 4 "labels" (where domain can actually be more than one label itself, i.e. edgecloud.net): cloudletobject.cloudlet.region.domain In some cases, another label will be prepended (such as for ip-per-k8s-services, the service name is prepended). To help avoid the total length limit of 253 when prepending additional labels, we restrict the base labels to less than the DNS spec per-label restriction of 63, based on how long we expect those labels to be in general. For example, we expect most region names to be 3-4 characters, while appname+version+org is likely to be much longer.

View Source
const DnsRegionLabelMaxLen = 10
View Source
const E2ETEST_IMAGE_CHECKSUM = "sha256:8d4ea2a9476bc51681c6e7e59759c10237669c950b1b4a3cd6834e2161d7bde2"
View Source
const FreeClusterEvent = "Free ClusterInst reservation"
View Source
const IdAlphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

These alphabets are used for generating random strings with gonanoid.

View Source
const IdAlphabetLC = "0123456789abcdefghijklmnopqrstuvwxyz"
View Source
const MaxClusterNameLength = 40

GCP limits to 40, Azure has issues above 54. For consistency go with the lower limit

View Source
const RedactedSecret = "***"
View Source
const ReservableClusterPrefix = "reservable"
View Source
const ReserveClusterEvent = "Reserve ClusterInst"
View Source
const TagIpUserEquipment string = "ip_user_equipment"
View Source
const TagPrioritySessionId string = "priority_session_id"

Values for QOS Priority Session API

View Source
const TagQosProfileName string = "qos_profile_name"
View Source
const UnknownOwner = "unknown"

UnknownOwner for ObjID

Variables

View Source
var (
	// Common platform resources
	ResourceRamMb       = "RAM"
	ResourceVcpus       = "vCPUs"
	ResourceDiskGb      = "Disk"
	ResourceGpus        = "GPUs"
	ResourceExternalIPs = "External IPs"

	// Platform specific resources
	ResourceInstances             = "Instances"
	ResourceFloatingIPs           = "Floating IPs"
	ResourceK8sClusters           = "K8s Clusters"
	ResourceMaxK8sNodesPerCluster = "Maximum K8s Nodes Per Cluster"
	ResourceTotalK8sNodes         = "Total Number Of K8s Nodes"
	ResourceNetworkLBs            = "Network Load Balancers"

	// Resource units
	ResourceRamUnits  = "MB"
	ResourceDiskUnits = "GB"

	// Resource metrics
	ResourceMetricRamMB                 = "ramUsed"
	ResourceMetricVcpus                 = "vcpusUsed"
	ResourceMetricDisk                  = "diskUsed"
	ResourceMetricGpus                  = "gpusUsed"
	ResourceMetricInstances             = "instancesUsed"
	ResourceMetricExternalIPs           = "externalIpsUsed"
	ResourceMetricFloatingIPs           = "floatingIpsUsed"
	ResourceMetricK8sClusters           = "k8sClustersUsed"
	ResourceMetricMaxK8sNodesPerCluster = "maxK8sNodesPerClusterUsed"
	ResourceMetricTotalK8sNodes         = "totalK8sNodesUsed"
	ResourceMetricNetworkLBs            = "networkLBsUsed"

	// Common cloudlet resources
	CommonCloudletResources = map[string]string{
		ResourceRamMb:       ResourceRamUnits,
		ResourceVcpus:       "",
		ResourceDiskGb:      "",
		ResourceGpus:        "",
		ResourceExternalIPs: "",
	}

	ResourceQuotaDesc = map[string]string{
		ResourceRamMb:                 "Limit on RAM available (MB)",
		ResourceVcpus:                 "Limit on vCPUs available",
		ResourceDiskGb:                "Limit on disk available (GB)",
		ResourceGpus:                  "Limit on GPUs available",
		ResourceExternalIPs:           "Limit on external IPs available",
		ResourceInstances:             "Limit on number of instances that can be provisioned",
		ResourceFloatingIPs:           "Limit on number of floating IPs that can be created",
		ResourceK8sClusters:           "Limit on number of k8s clusters than can be created",
		ResourceMaxK8sNodesPerCluster: "Limit on maximum number of k8s nodes that can be created as part of k8s cluster",
		ResourceTotalK8sNodes:         "Limit on total number of k8s nodes that can be created altogether",
		ResourceNetworkLBs:            "Limit on maximum number of network load balancers that can be created in a region",
	}

	ResourceMetricsDesc = map[string]string{
		ResourceMetricRamMB:                 "RAM Usage (MB)",
		ResourceMetricVcpus:                 "vCPU Usage",
		ResourceMetricDisk:                  "Disk Usage (GB)",
		ResourceMetricGpus:                  "GPU Usage",
		ResourceMetricExternalIPs:           "External IP Usage",
		ResourceMetricInstances:             "VM Instance Usage",
		ResourceMetricFloatingIPs:           "Floating IP Usage",
		ResourceMetricK8sClusters:           "K8s Cluster Usage",
		ResourceMetricMaxK8sNodesPerCluster: "Maximum K8s Nodes Per Cluster Usage",
		ResourceMetricTotalK8sNodes:         "Total K8s Nodes Usage",
		ResourceMetricNetworkLBs:            "Network Load Balancer Usage",
	}

	CommonResourceQuotaProps = GetCommonResourceQuotaProps()
)
View Source
var AlertHealthCheckStatus = "status"

for healthCheck:

View Source
var AlertKeyLowCpuNodeCount = "lowcpunodecount"
View Source
var AlertKeyMinNodes = "minnodes"
View Source
var AlertKeyNodeCount = "nodecount"

Alert annotation keys for autoscale:

View Source
var AlertSeverityTypes = map[string]struct{}{
	AlertSeverityError: struct{}{},
	AlertSeverityWarn:  struct{}{},
	AlertSeverityInfo:  struct{}{},
}

Map represents severities for the specific alerts that the platfrom generates

View Source
var AllocatedIpDynamic = "dynamic"
View Source
var AppInstCheckpoints = "appinst-checkpoints"
View Source
var AppInstEvent = "appinst"

Influx metrics selectors

View Source
var AutoProvMeasurement = "auto-prov-counts"
View Source
var AutoProvMinAlreadyMetError = fmt.Errorf("Create to satisfy min already met, ignoring")
View Source
var ClientTypeClusterVM string = "clustervm"
View Source
var ClientTypeRootLB string = "rootlb"

Client type to access cluster nodes

View Source
var CloudletEvent = "cloudlet"
View Source
var CloudletFlavorUsageMeasurement = "cloudlet-flavor-usage"
View Source
var CloudletKindAws = "aws"
View Source
var CloudletKindAzure = "azure"
View Source
var CloudletKindDIND = "dind"
View Source
var CloudletKindFake = "fake"
View Source
var CloudletKindGCP = "gcp"
View Source
var CloudletKindOpenStack = "openstack"

cloudlet types

View Source
var CloudletResourceUsageDbName = "cloudlet_resource_usage"

Cloudlet resource usage

View Source
var ClusterInstCheckpoints = "clusterinst-checkpoints"
View Source
var ClusterInstEvent = "clusterinst"
View Source
var CustomMetric = "custom-metric"
View Source
var DefaultPlatformFlavorKey = edgeproto.FlavorKey{
	Name: "DefaultPlatformFlavor",
}
View Source
var DeploymentTypeDocker = "docker"
View Source
var DeploymentTypeHelm = "helm"
View Source
var DeploymentTypeKubernetes = "kubernetes"
View Source
var DeploymentTypeVM = "vm"
View Source
var DeveloperMetricsDbName = "metrics"

Metrics common variables - TODO move to edge-cloud-infra after metrics-exporter chagnes

View Source
var DeviceMetric = "device-metric"
View Source
var DindScriptName = "dind-cluster-v1.14.sh"

DIND script to pull from kubeadm-dind-cluster

View Source
var DmeApiMeasurement = "dme-api"
View Source
var Download = "download"
View Source
var DownsampledMetricsDbName = "downsampled_metrics"
View Source
var EdgeEventsMetrics = map[string]struct{}{
	LatencyMetric: struct{}{},
	DeviceMetric:  struct{}{},
	CustomMetric:  struct{}{},
}

Map used to identify which metrics should go to persistent_metrics db. Value represents the measurement creation status

View Source
var EdgeEventsMetricsDbName = "edgeevents_metrics"

EdgeEvents Metrics Influx variables

View Source
var EventsDbName = "events"

Instance Lifecycle variables

View Source
var GPUResourceLimitName = "nvidia.com/gpu"
View Source
var GRPCClientKeepaliveParams = keepalive.ClientParameters{
	Time:    kpInterval,
	Timeout: kpInterval,
}
View Source
var GRPCServerKeepaliveEnforcement = keepalive.EnforcementPolicy{
	MinTime: 1 * time.Second,
}
View Source
var GRPCServerKeepaliveParams = keepalive.ServerParameters{
	MaxConnectionIdle:     3 * kpInterval,
	MaxConnectionAge:      infinity,
	MaxConnectionAgeGrace: infinity,
	Time:                  kpInterval,
	Timeout:               kpInterval,
}
View Source
var IPAddrAllInterfaces = "0.0.0.0"
View Source
var IPAddrLocalHost = "127.0.0.1"
View Source
var IPV6AddrAllInterfaces = "::"
View Source
var InstanceDown = "DOWN"
View Source
var InstanceUp = "UP"
View Source
var InternalDockerRegistry = "internal-docker-registry"
View Source
var InternalVMRegistry = "internal-vm-registry"
View Source
var LatencyMetric = "latency-metric"
View Source
var MEXPrometheusAppName = "MEXPrometheusAppName"
View Source
var MexAppInstNameLabel = "mexAppInstName"

AppLabels for the application containers

View Source
var MexAppInstOrgLabel = "mexAppInstOrg"
View Source
var MexAppNameLabel = "mexAppName"
View Source
var MexAppVersionLabel = "mexAppVersion"
View Source
var MexMetricEndpoint = "mexMetricsEndpoint"
View Source
var MexNodePrefix = "mex-k8s-node-"
View Source
var MonthlyInterval = "MONTH"
View Source
var NFSAutoProvisionAppName = "NFSAutoProvision"
View Source
var NetworkSchemePrivateIP = "privateip"
View Source
var NetworkSchemePublicIP = "publicip"

network schemes for use by standalone deployments (e.g. DIND)

View Source
var NoCreds = ""
View Source
var NoDownload = "nodownload"
View Source
var OperatingSystemLinux = "linux"
View Source
var OperatingSystemMac = "mac"
View Source
var OperatorAWS = "aws"
View Source
var OperatorAzure = "azure"
View Source
var OperatorGCP = "gcp"

special operator types

View Source
var PlatosEnablingLayer = "PlatosEnablingLayer"

platform apps

View Source
var PrometheusPort = int32(9090)
View Source
var ProxyMetricsDefaultListenIP = "127.0.0.1"
View Source
var ProxyMetricsListenUDS = "MetricsUDS" // Unix Domain Socket
View Source
var ProxyMetricsPort = int32(65121)
View Source
var RemoteServerNone = ""
View Source
var ResourceTypeK8sLBSvc = "k8s-lb-svc"

resource types

View Source
var RootLBHostname = "shared"
View Source
var ValidCloudletDeployments = []string{
	DeploymentTypeDocker,
	DeploymentTypeKubernetes,
}
View Source
var VmRegHeaderMD5 = "X-Checksum-Md5"
View Source
var VmRegPath = "/storage/v1/artifacts"

Common API paths

View Source
var VmRegPullPath = "/storage/v1/pull"

Functions

func AppInstBeingDeleted

func AppInstBeingDeleted(inst *edgeproto.AppInst) bool

func AppInstToClusterDeployment

func AppInstToClusterDeployment(deployment string) string

Transform AppInst deployment type to ClusterInst deployment type

func AuditStreamInterceptor

func AuditStreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func AuditUnaryInterceptor

func AuditUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func AutoProvAppInstGoingOnline

func AutoProvAppInstGoingOnline(appInst *edgeproto.AppInst, cloudletInfo *edgeproto.CloudletInfo, cloudlet *edgeproto.Cloudlet) bool

func AutoProvAppInstOnline

func AutoProvAppInstOnline(appInst *edgeproto.AppInst, cloudletInfo *edgeproto.CloudletInfo, cloudlet *edgeproto.Cloudlet) bool

func AutoProvCloudletInfoOnline

func AutoProvCloudletInfoOnline(cloudletInfo *edgeproto.CloudletInfo) bool

func AutoProvCloudletOnline

func AutoProvCloudletOnline(cloudlet *edgeproto.Cloudlet) bool

func BuildReservableClusterName

func BuildReservableClusterName(id int, cloudletKey *edgeproto.CloudletKey) string

func CheckFQDNLengths

func CheckFQDNLengths(prefix, uri string) error

DNS names must have labels <= 63 chars, and the total length <= 255 octets (which works out to 253 chars).

func CidrContainsCidr

func CidrContainsCidr(n1, n2 *net.IPNet) bool

CidrContainsCidr returns true only if the first CIDR fully contains the second CIDR

func CloudletResourceUsageAlerts

func CloudletResourceUsageAlerts(ctx context.Context, key *edgeproto.CloudletKey, warnings []string) []edgeproto.Alert

Raise the alarm when there are cloudlet resource usage warnings

func DecodeDockerComposeYaml

func DecodeDockerComposeYaml(manifest string) (map[string]DockerContainer, error)

func DecodeK8SYaml

func DecodeK8SYaml(manifest string) ([]runtime.Object, []*schema.GroupVersionKind, error)

func DeleteAppSecretVars

func DeleteAppSecretVars(ctx context.Context, region string, appKey *edgeproto.AppKey, vaultConfig *vault.Config) error

func DeleteFile

func DeleteFile(filePath string) error

func DeleteSecretVars

func DeleteSecretVars(ctx context.Context, path string, vaultConfig *vault.Config) error

func DownloadFile

func DownloadFile(ctx context.Context, authApi RegistryAuthApi, fileUrlPath, urlCreds, filePath string, content *string) (reterr error)

func FormatDuration

func FormatDuration(dur time.Duration, digIdx int) string

round the given field denoted by digIdx, we mostly want seconds rounded to two digits

func FqdnPrefix

func FqdnPrefix(svcName string) string

FqdnPrefix is used only for IP-per-service platforms that allocate an IP for each kubernetes service. Because it adds an extra level of DNS label hierarchy and cannot match the wildcard cert, we do not support TLS for it.

func GRPCErrorUnwrap

func GRPCErrorUnwrap(err error) error

GRPCError unwraps status.Status errors, this avoids ugly type print outs when various library code converts the error to a string.

func GenerateManifest

func GenerateManifest(app *edgeproto.App) (string, error)

func GetAppClientType

func GetAppClientType(app *edgeproto.App) string

func GetAppDeploymentManifest

func GetAppDeploymentManifest(ctx context.Context, authApi RegistryAuthApi, app *edgeproto.App) (string, error)

GetAppDeploymentManifest gets the deployment-specific manifest.

func GetAppInstCloudletScopedName

func GetAppInstCloudletScopedName(appInst *edgeproto.AppInst) string

GetAppInstCloudletScopedName gets the previous key name that was scoped to the cloudlet, if it exists. The current name is scoped to the region and may have been renamed on upgrade.

func GetAppInstCompatibilityVersion

func GetAppInstCompatibilityVersion() uint32

GetAppInstCompatibilityVersion always returns the highest compatibility version

func GetAppSecretVars

func GetAppSecretVars(ctx context.Context, region string, appKey *edgeproto.AppKey, vaultConfig *vault.Config) (map[string]string, error)

func GetArtifactOrgPath

func GetArtifactOrgPath(org, path string) string

func GetArtifactPullPath

func GetArtifactPullPath(addr, org, path string) string

func GetArtifactStoragePath

func GetArtifactStoragePath(addr, org, path string) string

func GetAuthToken

func GetAuthToken(ctx context.Context, host string, authApi RegistryAuthApi, userName string) (string, error)

func GetAutoProvAppInstKey

func GetAutoProvAppInstKey(appKey *edgeproto.AppKey, cloudletKey *edgeproto.CloudletKey) edgeproto.AppInstKey

Generate unique and recognizable name for autoprov deployed instances. Only one auto-provisioned instance per app is allowed per cloudlet.

func GetAvailablePort

func GetAvailablePort(ipaddr string) (string, error)

func GetCRMCompatibilityVersion

func GetCRMCompatibilityVersion() uint32

GetCRMCompatibilityVersion always returns the highest compatibility version

func GetCertsDirAndFiles

func GetCertsDirAndFiles(pwd string) (string, string, string)

GetCertsDirAndFiles returns certsDir, certFile, keyFile

func GetCloudletE2EPublicCert

func GetCloudletE2EPublicCert(ctx context.Context, commonName string) (*vault.PublicCert, error)

func GetCloudletKeyHash

func GetCloudletKeyHash(key *edgeproto.CloudletKey) string

GetCloudletKeyHash returns a short hash of the cloudlet key to allow for a deterministic string representing the cloudlet, that does not reveal the cloudlet name (which would likely reveal its location).

func GetCloudletResourceUsageMeasurement

func GetCloudletResourceUsageMeasurement(pfType string) string

func GetClusterInstCloudletScopedName

func GetClusterInstCloudletScopedName(clusterInst *edgeproto.ClusterInst) string

GetClusterInstCloudletScopedName gets the previous key name that was scoped to the cloudlet, if it exists. The current name is scoped to the region and may have been renamed on upgrade.

func GetClusterInstCompatibilityVersion

func GetClusterInstCompatibilityVersion() uint32

GetClusterInstCompatibilityVersion always returns the highest compatibility version

func GetClusterInstVMRequirements

func GetClusterInstVMRequirements(ctx context.Context, clusterInst *edgeproto.ClusterInst, nodeFlavor, masterNodeFlavor, rootLBFlavor *edgeproto.FlavorInfo, isManagedK8s bool) ([]edgeproto.VMResource, error)

GetClusterInstVMRequirements uses the nodeFlavor and masterNodeFlavor if it cannot find a platform flavor

func GetCommonResourceQuotaProps

func GetCommonResourceQuotaProps(additionalResources ...string) []edgeproto.InfraResource

GetCommonResourceQuotaProps returns the common resource quota properties. This is for convenience, it is not required that every platform support these quotas.

func GetDefaultClustKey

func GetDefaultClustKey(cloudletKey edgeproto.CloudletKey, ownerOrg string) *edgeproto.ClusterKey

func GetDefaultDeploymentType

func GetDefaultDeploymentType(imageType edgeproto.ImageType) (string, error)

func GetDefaultMTClustKey

func GetDefaultMTClustKey(cloudletKey edgeproto.CloudletKey) *edgeproto.ClusterKey

func GetDeploymentManifest

func GetDeploymentManifest(ctx context.Context, authApi RegistryAuthApi, manifest string) (string, error)

func GetDockerBaseImageVersion

func GetDockerBaseImageVersion() (string, error)

func GetDockerDeployType

func GetDockerDeployType(manifest string) string

func GetDockerImageChecksum

func GetDockerImageChecksum(ctx context.Context, imagePath string, auth *RegistryAuth) (string, error)

Return sha256 image digest, requires skopeo installed

func GetFileName

func GetFileName(fileUrlPath string) (string, error)

func GetFileNameWithExt

func GetFileNameWithExt(fileUrlPath string) (string, error)

func GetGPUDriverBuildStoragePath

func GetGPUDriverBuildStoragePath(key *edgeproto.GPUDriverKey, region, buildName, ext string) (string, error)

func GetGPUDriverLicenseCloudletStoragePath

func GetGPUDriverLicenseCloudletStoragePath(key *edgeproto.GPUDriverKey, region string, cloudletKey *edgeproto.CloudletKey) (string, error)

func GetGPUDriverLicenseStoragePath

func GetGPUDriverLicenseStoragePath(key *edgeproto.GPUDriverKey, region string) (string, error)

func GetGPUDriverStoragePath

func GetGPUDriverStoragePath(key *edgeproto.GPUDriverKey, region string) (string, error)

func GetImageTypeForDeployment

func GetImageTypeForDeployment(deployment string) (edgeproto.ImageType, error)

func GetInfluxSelectFields

func GetInfluxSelectFields(selectors []string) string

Returns a string of format `"selector","selector",...`

func GetK8sAppRequirements

func GetK8sAppRequirements(ctx context.Context, app *edgeproto.App) ([]edgeproto.VMResource, error)

func GetMappedAccessType

func GetMappedAccessType(accessType edgeproto.AccessType, deployment, deploymentManifest string) (edgeproto.AccessType, error)

GetMappedAccessType gets the default access type for the deployment. As of 2.4.1 only Load Balancer access is supported. Once the UI is updated to remove all references to access type, this can be removed altogether

func GetQueryArgsFromObj

func GetQueryArgsFromObj(obj interface{}) (string, error)

func GetRegistryAuthToken

func GetRegistryAuthToken(ctx context.Context, host string, authApi RegistryAuthApi) (string, error)

func GetRemoteManifest

func GetRemoteManifest(ctx context.Context, authApi RegistryAuthApi, target string) (string, error)

func GetRemoteManifestToFile

func GetRemoteManifestToFile(ctx context.Context, authApi RegistryAuthApi, target string, filename string) error

func GetRemoteZipDockerManifests

func GetRemoteZipDockerManifests(ctx context.Context, authApi RegistryAuthApi, manifest, zipfile, downloadAction string) ([]map[string]DockerContainer, error)

func GetRootLBFQDNOld

func GetRootLBFQDNOld(key *edgeproto.CloudletKey, domain string) string

Old version of getting the shared root lb, does not match wildcard cert.

func GetRootLBFQDNWildcard

func GetRootLBFQDNWildcard(cloudlet *edgeproto.Cloudlet) string

Wildcard cert for all LBs both shared and dedicated

func GetSecretVars

func GetSecretVars(ctx context.Context, path string, vaultConfig *vault.Config) (map[string]string, error)

func GetSeverityForAlert

func GetSeverityForAlert(alertname string) string

func GetSideCarAppFilter

func GetSideCarAppFilter() *edgeproto.App

func GetTimeout

func GetTimeout(cLen int) time.Duration

5GB = 10minutes

func GetVMAppRequirements

func GetVMAppRequirements(ctx context.Context, app *edgeproto.App, appInst *edgeproto.AppInst, pfFlavorList []*edgeproto.FlavorInfo, rootLBFlavor *edgeproto.FlavorInfo) ([]edgeproto.VMResource, error)

func GetValidAlertSeverityString

func GetValidAlertSeverityString() string

Helper function - returns the string representations of all valid severities

func GrpcCreds

func GrpcCreds(cfg *ctls.Config) grpc.ServerOption

func GrpcGateway

func GrpcGateway(cfg *GrpcGWConfig) (http.Handler, error)

func GrpcGatewayServe

func GrpcGatewayServe(server *http.Server, tlsCertFile string)

func Hostname

func Hostname() string

func IsAlertSeverityValid

func IsAlertSeverityValid(severity string) bool

func IsAppInstBeingCreatedError

func IsAppInstBeingCreatedError(err error) bool

Autoprov relies on detecting if an AppInst is already being created

func IsAppInstBeingDeletedError

func IsAppInstBeingDeletedError(err error) bool

Autoprov relies on detecting if an AppInst is already being deleted

func IsClusterInstReqd

func IsClusterInstReqd(app *edgeproto.App) bool

func IsDefaultClustKey

func IsDefaultClustKey(clusterKey edgeproto.ClusterKey, cloudletKey edgeproto.CloudletKey) bool

func IsGPUFlavor

func IsGPUFlavor(flavor *edgeproto.Flavor) (bool, int)

func IsInternalAlert

func IsInternalAlert(labels map[string]string) bool

func IsLBNode

func IsLBNode(nodeTypeStr string) bool

func IsLabelInternal

func IsLabelInternal(label string) bool

Prune labels we don't want to show on the alerts sent to the external alert integrations

func IsMonitoredAlert

func IsMonitoredAlert(labels map[string]string) bool

func IsPlatformApp

func IsPlatformApp(devname string, appname string) bool

IsPlatformApp true if the developer/app combo is a platform app

func IsPlatformNode

func IsPlatformNode(nodeTypeStr string) bool

func IsSideCarApp

func IsSideCarApp(app *edgeproto.App) bool

func IsValidDeploymentForImage

func IsValidDeploymentForImage(imageType edgeproto.ImageType, deployment string) bool

func IsValidDeploymentManifest

func IsValidDeploymentManifest(deploymentType, command, manifest string, ports []dme.AppPort, appFlavor *edgeproto.Flavor) error

func IsValidDeploymentManifestForFlavor

func IsValidDeploymentManifestForFlavor(deploymentType, manifest string, flavor *edgeproto.Flavor) error

func IsValidDeploymentType

func IsValidDeploymentType(DeploymentType string, validDeployments []string) bool

func LookupDNS

func LookupDNS(name string) (string, error)

func Md5SumFile

func Md5SumFile(filePath string) (string, error)

func Md5SumStr

func Md5SumStr(data string) string

func ParseGPUResource

func ParseGPUResource(resStr string) (string, string, int, error)

func ParseGrpcMethod

func ParseGrpcMethod(method string) (path string, cmd string)

func ParseHost

func ParseHost(hostOrURL string) (string, string, error)

return hostname and port from hostOrURL string.

func ParseMyCloudletKey

func ParseMyCloudletKey(standalone bool, keystr *string, mykey *edgeproto.CloudletKey)

For the DME and CRM that require a cloudlet key to be specified at startup, this function parses the string argument.

func ParseReservableClusterName

func ParseReservableClusterName(name string) (int, string, error)

func RedactSecretVars

func RedactSecretVars(vars map[string]string) map[string]string

func SaveAppSecretVars

func SaveAppSecretVars(ctx context.Context, region string, appKey *edgeproto.AppKey, vaultConfig *vault.Config, vars map[string]string) error

func SaveSecretVars

func SaveSecretVars(ctx context.Context, path string, vaultConfig *vault.Config, vars map[string]string) error

func SendHTTPReq

func SendHTTPReq(ctx context.Context, method, regUrl string, authApi RegistryAuthApi, urlCreds string, reqConfig *RequestConfig, body io.Reader) (*http.Response, error)

* Sends HTTP request to regUrl * Checks if any Auth Credentials is needed by doing a lookup to Vault path * - If it finds auth details, then HTTP request is sent with auth details set in HTTP Header * - else, we assume it to be a public registry which requires no authentication * Following is the flow for Docker Registry v2 authentication: * - Send HTTP request to regUrl with auth (if found in Vault) or else without auth * - If the registry requires authorization, it will return a 401 Unauthorized response with a * WWW-Authenticate header detailing how to authenticate to this registry * - We then make a request to the authorization service for a Bearer token * - The authorization service returns an opaque Bearer token representing the client’s authorized access * - Retry the original request with the Bearer token embedded in the request’s Authorization header * - The Registry authorizes the client by validating the Bearer token and the claim set embedded within * it and begins the session as usual

func SendHTTPReqAuth

func SendHTTPReqAuth(ctx context.Context, method, regUrl string, auth *RegistryAuth, reqConfig *RequestConfig, body io.Reader) (*http.Response, error)

func ServiceFQDN

func ServiceFQDN(svcName, baseFQDN string) string

func StreamRecv

func StreamRecv[Object any](ctx context.Context, stream GRPCStreamRecv[Object], cb func(obj Object) error) error

StreamRecv converts a grpc stream receiver into callbacks

func StreamRecvWithStatus

func StreamRecvWithStatus[Object StatusObj](ctx context.Context, stream GRPCStreamRecv[Object], statusSend func(*edgeproto.Result) error, cb func(obj Object) error) error

StreamRecvWithStatus is like StreamRecv, but for objects that include a StatusInfo object whose new status messages should be sent via the statusSend callback.

func UpdateAppSecretVars

func UpdateAppSecretVars(ctx context.Context, region string, appKey *edgeproto.AppKey, vaultConfig *vault.Config, vars map[string]string, updateListAction string) (map[string]string, error)

func UpdateSecretVars

func UpdateSecretVars(ctx context.Context, path string, vaultConfig *vault.Config, vars map[string]string, updateListAction string) (map[string]string, error)

func ValidateCloudletResourceQuotas

func ValidateCloudletResourceQuotas(ctx context.Context, quotaProps []edgeproto.InfraResource, curRes map[string]edgeproto.InfraResource, resourceQuotas []edgeproto.ResourceQuota) error

func ValidateDockerRegistryPath

func ValidateDockerRegistryPath(ctx context.Context, regUrl string, authApi RegistryAuthApi) error

func ValidateOvfRegistryPath

func ValidateOvfRegistryPath(ctx context.Context, imgUrl string, authApi RegistryAuthApi) error

func ValidateVMRegistryPath

func ValidateVMRegistryPath(ctx context.Context, imgUrl string, authApi RegistryAuthApi) error

func WrapStream

func WrapStream(stream grpc.ServerStream, ctx context.Context) grpc.ServerStream

Types

type Action

type Action int
const (
	Create Action = iota
	Delete
	Update
)

func (Action) String

func (a Action) String() string

type AppInstLabels

type AppInstLabels struct {
	AppInstNameLabel string
	AppInstOrgLabel  string
}

AppInstLabels are for labeling objects to track that they belong to an AppInst. The cloudlet key information is omitted because objects to track are on a particular cloudlet, so the cloudlet info is fixed.

func GetAppInstLabels

func GetAppInstLabels(appInst *edgeproto.AppInst) AppInstLabels

func (*AppInstLabels) FromMap

func (s *AppInstLabels) FromMap(labels map[string]string)

func (*AppInstLabels) Map

func (s *AppInstLabels) Map() map[string]string

type AppInstLabelsOld

type AppInstLabelsOld struct {
	AppNameLabel    string
	AppVersionLabel string
}

AppInstLabelsOld are the version of AppInstLabels before the AppInstUniqueNameKey upgrade.

func GetAppInstLabelsOld

func GetAppInstLabelsOld(appInst *edgeproto.AppInst) AppInstLabelsOld

func (*AppInstLabelsOld) FromMap

func (s *AppInstLabelsOld) FromMap(labels map[string]string)

func (*AppInstLabelsOld) Map

func (s *AppInstLabelsOld) Map() map[string]string

type AuditRecvOne

type AuditRecvOne struct {
	grpc.ServerStream
	// contains filtered or unexported fields
}

func NewAuditRecvOne

func NewAuditRecvOne(stream grpc.ServerStream, ctx context.Context) *AuditRecvOne

func (*AuditRecvOne) Context

func (s *AuditRecvOne) Context() context.Context

func (*AuditRecvOne) RecvMsg

func (s *AuditRecvOne) RecvMsg(m interface{}) error

type AuthTokenResp

type AuthTokenResp struct {
	Scope       string `json:"scope"`
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type DockerContainer

type DockerContainer struct {
	Image string `mapstructure:"image"`
}

type DockerManifest

type DockerManifest struct {
	DockerComposeFiles []string
}

type DummyRegistryAuthApi

type DummyRegistryAuthApi struct {
	DummyAuth RegistryAuth
}

For unit tests

func (*DummyRegistryAuthApi) GetRegistryAuth

func (s *DummyRegistryAuthApi) GetRegistryAuth(ctx context.Context, imgUrl string) (*RegistryAuth, error)

type EmailAccount

type EmailAccount struct {
	Email    string `json:"email"`
	User     string `json:"user"`
	Pass     string `json:"pass"`
	Smtp     string `json:"smtp"`
	SmtpPort string `json:"smtpport"`
	SmtpTLS  bool   `json:"smtptls"`
}

func GetNoreply

func GetNoreply(vaultConfig *vault.Config) (*EmailAccount, error)

type ExecReqInfo

type ExecReqInfo struct {
	Type    ExecReqType
	InitURL *url.URL
	Cookies []*http.Cookie
}

type ExecReqType

type ExecReqType int
const (
	ExecReqConsole ExecReqType = 0
	ExecReqShell   ExecReqType = 1
)

type GRPCConnCache

type GRPCConnCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGRPCConnCache

func NewGRPCConnCache(addrsByKey map[string]string) *GRPCConnCache

func (*GRPCConnCache) GetConn

func (s *GRPCConnCache) GetConn(ctx context.Context, key string) (*grpc.ClientConn, error)

func (*GRPCConnCache) GetInterval

func (s *GRPCConnCache) GetInterval() time.Duration

func (*GRPCConnCache) Run

func (s *GRPCConnCache) Run(ctx context.Context)

func (*GRPCConnCache) SetConn

func (s *GRPCConnCache) SetConn(key string, conn *grpc.ClientConn)

SetConn allows for manually injecting a client connection. Can be used for unit testing with grpc.bufconn.

func (*GRPCConnCache) Start

func (s *GRPCConnCache) Start()

func (*GRPCConnCache) StartSpan

func (s *GRPCConnCache) StartSpan() opentracing.Span

func (*GRPCConnCache) Stop

func (s *GRPCConnCache) Stop()

type GRPCStreamRecv

type GRPCStreamRecv[Object any] interface {
	Recv() (Object, error)
}

type GetPublicCertApi

type GetPublicCertApi interface {
	GetPublicCert(ctx context.Context, commonName string) (*vault.PublicCert, error)
}

GetPublicCertApi abstracts the way the public cert is retrieved. Certain services, like DME running on a Cloudlet, may need to connect to the controller to get a public cert from Vault.

type GrpcGWConfig

type GrpcGWConfig struct {
	ApiAddr        string
	GetCertificate func(*ctls.CertificateRequestInfo) (*ctls.Certificate, error)
	TlsCertFile    string
	ApiHandles     []func(context.Context, *gwruntime.ServeMux, *grpc.ClientConn) error
}

type InfluxCreds

type InfluxCreds struct {
	User string
	Pass string
}

func GetInfluxDataAuth

func GetInfluxDataAuth(vaultConfig *vault.Config, region string) (*InfluxCreds, error)

type InstanceEvent

type InstanceEvent string
const (
	CREATED           InstanceEvent = "CREATED"
	UPDATE_START      InstanceEvent = "UPDATE_START"
	UPDATE_ERROR      InstanceEvent = "UPDATE_ERROR"
	UPDATE_COMPLETE   InstanceEvent = "UPDATE_COMPLETE"
	DELETED           InstanceEvent = "DELETED"
	DELETE_ERROR      InstanceEvent = "DELETE_ERROR"
	HEALTH_CHECK_FAIL InstanceEvent = "HEALTH_CHECK_FAIL"
	HEALTH_CHECK_OK   InstanceEvent = "HEALTH_CHECK_OK"
	RESERVED          InstanceEvent = "RESERVED"
	UNRESERVED        InstanceEvent = "UNRESERVED"
)

type NodeRole

type NodeRole string

NodeRole specifies the role for provisioning a node from ansible

const (
	NodeRoleBase             NodeRole = "base"
	NodeRoleDockerCrm        NodeRole = "dockercrm"        // crm and shepherd on platform VM
	NodeRoleDockerShepherdLB NodeRole = "dockershepherdlb" // shepherd on root LB
	NodeRoleK8sCrm           NodeRole = "k8scrm"
	NodeRoleK8sCrmWorker     NodeRole = "k8scrmworker"
)

func (NodeRole) String

func (s NodeRole) String() string

type NodeType

type NodeType int
const (
	NodeTypeAppVM NodeType = iota
	NodeTypeSharedRootLB
	NodeTypeDedicatedRootLB
	NodeTypePlatformVM
	NodeTypePlatformHost
	NodeTypePlatformK8sClusterMaster
	NodeTypePlatformK8sClusterPrimaryNode
	NodeTypePlatformK8sClusterSecondaryNode
	// Cloudlet Compute nodes
	NodeTypeK8sClusterMaster
	NodeTypeK8sClusterNode
	NodeTypeDockerClusterNode
)

func (NodeType) String

func (n NodeType) String() string

type OauthTokenResp

type OauthTokenResp struct {
	TokenType   string `json:"token_type"`
	AccessToken string `json:"access_token"`
}

type ProtoCodec

type ProtoCodec struct{}

Implements grpc.Codec to allow the more recent versions of grpc to use the gogo protobuf marshaling functions.

func (*ProtoCodec) Marshal

func (s *ProtoCodec) Marshal(v interface{}) ([]byte, error)

func (*ProtoCodec) Name

func (s *ProtoCodec) Name() string

func (*ProtoCodec) Unmarshal

func (s *ProtoCodec) Unmarshal(data []byte, v interface{}) error

type RegistryAuth

type RegistryAuth struct {
	AuthType string
	Username string `json:"username"`
	Password string `json:"password"`
	Token    string `json:"token"`
	ApiKey   string `json:"apikey"`
	Hostname string `json:"hostname"`
	Port     string `json:"port"`
}

func GetAccountAuth

func GetAccountAuth(ctx context.Context, name string, vaultConfig *vault.Config) (*RegistryAuth, error)

Same as registry auth, but is always the user/password of an admin or other user account.

type RegistryAuthApi

type RegistryAuthApi interface {
	GetRegistryAuth(ctx context.Context, imgUrl string) (*RegistryAuth, error)
}

type RegistryAuthMgr

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

func NewRegistryAuthMgr

func NewRegistryAuthMgr(vaultConfig *vault.Config, validDomains string) *RegistryAuthMgr

func (*RegistryAuthMgr) DeleteRegistryAuth

func (s *RegistryAuthMgr) DeleteRegistryAuth(ctx context.Context, host, org string) error

func (*RegistryAuthMgr) GetRegistryImageAuth

func (s *RegistryAuthMgr) GetRegistryImageAuth(ctx context.Context, imgUrl string) (*RegistryAuth, error)

GetRegistryImageAuth gets the credentials for pulling the image.

func (*RegistryAuthMgr) GetRegistryOrgAuth

func (s *RegistryAuthMgr) GetRegistryOrgAuth(ctx context.Context, hostOrURL, org string) (*RegistryAuth, error)

GetRegistryOrgAuth gets the credentials for accessing the image registry. If org is AllOrgs, then admin credentials are returned. Otherwise, credentials are scoped to the org.

func (*RegistryAuthMgr) PutRegistryAuth

func (s *RegistryAuthMgr) PutRegistryAuth(ctx context.Context, host, org string, auth *RegistryAuth, checkAndSet int) error

func (*RegistryAuthMgr) UpgradeRegistryAuth

func (s *RegistryAuthMgr) UpgradeRegistryAuth(ctx context.Context, internalRegistry, org string) error

UpgradeDockerRegistryAuth copies docker credentials from hostname-specific vault path to common internal vault path. This is an upgrade function and can be removed once all existing deployments have been upgraded.

type RegistryTags

type RegistryTags struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

type RequestConfig

type RequestConfig struct {
	Timeout               time.Duration
	ResponseHeaderTimeout time.Duration
	Headers               map[string]string
}

type SessionInfo

type SessionInfo struct {
	Token string
}

type SkopeoInspect

type SkopeoInspect struct {
	Name          string
	Digest        string
	RepoTags      []string
	Created       time.Time
	DockerVersion string
	Labels        map[string]string
	Architecture  string
	Os            string
	Layers        []string
	LayersData    []SkopeoInspectLayer
	Env           []string
}

type SkopeoInspectLayer

type SkopeoInspectLayer struct {
	MIMEType string
	Digest   string
	Size     string
}

type StatusObj

type StatusObj interface {
	GetStatus() *edgeproto.StatusInfo
}

type StoragePath

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

func (*StoragePath) AppendPaths

func (s *StoragePath) AppendPaths(paths ...string) error

func (*StoragePath) String

func (s *StoragePath) String() string

func (*StoragePath) Validate

func (s *StoragePath) Validate() error

type StreamObj

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

func (*StreamObj) Add

func (sm *StreamObj) Add(in interface{}, streamer *Streamer)

func (*StreamObj) Get

func (sm *StreamObj) Get(in interface{}) *Streamer

func (*StreamObj) Remove

func (sm *StreamObj) Remove(in interface{}, streamer *Streamer)

func (*StreamObj) SetupCleanupTimer

func (sm *StreamObj) SetupCleanupTimer()

type Streamer

type Streamer struct {
	State edgeproto.StreamState
	// contains filtered or unexported fields
}

func NewStreamer

func NewStreamer() *Streamer

func (*Streamer) Publish

func (s *Streamer) Publish(msg interface{})

func (*Streamer) Stop

func (s *Streamer) Stop()

func (*Streamer) Subscribe

func (s *Streamer) Subscribe() chan interface{}

func (*Streamer) Unsubscribe

func (s *Streamer) Unsubscribe(msgCh chan interface{})

type Streams

type Streams map[interface{}]*Streamer

type TestPublicCertApi

type TestPublicCertApi struct {
	GetCount int
}

TestPublicCertApi implements GetPublicCertApi for unit/e2e testing

func (*TestPublicCertApi) GetPublicCert

func (s *TestPublicCertApi) GetPublicCert(ctx context.Context, commonName string) (*vault.PublicCert, error)

type TrustPolicyExceptionKeyClusterKey

type TrustPolicyExceptionKeyClusterKey struct {
	TpeKey     edgeproto.TrustPolicyExceptionKey
	ClusterKey edgeproto.ClusterKey
}

type VaultPublicCertApi

type VaultPublicCertApi struct {
	VaultConfig *vault.Config
}

VaultPublicCertApi implements GetPublicCertApi by connecting directly to Vault.

func (*VaultPublicCertApi) GetPublicCert

func (s *VaultPublicCertApi) GetPublicCert(ctx context.Context, commonName string) (*vault.PublicCert, error)

type VaultRegistryAuthApi

type VaultRegistryAuthApi struct {
	RegAuthMgr *RegistryAuthMgr
}

func (*VaultRegistryAuthApi) GetRegistryAuth

func (s *VaultRegistryAuthApi) GetRegistryAuth(ctx context.Context, imgUrl string) (*RegistryAuth, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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