@@ -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+ targetClusterLogCollectionBasePath = "/tmp/target_cluster_logs"
38+ managementClusterLogCollectionBasePath = "/tmp/management_cluster_logs"
39+ Metal3ipamProviderName = "metal3"
4040)
4141
4242type PivotingInput struct {
@@ -64,7 +64,7 @@ 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 (targetClusterLogCollectionBasePath , "beforePivot" ))
6868 if err != nil {
6969 Logf ("Error: %v" , err )
7070 }
@@ -83,17 +83,20 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
8383 }
8484
8585 By ("Fetch container logs" )
86- bootstrapCluster := os .Getenv ("BOOTSTRAP_CLUSTER" )
8786 fetchContainerLogs (& generalContainers , input .ArtifactFolder , input .E2EConfig .MustGetVariable ("CONTAINER_RUNTIME" ))
88- if bootstrapCluster == Kind {
87+ if input . BootstrapClusterProxy . GetName () == Kind {
8988 fetchContainerLogs (& ironicContainers , input .ArtifactFolder , input .E2EConfig .MustGetVariable ("CONTAINER_RUNTIME" ))
9089 }
9190
9291 By ("Fetch manifest for bootstrap cluster before pivot" )
93- err = FetchManifests (input .BootstrapClusterProxy , "/tmp/ manifests/" )
92+ err = FetchManifests (input .BootstrapClusterProxy , filepath . Join ( managementClusterLogCollectionBasePath , "beforePivot" , " manifests" ) )
9493 if err != nil {
9594 Logf ("Error fetching manifests for bootstrap cluster before pivot: %v" , err )
9695 }
96+ err = FetchManifests (input .TargetCluster , filepath .Join (targetClusterLogCollectionBasePath , "beforePivot" , "manifests" ))
97+ if err != nil {
98+ Logf ("Error fetching manifests for Target cluster before pivot: %v" , err )
99+ }
97100 By ("Fetch target cluster kubeconfig for target cluster log collection" )
98101 kconfigPathWorkload := input .TargetCluster .GetKubeconfigPath ()
99102 os .Setenv ("KUBECONFIG_WORKLOAD" , kconfigPathWorkload )
@@ -109,7 +112,7 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
109112
110113 By ("Remove Ironic containers from the source cluster" )
111114 ironicDeploymentType := IronicDeploymentTypeBMO
112- if bootstrapCluster == Kind {
115+ if input . BootstrapClusterProxy . GetName () == Kind {
113116 ironicDeploymentType = IronicDeploymentTypeLocal
114117 } else if GetBoolVariable (input .E2EConfig , "USE_IRSO" ) {
115118 ironicDeploymentType = IronicDeploymentTypeIrSO
@@ -368,18 +371,20 @@ func rePivoting(ctx context.Context, inputGetter func() RePivotingInput) {
368371 numberOfAllBmh := numberOfWorkers + numberOfControlplane
369372
370373 By ("Fetch logs from target cluster after pivot" )
371- err := FetchClusterLogs (input .TargetCluster , filepath .Join (clusterLogCollectionBasePath , "afterPivot" ))
374+ err := FetchClusterLogs (input .TargetCluster , filepath .Join (targetClusterLogCollectionBasePath , "afterPivot" ))
372375 if err != nil {
373376 Logf ("Error: %v" , err )
374377 }
375378
376379 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/" )
380+ err = FetchManifests (input .TargetCluster , filepath .Join (targetClusterLogCollectionBasePath , "afterPivot" , "manifests" ))
379381 if err != nil {
380382 Logf ("Error fetching manifests for workload cluster after pivot: %v" , err )
381383 }
382- os .Unsetenv ("KUBECONFIG_WORKLOAD" )
384+ err = FetchManifests (input .BootstrapClusterProxy , filepath .Join (managementClusterLogCollectionBasePath , "afterPivot" , "manifests" ))
385+ if err != nil {
386+ Logf ("Error fetching manifests for bootstrap cluster before pivot: %v" , err )
387+ }
383388
384389 By ("Remove Ironic deployment from target cluster" )
385390 ironicDeploymentType := IronicDeploymentTypeBMO
@@ -497,7 +502,11 @@ func rePivoting(ctx context.Context, inputGetter func() RePivotingInput) {
497502 })
498503
499504 By ("Fetch manifest for bootstrap cluster after re-pivot" )
500- err = FetchManifests (input .BootstrapClusterProxy , "/tmp/manifests/" )
505+ err = FetchManifests (input .TargetCluster , filepath .Join (targetClusterLogCollectionBasePath , "afterRePivot" , "manifests" ))
506+ if err != nil {
507+ Logf ("Error fetching manifests for workload cluster after pivot: %v" , err )
508+ }
509+ err = FetchManifests (input .BootstrapClusterProxy , filepath .Join (managementClusterLogCollectionBasePath , "afterRePivot" , "manifests" ))
501510 if err != nil {
502511 Logf ("Error fetching manifests for bootstrap cluster before pivot: %v" , err )
503512 }
0 commit comments