Add NetworkAttachmentDefinition reporter
It is necessary to report NetworkAttachmentDefinition
as well as other k8s entities.
@@ -30,6 +30,8 @@ const (
sriovNodeNetworkPolicyEntity = "sriovnetworknodepolicies"
sriovNodeStateEntity = "sriovnetworknodestates"
sriovOperatorConfigsEntity = "sriovoperatorconfigs"
+ k8sCNICNCFEntityURLTemplate = "/apis/k8s.cni.cncf.io/v1/namespaces/%s/%s/"
+ networkAttachmentDefinitionEntity = "network-attachment-definitions"
)
type KubernetesReporter struct {
@@ -111,6 +113,7 @@ func (r *KubernetesReporter) Dump(duration time.Duration) {
r.logDomainXMLs(virtCli)
r.logLogs(virtCli, since)
r.logSRIOVInfo(virtCli)
+ r.logNetworkAttachmentDefinitionInfo(virtCli)
}
// Cleanup cleans up the current content of the artifactsDir
@@ -643,6 +646,17 @@ func (r *KubernetesReporter) logSRIOVOperatorConfigs(virtCli kubecli.KubevirtCli
r.dumpK8sEntityToFile(virtCli, sriovOperatorConfigsEntity, v1.NamespaceAll, operatorConfigPath)
}
+func (r *KubernetesReporter) logNetworkAttachmentDefinitionInfo(virtCli kubecli.KubevirtClient) {
+ nadOutputDir := r.artifactsDir
+
+ r.logNetworkAttachmentDefinition(virtCli, nadOutputDir)
+}
+
+func (r *KubernetesReporter) logNetworkAttachmentDefinition(virtCli kubecli.KubevirtClient, outputFolder string) {
+ networkAttachmentDefinitionsPath := filepath.Join(outputFolder, fmt.Sprintf("%d_networkAttachmentDefinitions.log", r.failureCount))
+ r.dumpK8sEntityToFile(virtCli, networkAttachmentDefinitionEntity, v1.NamespaceAll, networkAttachmentDefinitionsPath)
+}
+
func (r *KubernetesReporter) dumpK8sEntityToFile(virtCli kubecli.KubevirtClient, entityName string, namespace string, outputFilePath string) {
requestURI := fmt.Sprintf(sriovEntityURITemplate, namespace, entityName)
f, err := os.OpenFile(outputFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
