Skip to content

Commit ad12f6a

Browse files
committed
test: stream logs for CPI and CSI to artifacts
1 parent 3559ab2 commit ad12f6a

10 files changed

+80
-15
lines changed

packaging/flavorgen/cloudprovider/csi/vsphere-csi-driver.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ apiVersion: apps/v1
193193
metadata:
194194
name: vsphere-csi-controller
195195
namespace: vmware-system-csi
196+
labels:
197+
component: "csi"
196198
spec:
197199
replicas: 3
198200
strategy:
@@ -579,6 +581,8 @@ apiVersion: apps/v1
579581
metadata:
580582
name: vsphere-csi-node-windows
581583
namespace: vmware-system-csi
584+
labels:
585+
component: "csi"
582586
spec:
583587
selector:
584588
matchLabels:

templates/cluster-template-external-loadbalancer.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ data:
588588
apiVersion: apps/v1
589589
kind: Deployment
590590
metadata:
591+
labels:
592+
component: csi
591593
name: vsphere-csi-controller
592594
namespace: vmware-system-csi
593595
spec:
@@ -957,6 +959,8 @@ data:
957959
apiVersion: apps/v1
958960
kind: DaemonSet
959961
metadata:
962+
labels:
963+
component: csi
960964
name: vsphere-csi-node-windows
961965
namespace: vmware-system-csi
962966
spec:

templates/cluster-template-ignition.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ data:
792792
apiVersion: apps/v1
793793
kind: Deployment
794794
metadata:
795+
labels:
796+
component: csi
795797
name: vsphere-csi-controller
796798
namespace: vmware-system-csi
797799
spec:
@@ -1161,6 +1163,8 @@ data:
11611163
apiVersion: apps/v1
11621164
kind: DaemonSet
11631165
metadata:
1166+
labels:
1167+
component: csi
11641168
name: vsphere-csi-node-windows
11651169
namespace: vmware-system-csi
11661170
spec:

templates/cluster-template-node-ipam.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,8 @@ data:
713713
apiVersion: apps/v1
714714
kind: Deployment
715715
metadata:
716+
labels:
717+
component: csi
716718
name: vsphere-csi-controller
717719
namespace: vmware-system-csi
718720
spec:
@@ -1082,6 +1084,8 @@ data:
10821084
apiVersion: apps/v1
10831085
kind: DaemonSet
10841086
metadata:
1087+
labels:
1088+
component: csi
10851089
name: vsphere-csi-node-windows
10861090
namespace: vmware-system-csi
10871091
spec:

templates/cluster-template-topology.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@ data:
487487
apiVersion: apps/v1
488488
kind: Deployment
489489
metadata:
490+
labels:
491+
component: csi
490492
name: vsphere-csi-controller
491493
namespace: vmware-system-csi
492494
spec:
@@ -856,6 +858,8 @@ data:
856858
apiVersion: apps/v1
857859
kind: DaemonSet
858860
metadata:
861+
labels:
862+
component: csi
859863
name: vsphere-csi-node-windows
860864
namespace: vmware-system-csi
861865
spec:

templates/cluster-template.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ data:
703703
apiVersion: apps/v1
704704
kind: Deployment
705705
metadata:
706+
labels:
707+
component: csi
706708
name: vsphere-csi-controller
707709
namespace: vmware-system-csi
708710
spec:
@@ -1072,6 +1074,8 @@ data:
10721074
apiVersion: apps/v1
10731075
kind: DaemonSet
10741076
metadata:
1077+
labels:
1078+
component: csi
10751079
name: vsphere-csi-node-windows
10761080
namespace: vmware-system-csi
10771081
spec:

test/e2e/log_collector.go

+39
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"golang.org/x/crypto/ssh"
3030
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3131
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
32+
"sigs.k8s.io/cluster-api/test/framework"
3233
"sigs.k8s.io/controller-runtime/pkg/client"
3334
kinderrors "sigs.k8s.io/kind/pkg/errors"
3435
)
@@ -154,3 +155,41 @@ func readPrivateKey() ([]byte, error) {
154155

155156
return os.ReadFile(filepath.Clean(privateKeyFilePath))
156157
}
158+
159+
func watchVSphereComponentLogsFunc(ctx context.Context, artifactFolder string) func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace, workloadClusterName string) {
160+
return func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace, workloadClusterName string) {
161+
workloadClusterProxy := managementClusterProxy.GetWorkloadCluster(ctx, workloadClusterNamespace, workloadClusterName)
162+
// CPI
163+
framework.WatchDaemonSetLogsByLabelSelector(ctx, framework.WatchDaemonSetLogsByLabelSelectorInput{
164+
GetLister: workloadClusterProxy.GetClient(),
165+
Cache: workloadClusterProxy.GetCache(ctx),
166+
ClientSet: workloadClusterProxy.GetClientSet(),
167+
Labels: map[string]string{
168+
"component": "cloud-controller-manager",
169+
},
170+
LogPath: filepath.Join(artifactFolder, "clusters", workloadClusterName, "logs"),
171+
})
172+
173+
// CSI Deployment
174+
framework.WatchDeploymentLogsByLabelSelector(ctx, framework.WatchDeploymentLogsByLabelSelectorInput{
175+
GetLister: workloadClusterProxy.GetClient(),
176+
Cache: workloadClusterProxy.GetCache(ctx),
177+
ClientSet: workloadClusterProxy.GetClientSet(),
178+
Labels: map[string]string{
179+
"component": "cloud-controller-manager",
180+
},
181+
LogPath: filepath.Join(artifactFolder, "clusters", workloadClusterName, "logs"),
182+
})
183+
184+
// CSI Daemonset
185+
framework.WatchDaemonSetLogsByLabelSelector(ctx, framework.WatchDaemonSetLogsByLabelSelectorInput{
186+
GetLister: workloadClusterProxy.GetClient(),
187+
Cache: workloadClusterProxy.GetCache(ctx),
188+
ClientSet: workloadClusterProxy.GetClientSet(),
189+
Labels: map[string]string{
190+
"component": "cloud-controller-manager",
191+
},
192+
LogPath: filepath.Join(artifactFolder, "clusters", workloadClusterName, "logs"),
193+
})
194+
}
195+
}

