store

package
v0.20.6 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectResourceService     = "service"
	ObjectResourceDeployment  = "deployment"
	ObjectResourceApplication = "application"
	ObjectResourceConfigmap   = "configmap"
	ObjectResourceSecret      = "secret"

	ResourceStatusRunning   = "running"
	ResourceStatusFailed    = "failed"
	ResourceStatusFinish    = "finish"
	ResourceStatusOperating = "operating"
)
View Source
const (
	StoreOperatorCreate = "create"
	StoreOperatorDelete = "delete"
	StoreOperatorUpdate = "update"
	StoreOperatorFetch  = "fetch"
)

Variables

View Source
var (
	//metric value is object status
	//service、configmap、secret、deployment status only 0 show success
	//application status 0 show Staging、Deploying、Operating、RollingUpdate; 1 show Running; 2 show Finish; 3 show Abnormal,Error
	ObjectResourceInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "object_resource_info",
		Help:      "Object resource info",
	}, []string{"resource", "namespace", "name", "status"})

	//metric value is taskgroup status
	//0 show Staging、Starting; 1 show Running; 2 show Finish、Killing、Killed; 3 show Error、Failed; 4 show Lost
	TaskgroupInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "taskgroup_info",
		Help:      "Taskgroup info",
	}, []string{"namespace", "application", "taskgroup"})

	AgentCpuResourceTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "agent_cpu_resource_total",
		Help:      "Agent cpu resource total",
	}, []string{"InnerIP", "clusterId"})

	AgentMemoryResourceTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "agent_memory_resource_total",
		Help:      "Agent memory resource total",
	}, []string{"InnerIP", "clusterId"})

	AgentCpuResourceRemain = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "agent_cpu_resource_remain",
		Help:      "Agent cpu resource remain",
	}, []string{"InnerIP", "clusterId"})

	AgentMemoryResourceRemain = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "agent_memory_resource_remain",
		Help:      "Agent memory resource remain",
	}, []string{"InnerIP", "clusterId"})

	AgentIpResourceRemain = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "agent_ip_resource_remain",
		Help:      "Agent ip resource remain",
	}, []string{"InnerIP", "clusterId"})

	ClusterCpuResouceRemain = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "cluster_cpu_resource_remain",
		Help:      "Cluster cpu resource remain",
	}, []string{"clusterId"})

	ClusterMemoryResouceRemain = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "cluster_memory_resource_remain",
		Help:      "Cluster memory resource remain",
	}, []string{"clusterId"})

	ClusterCpuResouceTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "cluster_cpu_resource_total",
		Help:      "Cluster cpu resource total",
	}, []string{"clusterId"})

	ClusterMemoryResouceTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "cluster_memory_resource_total",
		Help:      "Cluster memory resource total",
	}, []string{"clusterId"})

	StorageOperatorTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "storage_operator_total",
		Help:      "Storage operator total",
	}, []string{"operator"})

	StorageOperatorLatencyMs = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "storage_operator_latency_ms",
		Help:      "Storage operator latency Millisecond",
	}, []string{"operator"})

	StorageOperatorFailedTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: types.MetricsNamespaceScheduler,
		Subsystem: types.MetricsSubsystemScheduler,
		Name:      "storage_operator_failed_total",
		Help:      "Storage operator failed total",
	}, []string{"operator"})
)

Metrics the store info

View Source
var (
	ErrNoFound = errors.New("store: Not Found")
)

Functions

func ReportAgentInfoMetrics

func ReportAgentInfoMetrics(ip, clusterId string, totalCpu, remainCpu, totalMem, remainMem, remainIp float64)

func ReportClusterInfoMetrics

func ReportClusterInfoMetrics(clusterId string, remainCpu, totalCpu, remainMem, totalMem float64)

func ReportObjectResourceInfoMetrics

func ReportObjectResourceInfoMetrics(resource, ns, name, status string)

func ReportStorageOperatorMetrics

func ReportStorageOperatorMetrics(operator string, started time.Time, failed bool)

func ReportTaskgroupInfoMetrics

func ReportTaskgroupInfoMetrics(ns, name, taskgroupId, status string)

Types

type Dbdrvier

type Dbdrvier interface {
	// Connect
	Connect() error
	// save data to db
	Insert(string, string) error
	// fetch data from db
	Fetch(string) ([]byte, error)
	// update data to db
	Update(string, string) error
	// delete data from db
	Delete(string) error
	// list the key of the data from db
	List(string) ([]string, error)
}

The interface for db operations

