istio.io/istio@v0.0.0-20240520182934-d79c90f27776/tests/integration/operator/operator_dumper.go (about) 1 //go:build integ 2 // +build integ 3 4 /* 5 Copyright Istio Authors 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 */ 19 20 package operator 21 22 import ( 23 "istio.io/istio/pkg/test/framework/resource" 24 "istio.io/istio/pkg/test/kube" 25 "istio.io/istio/pkg/test/scopes" 26 ) 27 28 // operatorDumper dumps the logs of in-cluster operator at suite completion 29 type operatorDumper struct { 30 ns string 31 rev string 32 } 33 34 func (d *operatorDumper) Dump(ctx resource.Context) { 35 scopes.Framework.Errorf("=== Dumping Istio Deployment State for %v...", ctx.ID()) 36 ns := d.ns 37 if len(ns) < 1 { 38 ns = "istio-operator" 39 } 40 41 dir, err := ctx.CreateTmpDirectory("istio-operator-" + d.ID().String()) 42 if err != nil { 43 scopes.Framework.Errorf("Unable to create directory for dumping operator contents: %v", err) 44 return 45 } 46 kube.DumpPods(ctx, dir, ns, []string{"name=istio-operator"}) 47 } 48 49 func (d *operatorDumper) ID() resource.ID { 50 return &operatorID{d.rev} 51 } 52 53 type operatorID struct { 54 content string 55 } 56 57 func (o *operatorID) String() string { 58 return o.content 59 }