test/e2e/quick_start_test.go

+14-12
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,27 @@ var _ = Describe("Cluster Creation using Cluster API quick-start test", func() {
3737
var _ = Describe("ClusterClass Creation using Cluster API quick-start test [PR-Blocking] [ClusterClass]", func() {
3838
capi_e2e.QuickStartSpec(ctx, func() capi_e2e.QuickStartSpecInput {
3939
return capi_e2e.QuickStartSpecInput{
40-
E2EConfig: e2eConfig,
41-
ClusterctlConfigPath: clusterctlConfigPath,
42-
BootstrapClusterProxy: bootstrapClusterProxy,
43-
ArtifactFolder: artifactFolder,
44-
SkipCleanup: skipCleanup,
45-
Flavor: ptr.To("topology"),
40+
E2EConfig: e2eConfig,
41+
ClusterctlConfigPath: clusterctlConfigPath,
42+
BootstrapClusterProxy: bootstrapClusterProxy,
43+
ArtifactFolder: artifactFolder,
44+
SkipCleanup: skipCleanup,
45+
Flavor: ptr.To("topology"),
46+
PostMachinesProvisioned: watchVSphereComponentLogsFunc(ctx, artifactFolder),
4647
}
4748
})
4849
})
4950

5051
var _ = Describe("Cluster creation with [Ignition] bootstrap [PR-Blocking]", func() {
5152
capi_e2e.QuickStartSpec(ctx, func() capi_e2e.QuickStartSpecInput {
5253
return capi_e2e.QuickStartSpecInput{
53-
E2EConfig: e2eConfig,
54-
ClusterctlConfigPath: clusterctlConfigPath,
55-
BootstrapClusterProxy: bootstrapClusterProxy,
56-
ArtifactFolder: artifactFolder,
57-
SkipCleanup: skipCleanup,
58-
Flavor: ptr.To("ignition"),
54+
E2EConfig: e2eConfig,
55+
ClusterctlConfigPath: clusterctlConfigPath,
56+
BootstrapClusterProxy: bootstrapClusterProxy,
57+
ArtifactFolder: artifactFolder,
58+
SkipCleanup: skipCleanup,
59+
Flavor: ptr.To("ignition"),
60+
PostMachinesProvisioned: watchVSphereComponentLogsFunc(ctx, artifactFolder),
5961
}
6062
})
6163
})

test/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.20
44

55
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.6.0
66

7-
replace sigs.k8s.io/cluster-api/test => sigs.k8s.io/cluster-api/test v1.6.1-0.20240108181656-eb46d086f417
7+
replace sigs.k8s.io/cluster-api/test => sigs.k8s.io/cluster-api/test v1.6.1-0.20240112150242-70716332b487
88

99
replace sigs.k8s.io/cluster-api-provider-vsphere => ../
1010

test/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,8 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
11151115
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
11161116
sigs.k8s.io/cluster-api v1.6.0 h1:2bhVSnUbtWI8taCjd9lGiHExsRUpKf7Z1fXqi/IwYx4=
11171117
sigs.k8s.io/cluster-api v1.6.0/go.mod h1:LB7u/WxiWj4/bbpHNOa1oQ8nq0MQ5iYlD0pGfRSBGLI=
1118-
sigs.k8s.io/cluster-api/test v1.6.1-0.20240108181656-eb46d086f417 h1:aI5QL5q0eT20HyA36LQfpkTVu7jdM9ssmNzBnA+gRpo=
1119-
sigs.k8s.io/cluster-api/test v1.6.1-0.20240108181656-eb46d086f417/go.mod h1:hsaaOsAftllhnRZ6l6izUvgGswlqO8Gm4EQS96+mnC0=
1118+
sigs.k8s.io/cluster-api/test v1.6.1-0.20240112150242-70716332b487 h1:72l+q8XVnAtW74R0slvFDljpjjtK+PJwZYSPphTlNRg=
1119+
sigs.k8s.io/cluster-api/test v1.6.1-0.20240112150242-70716332b487/go.mod h1:hsaaOsAftllhnRZ6l6izUvgGswlqO8Gm4EQS96+mnC0=
11201120
sigs.k8s.io/controller-runtime v0.9.0/go.mod h1:TgkfvrhhEw3PlI0BRL/5xM+89y3/yc0ZDfdbTl84si8=
11211121
sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4=
11221122
sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0=

0 commit comments

Comments
 (0)