mirror of https://github.com/k3s-io/k3s
Merge pull request #49058 from shyamjvs/logexporter-support
Automatic merge from submit-queue Pass logexporter config through e2e framework Ref https://github.com/kubernetes/kubernetes/issues/48513 /cc @wojtek-t @fejtapull/6/head
commit
6af05149aa
|
@ -22,6 +22,7 @@ set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
readonly report_dir="${1:-_artifacts}"
|
readonly report_dir="${1:-_artifacts}"
|
||||||
|
readonly gcs_artifacts_dir="${2:-}"
|
||||||
|
|
||||||
# In order to more trivially extend log-dump for custom deployments,
|
# In order to more trivially extend log-dump for custom deployments,
|
||||||
# check for a function named log_dump_custom_get_instances. If it's
|
# check for a function named log_dump_custom_get_instances. If it's
|
||||||
|
@ -271,7 +272,6 @@ function dump_nodes_with_logexporter() {
|
||||||
# Obtain parameters required by logexporter.
|
# Obtain parameters required by logexporter.
|
||||||
local -r service_account_credentials="$(cat ${GOOGLE_APPLICATION_CREDENTIALS} | base64)"
|
local -r service_account_credentials="$(cat ${GOOGLE_APPLICATION_CREDENTIALS} | base64)"
|
||||||
local -r cloud_provider="${KUBERNETES_PROVIDER}"
|
local -r cloud_provider="${KUBERNETES_PROVIDER}"
|
||||||
local -r gcs_artifacts_dir="${GCS_ARTIFACTS_DIR}"
|
|
||||||
local -r enable_hollow_node_logs="${ENABLE_HOLLOW_NODE_LOGS:-false}"
|
local -r enable_hollow_node_logs="${ENABLE_HOLLOW_NODE_LOGS:-false}"
|
||||||
local -r logexport_timeout_seconds="$(( 30 + NUM_NODES / 10 ))"
|
local -r logexport_timeout_seconds="$(( 30 + NUM_NODES / 10 ))"
|
||||||
|
|
||||||
|
@ -347,12 +347,8 @@ function main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy logs from nodes to GCS directly or to artifacts dir locally (through SSH).
|
# Copy logs from nodes to GCS directly or to artifacts dir locally (through SSH).
|
||||||
if [[ "${ENABLE_LOGEXPORTER:-}" == "true" ]]; then
|
if [[ -n "${gcs_artifacts_dir}" ]]; then
|
||||||
if [[ -z "${GCS_ARTIFACTS_DIR:-}" ]]; then
|
echo "Dumping logs from nodes to GCS directly at '${gcs_artifacts_dir}' using logexporter"
|
||||||
echo "Env var GCS_ARTIFACTS_DIR is empty. Failed to dump node logs to GCS."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Dumping logs from nodes to GCS directly at '${GCS_ARTIFACTS_DIR}'"
|
|
||||||
dump_nodes_with_logexporter
|
dump_nodes_with_logexporter
|
||||||
else
|
else
|
||||||
echo "Dumping logs from nodes locally to '${report_dir}'"
|
echo "Dumping logs from nodes locally to '${report_dir}'"
|
||||||
|
|
|
@ -448,6 +448,7 @@ load-balancer-ip
|
||||||
lock-file
|
lock-file
|
||||||
log-flush-frequency
|
log-flush-frequency
|
||||||
log-lines-total
|
log-lines-total
|
||||||
|
logexporter-gcs-path
|
||||||
long-running-request-regexp
|
long-running-request-regexp
|
||||||
low-diskspace-threshold-mb
|
low-diskspace-threshold-mb
|
||||||
make-iptables-util-chains
|
make-iptables-util-chains
|
||||||
|
|
|
@ -87,6 +87,8 @@ type TestContextType struct {
|
||||||
DumpLogsOnFailure bool
|
DumpLogsOnFailure bool
|
||||||
// Disables dumping cluster log from master and nodes after all tests.
|
// Disables dumping cluster log from master and nodes after all tests.
|
||||||
DisableLogDump bool
|
DisableLogDump bool
|
||||||
|
// Path to the GCS artifacts directory to dump logs from nodes. Logexporter gets enabled if this is non-empty.
|
||||||
|
LogexporterGCSPath string
|
||||||
// If the garbage collector is enabled in the kube-apiserver and kube-controller-manager.
|
// If the garbage collector is enabled in the kube-apiserver and kube-controller-manager.
|
||||||
GarbageCollectorEnabled bool
|
GarbageCollectorEnabled bool
|
||||||
// FeatureGates is a set of key=value pairs that describe feature gates for alpha/experimental features.
|
// FeatureGates is a set of key=value pairs that describe feature gates for alpha/experimental features.
|
||||||
|
@ -174,6 +176,7 @@ func RegisterCommonFlags() {
|
||||||
flag.StringVar(&TestContext.OutputPrintType, "output-print-type", "json", "Format in which summaries should be printed: 'hr' for human readable, 'json' for JSON ones.")
|
flag.StringVar(&TestContext.OutputPrintType, "output-print-type", "json", "Format in which summaries should be printed: 'hr' for human readable, 'json' for JSON ones.")
|
||||||
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.")
|
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.")
|
||||||
flag.BoolVar(&TestContext.DisableLogDump, "disable-log-dump", false, "If set to true, logs from master and nodes won't be gathered after test run.")
|
flag.BoolVar(&TestContext.DisableLogDump, "disable-log-dump", false, "If set to true, logs from master and nodes won't be gathered after test run.")
|
||||||
|
flag.StringVar(&TestContext.LogexporterGCSPath, "logexporter-gcs-path", "", "Path to the GCS artifacts directory to dump logs from nodes. Logexporter gets enabled if this is non-empty.")
|
||||||
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.")
|
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.")
|
||||||
flag.BoolVar(&TestContext.DeleteNamespaceOnFailure, "delete-namespace-on-failure", true, "If true, framework will delete test namespace on failure. Used only during test debugging.")
|
flag.BoolVar(&TestContext.DeleteNamespaceOnFailure, "delete-namespace-on-failure", true, "If true, framework will delete test namespace on failure. Used only during test debugging.")
|
||||||
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.")
|
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.")
|
||||||
|
|
|
@ -4303,7 +4303,14 @@ func CoreDump(dir string) {
|
||||||
Logf("Skipping dumping logs from cluster")
|
Logf("Skipping dumping logs from cluster")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cmd := exec.Command(path.Join(TestContext.RepoRoot, "cluster", "log-dump", "log-dump.sh"), dir)
|
var cmd *exec.Cmd
|
||||||
|
if TestContext.LogexporterGCSPath != "" {
|
||||||
|
Logf("Dumping logs from nodes to GCS directly at path: %s", TestContext.LogexporterGCSPath)
|
||||||
|
cmd = exec.Command(path.Join(TestContext.RepoRoot, "cluster", "log-dump", "log-dump.sh"), dir, TestContext.LogexporterGCSPath)
|
||||||
|
} else {
|
||||||
|
Logf("Dumping logs locally to: %s", dir)
|
||||||
|
cmd = exec.Command(path.Join(TestContext.RepoRoot, "cluster", "log-dump", "log-dump.sh"), dir)
|
||||||
|
}
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue