cputil

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectsDisplayNameCache = "projectDisplayName"
	NamespacesCache          = "allNamespaces"
)

Variables

View Source
var PodStatus = map[string]string{
	"Completed":         "success",
	"ContainerCreating": "processing",
	"CrashLoopBackOff":  "error",
	"Error":             "error",
	"Evicted":           "default",
	"ImagePullBackOff":  "error",
	"ErrImagePull":      "error",
	"Pending":           "processing",
	"Running":           "success",
	"Terminating":       "processing",
	"OOMKilled":         "error",
}

PodStatus is a map of pod status to normal status

Functions

func CalculateNodeRes

func CalculateNodeRes(node data.Object, allocatedCPU, allocatedMem, allocatedPods int64) (unallocatedCPU, unallocatedMem, leftCPU, leftMem, leftPods int64)

CalculateNodeRes calculate unallocated cpu, memory and left cpu, mem, pods for given node and its allocated cpu, memory

func GetAllNamespacesFromCache added in v1.4.0

func GetAllNamespacesFromCache(ctx context.Context, steveServer cmp.SteveServer, userID, orgID, clusterName string) ([]string, error)

GetAllNamespacesFromCache get all namespaces name list by k8s client with cache

func GetAllProjectsDisplayNameFromCache added in v1.4.0

func GetAllProjectsDisplayNameFromCache(bdl *bundle.Bundle, orgID string) (map[uint64]string, error)

GetAllProjectsDisplayNameFromCache get all projects in org and return a project id to project display name map with cache

func GetImpersonateClient added in v1.4.0

func GetImpersonateClient(steveServer cmp.SteveServer, userID, orgID, clusterName string) (*k8sclient.K8sClient, error)

GetImpersonateClient authenticate user by steve server and return an impersonate k8s client

func GetWorkloadAgeAndImage

func GetWorkloadAgeAndImage(obj data.Object) (string, string, error)

GetWorkloadAgeAndImage get age and image for workloads from .metadata.fields

func IsDeepEqual added in v1.5.0

func IsDeepEqual(objA, objB interface{}) (bool, error)

IsDeepEqual return true if objA and objB is deep equal. Used for unit testing.

func IsJsonEqual added in v1.4.0

func IsJsonEqual(objA, objB interface{}) (bool, error)

IsJsonEqual return true if objA and objB is same after marshal by json. Used for unit testing.

func ParsePodStatus added in v1.5.0

func ParsePodStatus(state string) (string, bool)

func ParseWorkloadID

func ParseWorkloadID(id string) (apistructs.K8SResType, string, string, error)

ParseWorkloadID get workloadKind, namespace and name from id

func ParseWorkloadStatus

func ParseWorkloadStatus(obj data.Object) (string, string, bool, error)

ParseWorkloadStatus get status for workloads from .metadata.fields

func ResourceToString

func ResourceToString(sdk *cptype.SDK, res float64, format resource.Format) string

ResourceToString return resource with unit Only support resource.DecimalSI and resource.BinarySI format Original unit is m (for DecimalSI) or B (for resource.BinarySI) Accurate to 1 decimal places. Zero in suffix will be removed

Types

This section is empty.

Jump to

Keyboard shortcuts

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