mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
@@ -13,7 +13,7 @@ import (
|
||||
func analyzeStatefulsetStatus(analyzer *troubleshootv1beta1.StatefulsetStatus, getCollectedFileContents func(string) ([]byte, error)) (*AnalyzeResult, error) {
|
||||
collected, err := getCollectedFileContents(path.Join("cluster-resources", "statefulsets", fmt.Sprintf("%s.json", analyzer.Namespace)))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to read collected deployments from namespace")
|
||||
return nil, errors.Wrap(err, "failed to read collected statefulsets from namespace")
|
||||
}
|
||||
|
||||
var statefulsets []appsv1.StatefulSet
|
||||
|
||||
@@ -24,6 +24,8 @@ type ClusterResourcesOutput struct {
|
||||
ServicesErrors []byte `json:"cluster-resources/services-errors.json,omitempty"`
|
||||
Deployments map[string][]byte `json:"cluster-resources/deployments,omitempty"`
|
||||
DeploymentsErrors []byte `json:"cluster-resources/deployments-errors.json,omitempty"`
|
||||
StatefulSets map[string][]byte `json:"cluster-resources/statefulsets,omitempty"`
|
||||
StatefulSetsErrors []byte `json:"cluster-resources/statefulsets-errors.json,omitempty"`
|
||||
Ingress map[string][]byte `json:"cluster-resources/ingress,omitempty"`
|
||||
IngressErrors []byte `json:"cluster-resources/ingress-errors.json,omitempty"`
|
||||
StorageClasses []byte `json:"cluster-resources/storage-classes.json,omitempty"`
|
||||
@@ -98,6 +100,14 @@ func ClusterResources(ctx *Context) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// statefulsets
|
||||
statefulsets, statefulsetsErrors := statefulsets(client, namespaceNames)
|
||||
clusterResourcesOutput.StatefulSets = statefulsets
|
||||
clusterResourcesOutput.StatefulSetsErrors, err = marshalNonNil(statefulsetsErrors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// ingress
|
||||
ingress, ingressErrors := ingress(client, namespaceNames)
|
||||
clusterResourcesOutput.Ingress = ingress
|
||||
@@ -278,6 +288,29 @@ func deployments(client *kubernetes.Clientset, namespaces []string) (map[string]
|
||||
return deploymentsByNamespace, errorsByNamespace
|
||||
}
|
||||
|
||||
func statefulsets(client *kubernetes.Clientset, namespaces []string) (map[string][]byte, map[string]string) {
|
||||
statefulsetsByNamespace := make(map[string][]byte)
|
||||
errorsByNamespace := make(map[string]string)
|
||||
|
||||
for _, namespace := range namespaces {
|
||||
statefulsets, err := client.AppsV1().StatefulSets(namespace).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
errorsByNamespace[namespace] = err.Error()
|
||||
continue
|
||||
}
|
||||
|
||||
b, err := json.MarshalIndent(statefulsets.Items, "", " ")
|
||||
if err != nil {
|
||||
errorsByNamespace[namespace] = err.Error()
|
||||
continue
|
||||
}
|
||||
|
||||
statefulsetsByNamespace[namespace+".json"] = b
|
||||
}
|
||||
|
||||
return statefulsetsByNamespace, errorsByNamespace
|
||||
}
|
||||
|
||||
func ingress(client *kubernetes.Clientset, namespaces []string) (map[string][]byte, map[string]string) {
|
||||
ingressByNamespace := make(map[string][]byte)
|
||||
errorsByNamespace := make(map[string]string)
|
||||
@@ -513,6 +546,10 @@ func (c *ClusterResourcesOutput) Redact() (*ClusterResourcesOutput, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
statefulsets, err := redactMap(c.StatefulSets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ingress, err := redactMap(c.Ingress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -545,6 +582,8 @@ func (c *ClusterResourcesOutput) Redact() (*ClusterResourcesOutput, error) {
|
||||
ServicesErrors: c.ServicesErrors,
|
||||
Deployments: deployments,
|
||||
DeploymentsErrors: c.DeploymentsErrors,
|
||||
StatefulSets: statefulsets,
|
||||
StatefulSetsErrors: c.StatefulSetsErrors,
|
||||
Ingress: ingress,
|
||||
IngressErrors: c.IngressErrors,
|
||||
StorageClasses: storageClasses,
|
||||
|
||||
Reference in New Issue
Block a user