@@ -16,7 +16,6 @@ import (
1616 . "github.com/onsi/gomega"
1717 corev1 "k8s.io/api/core/v1"
1818 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
19- "k8s.io/apimachinery/pkg/runtime"
2019 clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
2120 clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
2221 "sigs.k8s.io/cluster-api/cmd/clusterctl/client/config"
@@ -26,17 +25,18 @@ import (
2625)
2726
2827const (
29- bmoPath = "BMOPATH"
30- ironicTLSSetup = "IRONIC_TLS_SETUP"
31- ironicBasicAuth = "IRONIC_BASIC_AUTH"
32- ironicKeepalived = "IRONIC_KEEPALIVED"
33- ironicMariadb = "IRONIC_USE_MARIADB"
34- Kind = "kind"
35- NamePrefix = "NAMEPREFIX"
36- restartContainerCertUpdate = "RESTART_CONTAINER_CERTIFICATE_UPDATED"
37- ironicNamespace = "IRONIC_NAMESPACE"
38- clusterLogCollectionBasePath = "/tmp/target_cluster_logs"
39- Metal3ipamProviderName = "metal3"
28+ bmoPath = "BMOPATH"
29+ ironicTLSSetup = "IRONIC_TLS_SETUP"
30+ ironicBasicAuth = "IRONIC_BASIC_AUTH"
31+ ironicKeepalived = "IRONIC_KEEPALIVED"
32+ ironicMariadb = "IRONIC_USE_MARIADB"
33+ Kind = "kind"
34+ NamePrefix = "NAMEPREFIX"
35+ restartContainerCertUpdate = "RESTART_CONTAINER_CERTIFICATE_UPDATED"
36+ ironicNamespace = "IRONIC_NAMESPACE"
37+ workloadClusterLogCollectionBasePath = "workload_cluster_logs"
38+ bootstrapClusterLogCollectionBasePath = "bootstrap_cluster_logs"
39+ Metal3ipamProviderName = "metal3"
4040)
4141
4242type PivotingInput struct {
@@ -64,7 +64,13 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
6464 ListNodes (ctx , input .TargetCluster .GetClient ())
6565
6666 By ("Fetch logs from target cluster before pivot" )
67- err := FetchClusterLogs (input .TargetCluster , filepath .Join (clusterLogCollectionBasePath , "beforePivot" ))
67+ err := FetchClusterLogs (input .TargetCluster , filepath .Join (input .ArtifactFolder , workloadClusterLogCollectionBasePath , input .TargetCluster .GetName (), "beforePivot" ))
68+ if err != nil {
69+ Logf ("Error: %v" , err )
70+ }
71+
72+ By ("Fetch logs from bootstrap cluster before pivot" )
73+ err = FetchClusterLogs (input .BootstrapClusterProxy , filepath .Join (input .ArtifactFolder , bootstrapClusterLogCollectionBasePath , "beforePivot" ))
6874 if err != nil {
6975 Logf ("Error: %v" , err )
7076 }
@@ -83,17 +89,20 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
8389 }
8490
8591 By ("Fetch container logs" )
86- bootstrapCluster := os .Getenv ("BOOTSTRAP_CLUSTER" )
8792 fetchContainerLogs (& generalContainers , input .ArtifactFolder , input .E2EConfig .MustGetVariable ("CONTAINER_RUNTIME" ))
88- if bootstrapCluster == Kind {
93+ if input . BootstrapClusterProxy . GetName () == Kind {
8994 fetchContainerLogs (& ironicContainers , input .ArtifactFolder , input .E2EConfig .MustGetVariable ("CONTAINER_RUNTIME" ))
9095 }
9196
9297 By ("Fetch manifest for bootstrap cluster before pivot" )
93- err = FetchManifests (input .BootstrapClusterProxy , "/tmp/ manifests/" )
98+ err = FetchManifests (input .BootstrapClusterProxy , filepath . Join ( input . ArtifactFolder , bootstrapClusterLogCollectionBasePath , "beforePivot" , " manifests" ) )
9499 if err != nil {
95100 Logf ("Error fetching manifests for bootstrap cluster before pivot: %v" , err )
96101 }
102+ err = FetchManifests (input .TargetCluster , filepath .Join (input .ArtifactFolder , workloadClusterLogCollectionBasePath , input .TargetCluster .GetName (), "beforePivot" , "manifests" ))
103+ if err != nil {
104+ Logf ("Error fetching manifests for Target cluster before pivot: %v" , err )
105+ }
97106 By ("Fetch target cluster kubeconfig for target cluster log collection" )
98107 kconfigPathWorkload := input .TargetCluster .GetKubeconfigPath ()
99108 os .Setenv ("KUBECONFIG_WORKLOAD" , kconfigPathWorkload )
@@ -109,7 +118,7 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
109118
110119 By ("Remove Ironic containers from the source cluster" )
111120 ironicDeploymentType := IronicDeploymentTypeBMO
112- if bootstrapCluster == Kind {
121+ if input . BootstrapClusterProxy . GetName () == Kind {
113122 ironicDeploymentType = IronicDeploymentTypeLocal
114123 } else if GetBoolVariable (input .E2EConfig , "USE_IRSO" ) {
115124 ironicDeploymentType = IronicDeploymentTypeIrSO
@@ -368,18 +377,25 @@ func rePivoting(ctx context.Context, inputGetter func() RePivotingInput) {
368377 numberOfAllBmh := numberOfWorkers + numberOfControlplane
369378
370379 By ("Fetch logs from target cluster after pivot" )
371- err := FetchClusterLogs (input .TargetCluster , filepath .Join (clusterLogCollectionBasePath , "afterPivot" ))
380+ err := FetchClusterLogs (input .TargetCluster , filepath .Join (input .ArtifactFolder , workloadClusterLogCollectionBasePath , input .TargetCluster .GetName (), "afterPivot" ))
381+ if err != nil {
382+ Logf ("Error: %v" , err )
383+ }
384+ By ("Fetch logs from bootstrap cluster after pivot" )
385+ err = FetchClusterLogs (input .BootstrapClusterProxy , filepath .Join (input .ArtifactFolder , bootstrapClusterLogCollectionBasePath , "afterPivot" ))
372386 if err != nil {
373387 Logf ("Error: %v" , err )
374388 }
375389
376390 By ("Fetch manifest for workload cluster after pivot" )
377- workloadClusterProxy := framework .NewClusterProxy ("workload-cluster-after-pivot" , os .Getenv ("KUBECONFIG" ), runtime .NewScheme ())
378- err = FetchManifests (workloadClusterProxy , "/tmp/manifests/" )
391+ err = FetchManifests (input .TargetCluster , filepath .Join (input .ArtifactFolder , workloadClusterLogCollectionBasePath , input .TargetCluster .GetName (), "afterPivot" , "manifests" ))
379392 if err != nil {
380393 Logf ("Error fetching manifests for workload cluster after pivot: %v" , err )
381394 }
382- os .Unsetenv ("KUBECONFIG_WORKLOAD" )
395+ err = FetchManifests (input .BootstrapClusterProxy , filepath .Join (input .ArtifactFolder , bootstrapClusterLogCollectionBasePath , "afterPivot" , "manifests" ))
396+ if err != nil {
397+ Logf ("Error fetching manifests for bootstrap cluster before pivot: %v" , err )
398+ }
383399
384400 By ("Remove Ironic deployment from target cluster" )
385401 ironicDeploymentType := IronicDeploymentTypeBMO
@@ -497,7 +513,11 @@ func rePivoting(ctx context.Context, inputGetter func() RePivotingInput) {
497513 })
498514
499515 By ("Fetch manifest for bootstrap cluster after re-pivot" )
500- err = FetchManifests (input .BootstrapClusterProxy , "/tmp/manifests/" )
516+ err = FetchManifests (input .TargetCluster , filepath .Join (input .ArtifactFolder , workloadClusterLogCollectionBasePath , input .TargetCluster .GetName (), "afterRePivot" , "manifests" ))
517+ if err != nil {
518+ Logf ("Error fetching manifests for workload cluster after pivot: %v" , err )
519+ }
520+ err = FetchManifests (input .BootstrapClusterProxy , filepath .Join (input .ArtifactFolder , bootstrapClusterLogCollectionBasePath , "afterRePivot" , "manifests" ))
501521 if err != nil {
502522 Logf ("Error fetching manifests for bootstrap cluster before pivot: %v" , err )
503523 }
0 commit comments