Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae85e0b

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#50384 from shyamjvs/optional-logdump-for-1.4
Automatic merge from submit-queue Add ability to disable dumping logs and move log-dump.sh script to new path Cherry-pick of PR kubernetes#41886 to fix broken tests on 1.4 branch. /cc @jessfraz
2 parents 745f686 + 0193697 commit ae85e0b

File tree

8 files changed

+19
-12
lines changed

8 files changed

+19
-12
lines changed

cluster/aws/util.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function query-running-minions () {
252252

253253
function detect-node-names () {
254254
# If this is called directly, VPC_ID might not be set
255-
# (this is case from cluster/log-dump.sh)
255+
# (this is case from cluster/log-dump/log-dump.sh)
256256
if [[ -z "${VPC_ID:-}" ]]; then
257257
VPC_ID=$(get_vpc_id)
258258
fi

cluster/log-dump.sh renamed to cluster/log-dump/log-dump.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set -o errexit
2121
set -o nounset
2222
set -o pipefail
2323

24-
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
24+
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
2525
: ${KUBE_CONFIG_FILE:="config-test.sh"}
2626

2727
source "${KUBE_ROOT}/cluster/kube-util.sh"

docs/devel/e2e-tests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,14 @@ $ go run hack/e2e.go -v --down
332332
### Debugging clusters
333333

334334
If a cluster fails to initialize, or you'd like to better understand cluster
335-
state to debug a failed e2e test, you can use the `cluster/log-dump.sh` script
335+
state to debug a failed e2e test, you can use the `cluster/log-dump/log-dump.sh` script
336336
to gather logs.
337337

338338
This script requires that the cluster provider supports ssh. Assuming it does,
339339
running:
340340

341341
```
342-
cluster/log-dump.sh <directory>
342+
cluster/log-dump/log-dump.sh <directory>
343343
````
344344
345345
will ssh to the master and all nodes and download a variety of useful logs to

hack/e2e.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func DumpClusterLogs(location string) {
303303
return
304304
}
305305
log.Printf("Dumping cluster logs to: %v", location)
306-
finishRunning("dump cluster logs", exec.Command("./cluster/log-dump.sh", location))
306+
finishRunning("dump cluster logs", exec.Command("./cluster/log-dump/log-dump.sh", location))
307307
}
308308

309309
func KubemarkTest() bool {

hack/verify-flags/exceptions.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ cluster/juju/layers/kubernetes/reactive/k8s.py: cluster_name = 'kubernetes'
2929
cluster/juju/layers/kubernetes/reactive/k8s.py: tlslib.client_key(None, client_key, user='ubuntu', group='ubuntu')
3030
cluster/lib/logging.sh: local source_file=${BASH_SOURCE[$frame_no]}
3131
cluster/lib/logging.sh: local source_file=${BASH_SOURCE[$stack_skip]}
32-
cluster/log-dump.sh: for node_name in "${NODE_NAMES[@]}"; do
33-
cluster/log-dump.sh: local -r node_name="${1}"
34-
cluster/log-dump.sh:readonly report_dir="${1:-_artifacts}"
32+
cluster/log-dump/log-dump.sh: for node_name in "${NODE_NAMES[@]}"; do
33+
cluster/log-dump/log-dump.sh: local -r node_name="${1}"
34+
cluster/log-dump/log-dump.sh:readonly report_dir="${1:-_artifacts}"
3535
cluster/mesos/docker/km/build.sh: km_path=$(find-binary km darwin/amd64)
3636
cluster/photon-controller/templates/salt-master.sh: api_servers: $MASTER_NAME
3737
cluster/photon-controller/templates/salt-minion.sh: hostname_override: $(ip route get 1.1.1.1 | awk '{print $7}')
@@ -69,7 +69,6 @@ cluster/vagrant/provision-utils.sh: node_ip: '$(echo "$MASTER_IP" | sed -e "s/'
6969
cluster/vagrant/provision-utils.sh: runtime_config: '$(echo "$RUNTIME_CONFIG" | sed -e "s/'/''/g")'
7070
cluster/vsphere/templates/salt-master.sh: cloud_config: $CLOUD_CONFIG
7171
cluster/vsphere/templates/salt-minion.sh: cloud_config: $CLOUD_CONFIG
72-
cluster/vsphere/templates/salt-minion.sh: hostname_override: $(ip route get 1.1.1.1 | awk '{print $7}')
7372
examples/cluster-dns/images/frontend/client.py: service_address = socket.gethostbyname(hostname)
7473
examples/storage/cassandra/image/run.sh: cluster_name \
7574
examples/storage/vitess/env.sh: node_ip=$(get_node_ip)

hack/verify-flags/known-flags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ deserialization-cache-size
122122
dest-file
123123
disable-filter
124124
disable-kubenet
125+
disable-log-dump
125126
dns-port
126127
dns-provider
127128
dns-provider-config

test/e2e/framework/test_context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ type TestContextType struct {
6969
CreateTestingNS CreateTestingNSFn
7070
// If set to true test will dump data about the namespace in which test was running.
7171
DumpLogsOnFailure bool
72+
// Disables dumping cluster log from master and nodes after all tests.
73+
DisableLogDump bool
7274
// If the garbage collector is enabled in the kube-apiserver and kube-controller-manager.
7375
GarbageCollectorEnabled bool
7476
// Node e2e specific test context
@@ -123,6 +125,7 @@ func RegisterCommonFlags() {
123125
flag.BoolVar(&TestContext.GatherMetricsAfterTest, "gather-metrics-at-teardown", false, "If set to true framwork will gather metrics from all components after each test.")
124126
flag.StringVar(&TestContext.OutputPrintType, "output-print-type", "hr", "Comma separated list: 'hr' for human readable summaries 'json' for JSON ones.")
125127
flag.BoolVar(&TestContext.DumpLogsOnFailure, "dump-logs-on-failure", true, "If set to true test will dump data about the namespace in which test was running.")
128+
flag.BoolVar(&TestContext.DisableLogDump, "disable-log-dump", false, "If set to true, logs from master and nodes won't be gathered after test run.")
126129
flag.BoolVar(&TestContext.DeleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
127130
flag.IntVar(&TestContext.AllowedNotReadyNodes, "allowed-not-ready-nodes", 0, "If non-zero, framework will allow for that many non-ready nodes when checking for all ready nodes.")
128131
flag.StringVar(&TestContext.Host, "host", "http://127.0.0.1:8080", "The host, or apiserver, to connect to")

test/e2e/framework/util.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5078,13 +5078,17 @@ func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, timeo
50785078
}
50795079

50805080
// CoreDump SSHs to the master and all nodes and dumps their logs into dir.
5081-
// It shells out to cluster/log-dump.sh to accomplish this.
5081+
// It shells out to cluster/log-dump/log-dump.sh to accomplish this.
50825082
func CoreDump(dir string) {
5083-
cmd := exec.Command(path.Join(TestContext.RepoRoot, "cluster", "log-dump.sh"), dir)
5083+
if TestContext.DisableLogDump {
5084+
Logf("Skipping dumping logs from cluster")
5085+
return
5086+
}
5087+
cmd := exec.Command(path.Join(TestContext.RepoRoot, "cluster", "log-dump", "log-dump.sh"), dir)
50845088
cmd.Stdout = os.Stdout
50855089
cmd.Stderr = os.Stderr
50865090
if err := cmd.Run(); err != nil {
5087-
Logf("Error running cluster/log-dump.sh: %v", err)
5091+
Logf("Error running cluster/log-dump/log-dump.sh: %v", err)
50885092
}
50895093
}
50905094

0 commit comments

Comments
 (0)