type Store

type Store interface {

	// save framework id to db
	SaveFrameworkID(string) error
	// fetch framework id from db
	FetchFrameworkID() (string, error)
	// check if framework id is in db or not
	HasFrameworkID() (bool, error)

	// save application to db
	SaveApplication(*types.Application) error
	// fetch application from db
	FetchApplication(string, string) (*types.Application, error)
	// list all applications under a namepace
	ListApplications(string) ([]*types.Application, error)
	// delete application from db
	DeleteApplication(string, string) error
	// list namespaces
	ListRunAs() ([]string, error)
	// list application nodes
	ListApplicationNodes(runAs string) ([]string, error)
	// lock application
	LockApplication(appID string)
	// unLock application
	UnLockApplication(appID string)
	// init lock pool
	InitLockPool()
	// list all applications
	ListAllApplications() ([]*types.Application, error)

	// save task to db
	SaveTask(*types.Task) error
	// list all tasks belong to a application by namespace and application name
	//ListTasks(string, string) ([]*types.Task, error)
	// fetch task from db
	FetchTask(string) (*types.Task, error)
	// delete task from db
	DeleteTask(string) error

	// save version to db
	SaveVersion(*types.Version) error
	// list all versions
	ListVersions(string, string) ([]string, error)
	// fetch version from db by version id
	FetchVersion(string, string, string) (*types.Version, error)
	// delete version from db
	DeleteVersion(string, string, string) error
	// delete version's root node
	DeleteVersionNode(runAs, versionId string) error
	// get version from db
	GetVersion(runAs, appId string) (*types.Version, error)
	//update version, current only migrate tool use it
	UpdateVersion(version *types.Version) error

	// save taskgroup to db
	SaveTaskGroup(*types.TaskGroup) error
	// list taskgroups under namespace,appid
	ListTaskGroups(string, string) ([]*types.TaskGroup, error)
	// fetch taskgroup
	FetchTaskGroup(string) (*types.TaskGroup, error)
	FetchDBTaskGroup(string) (*types.TaskGroup, error)
	// delete taskgroup by taskgroup id
	DeleteTaskGroup(string) error
	//list mesos cluster taskgroups, include: application、deployment、daemonset...
	ListClusterTaskgroups() ([]*types.TaskGroup, error)

	// save agent
	SaveAgent(agent *types.Agent) error
	// fetch agent
	FetchAgent(Key string) (*types.Agent, error)
	// list agents
	ListAgentNodes() ([]string, error)
	// delete agent
	DeleteAgent(key string) error
	// list all agent
	ListAllAgents() ([]*types.Agent, error)

	// save agentsetting
	SaveAgentSetting(*commtypes.BcsClusterAgentSetting) error
	// fetch agentsetting
	FetchAgentSetting(string) (*commtypes.BcsClusterAgentSetting, error)
	// delete agentsetting
	DeleteAgentSetting(string) error
	// list agentsetting
	ListAgentSettingNodes() ([]string, error)
	ListAgentsettings() ([]*commtypes.BcsClusterAgentSetting, error)
	// save agentschedinfo
	SaveAgentSchedInfo(*types.AgentSchedInfo) error
	// fetch agentschedinfo
	FetchAgentSchedInfo(string) (*types.AgentSchedInfo, error)
	// delete agentschedinfo
	DeleteAgentSchedInfo(string) error

	// save configmap
	SaveConfigMap(configmap *commtypes.BcsConfigMap) error
	// fetch configmap
	FetchConfigMap(ns, name string) (*commtypes.BcsConfigMap, error)
	// delete configmap
	DeleteConfigMap(ns, name string) error
	// list ns configmap
	//ListConfigmaps(runAs string) ([]*commtypes.BcsConfigMap, error)
	// list all configmap
	ListAllConfigmaps() ([]*commtypes.BcsConfigMap, error)

	// save secret
	SaveSecret(secret *commtypes.BcsSecret) error
	// fetch secret
	FetchSecret(ns, name string) (*commtypes.BcsSecret, error)
	// delete secret
	DeleteSecret(ns, name string) error
	// list ns secret
	//ListSecrets(runAs string) ([]*commtypes.BcsSecret, error)
	// list all secret
	ListAllSecrets() ([]*commtypes.BcsSecret, error)

	// save service
	SaveService(service *commtypes.BcsService) error
	// fetch service
	FetchService(ns, name string) (*commtypes.BcsService, error)
	// delete service
	DeleteService(ns, name string) error
	// list service by namespace
	//ListServices(runAs string) ([]*commtypes.BcsService, error)
	// list all services
	ListAllServices() ([]*commtypes.BcsService, error)

	// save endpoint
	SaveEndpoint(endpoint *commtypes.BcsEndpoint) error
	// fetch endpoint
	FetchEndpoint(ns, name string) (*commtypes.BcsEndpoint, error)
	// delete endpoint
	DeleteEndpoint(ns, name string) error

	// save deployment
	SaveDeployment(deployment *types.Deployment) error
	// fetch deployment
	FetchDeployment(ns, name string) (*types.Deployment, error)
	// list deployments
	ListDeployments(ns string) ([]*types.Deployment, error)
	// delete deployment
	DeleteDeployment(ns, name string) error
	// list all deployment
	ListAllDeployments() ([]*types.Deployment, error)

	// init deployments lock pool
	InitDeploymentLockPool()
	// list namespaces for deployments
	ListDeploymentRunAs() ([]string, error)
	// list deployment nodes
	ListDeploymentNodes(runAs string) ([]string, error)
	// lock a deployment
	LockDeployment(deploymentName string)
	// unlock a deployment
	UnLockDeployment(deploymentName string)

	// init cache manager
	InitCacheMgr(bool) error
	// uninit cache manager
	UnInitCacheMgr() error

	//save custom resource register
	SaveCustomResourceRegister(*commtypes.Crr) error

	//delete custom resource register
	//para1: crr.spec.names.kind
	DeleteCustomResourceRegister(string) error

	//fetch custom resource register list
	ListCustomResourceRegister() ([]*commtypes.Crr, error)

	//list all crds
	ListAllCrds(kind string) ([]*commtypes.Crd, error)

	//save custom resource definition
	SaveCustomResourceDefinition(*commtypes.Crd) error

	//delete custom resource definition
	//para1: crd.kind
	//para2: namespace
	//para3: name
	DeleteCustomResourceDefinition(string, string, string) error

	// init command lock
	InitCmdLockPool()
	//lock command by command_id
	LockCommand(cmdId string)
	//unlock command by command_id
	UnLockCommand(cmdId string)
	// save command
	SaveCommand(command *commtypes.BcsCommandInfo) error
	// fetch command
	FetchCommand(ID string) (*commtypes.BcsCommandInfo, error)
	// delete command
	DeleteCommand(ID string) error
	//fetch custom resource definition list
	//para1: crd.kind
	//para2: namespace
	ListCustomResourceDefinition(kind, ns string) ([]*commtypes.Crd, error)

	//fetch custom resource definition
	//para1: crd.kind
	//para2: namespace
	//para3: name
	FetchCustomResourceDefinition(kind, ns, name string) (*commtypes.Crd, error)

	/*=========AdmissionWebhook==========*/
	SaveAdmissionWebhook(admission *commtypes.AdmissionWebhookConfiguration) error
	FetchAdmissionWebhook(ns, name string) (*commtypes.AdmissionWebhookConfiguration, error)
	DeleteAdmissionWebhook(ns, name string) error
	FetchAllAdmissionWebhooks() ([]*commtypes.AdmissionWebhookConfiguration, error)

	//start metrics
	StartStoreObjectMetrics()
	//stop metrics
	StopStoreMetrics()
	//fetch daemonset
	FetchDaemonset(namespace, name string) (*types.BcsDaemonset, error)
	//save daemonset
	SaveDaemonset(daemon *types.BcsDaemonset) error
	//List all daemonsets
	ListAllDaemonset() ([]*types.BcsDaemonset, error)
	//delete daemonset
	DeleteDaemonset(namespace, name string) error
	//list daemonset't taskgroup
	ListDaemonsetTaskGroups(namespace, name string) ([]*types.TaskGroup, error)
}

The interface for object storage

Directories

Path Synopsis
Package store implements the interface for db operations and objects storage, currently using ZK Including Framework, application, version, task, taskgroup, configmap, secret, deployment, service, endpoint, agent.
Package store implements the interface for db operations and objects storage, currently using ZK Including Framework, application, version, task, taskgroup, configmap, secret, deployment, service, endpoint, agent.
Package store implements the interface for db operations and objects storage, currently using ZK Including Framework, application, version, task, taskgroup, configmap, secret, deployment, service, endpoint, agent.
Package store implements the interface for db operations and objects storage, currently using ZK Including Framework, application, version, task, taskgroup, configmap, secret, deployment, service, endpoint, agent.

Jump to

Keyboard shortcuts

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