Documentation ¶
Index ¶
- Constants
- func BlockingRunCommandWithTimeout(command []string, timeoutSeconds int32) ([]byte, error)
- func ComputeHash(template interface{}) string
- func CreateFile(path string, content string) error
- func DecompressHPROFFileArchives(dirname string, fileInfo os.FileInfo, timeoutSeconds int32) (string, string, string, error)
- func DiskUsage(path string) (int, error)
- func FormatURL(scheme string, host string, port string, path string) *url.URL
- func GetAvailableBytes(path string) uint64
- func GetAvailablePort() (int, error)
- func GetDiagnosisCondition(status *diagnosisv1.DiagnosisStatus, ...) (int, *diagnosisv1.DiagnosisCondition)
- func GetDiagnosisConditionFromList(conditions []diagnosisv1.DiagnosisCondition, ...) (int, *diagnosisv1.DiagnosisCondition)
- func GetFreeBytes(path string) uint64
- func GetNodeUnhealthyConditionType(node corev1.Node) corev1.NodeConditionType
- func GetPodUnhealthyReason(pod corev1.Pod) string
- func GetProgramPID(program string) ([]int, error)
- func GetTotalBytes(path string) uint64
- func GetUsedBytes(path string) uint64
- func IsDiagnosisCompleted(diagnosis diagnosisv1.Diagnosis) bool
- func IsDiagnosisNodeNameMatched(diagnosis diagnosisv1.Diagnosis, nodeName string) bool
- func IsNodeReady(node corev1.Node) bool
- func MoveFiles(src string, dst string) error
- func ParseHPROFFile(workdir string, path string, timeoutSeconds int32) error
- func QueueDiagnosis(ctx context.Context, channel chan diagnosisv1.Diagnosis, ...) error
- func QueueEvent(ctx context.Context, channel chan corev1.Event, event corev1.Event) error
- func QueueOperationSet(ctx context.Context, channel chan diagnosisv1.OperationSet, ...) error
- func RemoveFile(path string) error
- func RetrieveDiagnosesOnNode(diagnoses []diagnosisv1.Diagnosis, nodeName string) []diagnosisv1.Diagnosis
- func RetrievePodsOnNode(pods []corev1.Pod, nodeName string) []corev1.Pod
- func SafeEncodeString(s string) string
- func ScanLastNonEmptyLine(data []byte, eof bool) (advance int, token []byte, err error)
- func StringToNamespacedName(s string) (types.NamespacedName, error)
- func Unzip(src string, dst string, timeoutSeconds int32) error
- func UpdateDiagnosisCondition(status *diagnosisv1.DiagnosisStatus, condition *diagnosisv1.DiagnosisCondition) bool
- func UpdatePodUnhealthyReasonStatistics(containerStateReasons map[string]int, reason string) bool
Constants ¶
const ( // ProfilerEndpointExpiredValue is the value of endpoint in profiler status after expiration duration. ProfilerEndpointExpiredValue = "expired" // KubeletRunDirectory specifies the directory where the kubelet runtime information is stored. KubeletRunDirectory = "/var/lib/kubelet" // KubeletPodDirectory specifies the directory where the kubelet pod information is stored. KubeletPodDirectory = "/var/lib/kubelet/pods" // DefautlNamespace is the default namespace of kubediag. DefautlNamespace = "kubediag" // PodKillGracePeriodSeconds is the duration in seconds after the pod is forcibly halted // with a kill signal and the time when the pod is taken as an abormal pod. PodKillGracePeriodSeconds = 30 // TerminatingPodDiagnosisNamePrefix is the name prefix for creating terminating pod diagnosis. TerminatingPodDiagnosisNamePrefix = "terminating-pod" // MemoryAnalyzerLeakSuspectsReportAPI is the eclipse memory analyzer api for leak suspects report. MemoryAnalyzerLeakSuspectsReportAPI = "org.eclipse.mat.api:suspects" // MemoryAnalyzerSystemOverviewReportAPI is the eclipse memory analyzer api for system overview report. MemoryAnalyzerSystemOverviewReportAPI = "org.eclipse.mat.api:overview" // MemoryAnalyzerTopComponentsReportAPI is the eclipse memory analyzer api for top components report. MemoryAnalyzerTopComponentsReportAPI = "org.eclipse.mat.api:top_components" // MemoryAnalyzerLeakSuspectsSuffix is the suffix for leak suspects report directory. MemoryAnalyzerLeakSuspectsSuffix = "_Leak_Suspects" // MemoryAnalyzerSystemOverviewSuffix is the suffix for system overview report directory. MemoryAnalyzerSystemOverviewSuffix = "_System_Overview" // MemoryAnalyzerTopComponentsSuffix is the suffix for top components report directory. MemoryAnalyzerTopComponentsSuffix = "_Top_Components" // MemoryAnalyzerHomepage is the html text for memory analyzer homepage. MemoryAnalyzerHomepage = `` /* 200-byte string literal not displayed */ // GoProfilerPathPrefix is the path prefix for go profiler pprof url. GoProfilerPathPrefix = "/debug/pprof/" // KubeDiagPrefix is the key prefix for annotations about kubediag. KubeDiagPrefix = "diagnosis.kubediag.org/" // OperationSetUniqueLabelKey is the default key of the label that is added to existing OperationSets and Diagnoses // to prevent conflicts on changed OperationSets and running Diagnoses. OperationSetUniqueLabelKey = "adjacency-list-hash" // AlphaNums omits vowels from the set of available characters to reduce the chances of "bad words" being formed. AlphaNums = "bcdfghjklmnpqrstvwxz2456789" )
Variables ¶
This section is empty.
Functions ¶
func BlockingRunCommandWithTimeout ¶
BlockingRunCommandWithTimeout executes command in blocking mode with timeout seconds.
func ComputeHash ¶
func ComputeHash(template interface{}) string
ComputeHash returns a hash value calculated from a template. The hash will be safe encoded to avoid bad words.
func CreateFile ¶ added in v0.2.2
CreateFile creates a file on the destination path and writes content to the the file.
func DecompressHPROFFileArchives ¶
func DecompressHPROFFileArchives(dirname string, fileInfo os.FileInfo, timeoutSeconds int32) (string, string, string, error)
DecompressHPROFFileArchives decompresses result archives from hprof files by executing "unzip" command.
func GetAvailableBytes ¶
GetAvailableBytes gets available bytes in filesystem.
func GetAvailablePort ¶
GetAvailablePort returns a free open port that is ready to use.
func GetDiagnosisCondition ¶
func GetDiagnosisCondition(status *diagnosisv1.DiagnosisStatus, conditionType diagnosisv1.DiagnosisConditionType) (int, *diagnosisv1.DiagnosisCondition)
GetDiagnosisCondition extracts the provided condition from the given status. Returns -1 and nil if the condition is not present, otherwise returns the index of the located condition.
func GetDiagnosisConditionFromList ¶
func GetDiagnosisConditionFromList(conditions []diagnosisv1.DiagnosisCondition, conditionType diagnosisv1.DiagnosisConditionType) (int, *diagnosisv1.DiagnosisCondition)
GetDiagnosisConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.
func GetFreeBytes ¶
GetFreeBytes gets free bytes in filesystem.
func GetNodeUnhealthyConditionType ¶
func GetNodeUnhealthyConditionType(node corev1.Node) corev1.NodeConditionType
GetNodeUnhealthyConditionType extracts the condition type of unhealthy node. The parameter must be an unhealthy node. It returns the type of the first unhealthy condition.
func GetPodUnhealthyReason ¶
GetPodUnhealthyReason extracts the reason of terminated or waiting container in the pod if the pod is not ready. The parameter must be an unhealthy pod. It returns the reason of the first terminated or waiting container.
func GetProgramPID ¶
GetProgramPID finds the process ID of a running program by executing "pidof" command.
func GetTotalBytes ¶
GetTotalBytes gets total bytes in filesystem.
func GetUsedBytes ¶
GetUsedBytes gets used bytes in filesystem.
func IsDiagnosisCompleted ¶
func IsDiagnosisCompleted(diagnosis diagnosisv1.Diagnosis) bool
IsDiagnosisCompleted return true if Diagnosis is failed or succeed
func IsDiagnosisNodeNameMatched ¶
func IsDiagnosisNodeNameMatched(diagnosis diagnosisv1.Diagnosis, nodeName string) bool
IsDiagnosisNodeNameMatched checks if the diagnosis is on the specific node. It returns true if current node name of the diagnosis matches provided NodeName field or the NodeName based on podReference field.
func IsNodeReady ¶
IsNodeReady returns true if its Ready condition is set to true and it does not have NetworkUnavailable condition set to true.
func ParseHPROFFile ¶
ParseHPROFFile parses hprof file with eclipse memory analyzer. The results are stored in zip files under the same directory of hprof file. It takes command working directory, hprof file path and timeout seconds as parameters.
func QueueDiagnosis ¶
func QueueDiagnosis(ctx context.Context, channel chan diagnosisv1.Diagnosis, diagnosis diagnosisv1.Diagnosis) error
QueueDiagnosis sends a diagnosis to a channel. It returns an error if the channel is blocked.
func QueueEvent ¶
QueueEvent sends an event to a channel. It returns an error if the channel is blocked.
func QueueOperationSet ¶
func QueueOperationSet(ctx context.Context, channel chan diagnosisv1.OperationSet, operationSet diagnosisv1.OperationSet) error
QueueOperationSet sends an operation set to a channel. It returns an error if the channel is blocked.
func RemoveFile ¶
RemoveFile removes a file or a directory by executing "rm" command.
func RetrieveDiagnosesOnNode ¶
func RetrieveDiagnosesOnNode(diagnoses []diagnosisv1.Diagnosis, nodeName string) []diagnosisv1.Diagnosis
RetrieveDiagnosesOnNode retrieves all diagnoses on the provided node.
func RetrievePodsOnNode ¶
RetrievePodsOnNode retrieves all pods on the provided node.
func SafeEncodeString ¶
SafeEncodeString encodes s using the same characters as rand.String. This reduces the chances of bad words and ensures that strings generated from hash functions appear consistent throughout the API.
func ScanLastNonEmptyLine ¶ added in v0.2.2
ScanLastNonEmptyLine get the last available line. It is an implementation of scanner.SplitFunc.
func StringToNamespacedName ¶
func StringToNamespacedName(s string) (types.NamespacedName, error)
StringToNamespacedName converts a string to NamespacedName.
func Unzip ¶
Unzip decompresses a zip archive, moving all files and folders within the zip file to an output directory by executing "unzip" command. It takes source zip file, destination output directory and timeout seconds as parameters.
func UpdateDiagnosisCondition ¶
func UpdateDiagnosisCondition(status *diagnosisv1.DiagnosisStatus, condition *diagnosisv1.DiagnosisCondition) bool
UpdateDiagnosisCondition updates existing diagnosis condition or creates a new one. Sets LastTransitionTime to now if the status has changed. Returns true if diagnosis condition has changed or has been added.
Types ¶
This section is empty.