5757 // - 1.24-alpha.feabc1234
5858 // matching only the version before first '_' which is used in the downstream builds, e.g. "1.23.2_ossm_tp.2"
5959 istiodVersionRegex = regexp .MustCompile (`Version:"([^"_]*)[^"]*"` )
60-
61- k = kubectl .New ()
6260)
6361
6462// GetObject returns the object with the given key
@@ -131,73 +129,80 @@ func CheckNamespaceEmpty(ctx SpecContext, cl client.Client, ns string) {
131129 }).Should (BeEmpty (), "No Services should be present in the namespace" )
132130}
133131
134- func LogDebugInfo () {
132+ func LogDebugInfo (k kubectl. Kubectl ) {
135133 // General debugging information to help diagnose the failure
136134 // TODO: Add the creation of file with this information to be attached to the test report
137135
138136 GinkgoWriter .Println ()
139- GinkgoWriter .Println ("The test run has failures and the debug information is as follows:" )
137+ GinkgoWriter .Println ("The test run has failures and the debug information is as follows from cluster: %q:" , k .GetClusterName ())
138+ GinkgoWriter .Println ("=========================================================" )
139+ logOperatorDebugInfo (k )
140140 GinkgoWriter .Println ("=========================================================" )
141- logOperatorDebugInfo ( )
141+ logIstioDebugInfo ( k )
142142 GinkgoWriter .Println ("=========================================================" )
143- logIstioDebugInfo ( )
143+ logCNIDebugInfo ( k )
144144 GinkgoWriter .Println ("=========================================================" )
145- logCNIDebugInfo ( )
145+ logCertsDebugInfo ( k )
146146 GinkgoWriter .Println ("=========================================================" )
147147}
148148
149- func logOperatorDebugInfo () {
150- k : = k .WithNamespace (OperatorNamespace )
149+ func logOperatorDebugInfo (k kubectl. Kubectl ) {
150+ k = k .WithNamespace (OperatorNamespace )
151151 operator , err := k .GetYAML ("deployment" , deploymentName )
152- logDebugElement ("Operator Deployment YAML" , operator , err )
152+ logDebugElement ("===== Operator Deployment YAML===== " , operator , err )
153153
154154 logs , err := k .Logs ("deploy/" + deploymentName , ptr .Of (120 * time .Second ))
155- logDebugElement ("Operator logs" , logs , err )
155+ logDebugElement ("===== Operator logs===== " , logs , err )
156156
157157 events , err := k .GetEvents ()
158- logDebugElement ("Events in " + OperatorNamespace , events , err )
158+ logDebugElement ("===== Events in " + OperatorNamespace + "=====" , events , err )
159159
160160 // Temporary information to gather more details about failure
161161 pods , err := k .GetPods ("" , "-o wide" )
162- logDebugElement ("Pods in " + OperatorNamespace , pods , err )
162+ logDebugElement ("===== Pods in " + OperatorNamespace + "=====" , pods , err )
163163
164164 describe , err := k .Describe ("deployment" , deploymentName )
165- logDebugElement ("Operator Deployment describe" , describe , err )
165+ logDebugElement ("===== Operator Deployment describe===== " , describe , err )
166166}
167167
168- func logIstioDebugInfo () {
168+ func logIstioDebugInfo (k kubectl. Kubectl ) {
169169 resource , err := k .GetYAML ("istio" , istioName )
170- logDebugElement ("Istio YAML" , resource , err )
170+ logDebugElement ("===== Istio YAML===== " , resource , err )
171171
172172 output , err := k .WithNamespace (controlPlaneNamespace ).GetPods ("" , "-o wide" )
173- logDebugElement ("Pods in " + controlPlaneNamespace , output , err )
173+ logDebugElement ("===== Pods in " + controlPlaneNamespace + "=====" , output , err )
174174
175175 logs , err := k .WithNamespace (controlPlaneNamespace ).Logs ("deploy/istiod" , ptr .Of (120 * time .Second ))
176- logDebugElement ("Istiod logs" , logs , err )
176+ logDebugElement ("===== Istiod logs===== " , logs , err )
177177
178178 events , err := k .WithNamespace (controlPlaneNamespace ).GetEvents ()
179- logDebugElement ("Events in " + controlPlaneNamespace , events , err )
179+ logDebugElement ("===== Events in " + controlPlaneNamespace + "=====" , events , err )
180180}
181181
182- func logCNIDebugInfo () {
182+ func logCNIDebugInfo (k kubectl. Kubectl ) {
183183 resource , err := k .GetYAML ("istiocni" , istioCniName )
184- logDebugElement ("IstioCNI YAML" , resource , err )
184+ logDebugElement ("===== IstioCNI YAML===== " , resource , err )
185185
186186 ds , err := k .WithNamespace (istioCniNamespace ).GetYAML ("daemonset" , "istio-cni-node" )
187- logDebugElement ("Istio CNI DaemonSet YAML" , ds , err )
187+ logDebugElement ("===== Istio CNI DaemonSet YAML===== " , ds , err )
188188
189189 events , err := k .WithNamespace (istioCniNamespace ).GetEvents ()
190- logDebugElement ("Events in " + istioCniNamespace , events , err )
190+ logDebugElement ("===== Events in " + istioCniNamespace + "=====" , events , err )
191191
192192 // Temporary information to gather more details about failure
193193 pods , err := k .WithNamespace (istioCniNamespace ).GetPods ("" , "-o wide" )
194- logDebugElement ("Pods in " + istioCniNamespace , pods , err )
194+ logDebugElement ("===== Pods in " + istioCniNamespace + "=====" , pods , err )
195195
196196 describe , err := k .WithNamespace (istioCniNamespace ).Describe ("daemonset" , "istio-cni-node" )
197- logDebugElement ("Istio CNI DaemonSet describe" , describe , err )
197+ logDebugElement ("===== Istio CNI DaemonSet describe===== " , describe , err )
198198
199199 logs , err := k .WithNamespace (istioCniNamespace ).Logs ("daemonset/istio-cni-node" , ptr .Of (120 * time .Second ))
200- logDebugElement ("Istio CNI logs" , logs , err )
200+ logDebugElement ("=====Istio CNI logs=====" , logs , err )
201+ }
202+
203+ func logCertsDebugInfo (k kubectl.Kubectl ) {
204+ certs , err := k .WithNamespace (controlPlaneNamespace ).GetSecret ("cacerts" )
205+ logDebugElement ("=====CA certs=====" , certs , err )
201206}
202207
203208func logDebugElement (caption string , info string , err error ) {
@@ -211,7 +216,7 @@ func logDebugElement(caption string, info string, err error) {
211216}
212217
213218func GetVersionFromIstiod () (* semver.Version , error ) {
214- k := kubectl .New ()
219+ k := kubectl .New ("testCluster" )
215220 output , err := k .WithNamespace (controlPlaneNamespace ).Exec ("deploy/istiod" , "" , "pilot-discovery version" )
216221 if err != nil {
217222 return nil , fmt .Errorf ("error getting version from istiod: %w" , err )
0 commit comments