Skip to content

Commit

Permalink
Gather PodNetworkConnectivityChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
natiiix committed Mar 12, 2021
1 parent c53ee95 commit 4588d17
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/gather/clusterconfig/0_gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ var gatherFunctions = map[string]gathering{
"sap_license_management_logs": failable(GatherSAPVsystemIptablesLogs),
"sap_pods": failable(GatherSAPPods),
"olm_operators": failable(GatherOLMOperators),
"pod_network_connectivity_checks": important(GatherPNCC),
}

var startTime time.Time
Expand Down
3 changes: 3 additions & 0 deletions pkg/gather/clusterconfig/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ var (
datahubGroupVersionResource = schema.GroupVersionResource{
Group: "installers.datahub.sap.com", Version: "v1alpha1", Resource: "datahubs",
}
pnccGroupVersionResource = schema.GroupVersionResource{
Group: "controlplane.operator.openshift.io", Version: "v1alpha1", Resource: "podnetworkconnectivitychecks",
}
)

func init() {
Expand Down
38 changes: 38 additions & 0 deletions pkg/gather/clusterconfig/pod_network_connectivity_checks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package clusterconfig

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"

"github.com/openshift/insights-operator/pkg/record"
)

// GatherPNCC collects PodNetworkConnectivityChecks.
func GatherPNCC(g *Gatherer, c chan<- gatherResult) {
gatherDynamicClient, err := dynamic.NewForConfig(g.gatherKubeConfig)
if err != nil {
c <- gatherResult{errors: []error{err}}
return
}
gatherKubeClient, err := kubernetes.NewForConfig(g.gatherProtoKubeConfig)
if err != nil {
c <- gatherResult{errors: []error{err}}
return
}

records, errors := gatherPNCC(g.ctx, gatherDynamicClient, gatherKubeClient.CoreV1())
c <- gatherResult{records: records, errors: errors}
}

func gatherPNCC(ctx context.Context, dynamicClient dynamic.Interface, coreClient corev1client.CoreV1Interface) ([]record.Record, []error) {
pnccList, err := dynamicClient.Resource(pnccGroupVersionResource).List(ctx, metav1.ListOptions{})
if err != nil {
return nil, []error{err}
}

return []record.Record{{Name: "config/aaaaaaaaa", Item: record.JSONMarshaller{Object: pnccList}}}, nil
}

0 comments on commit 4588d17

Please sign in to comment.