Skip to content

Commit 7ee4106

Browse files
author
Staging script
committed
Staging PR 3023
1 parent eea4f40 commit 7ee4106

File tree

4 files changed

+69
-12
lines changed

4 files changed

+69
-12
lines changed

doc/toml_settings.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,41 @@ Then the `kci_build install_kernel` command normally requires `--kdir`,
165165
so they don't need to be provided on the command line: `db_config` is in the
166166
`[DEFAULT]` section, `db_token` in the `[db:localhost]` section and `kdir` in
167167
the `[kci_build]` section.
168+
169+
## Environment Variables
170+
171+
In addition to the TOML settings file, KernelCI tools support several
172+
environment variables for runtime configuration:
173+
174+
| Variable | Description |
175+
|----------|-------------|
176+
| `KCI_API_TOKEN` | API authentication token |
177+
| `KCI_SETTINGS` | Path to the TOML settings file |
178+
| `KCI_INSTANCE` | Instance type (`prod`, `staging`) |
179+
| `KCI_INSTANCE_CALLBACK` | LAVA callback URL |
180+
| `KCI_STORAGE_CREDENTIALS` | Storage backend credentials |
181+
| `KCI_DEBUG` | Enable verbose debug logging |
182+
183+
### `KCI_DEBUG`
184+
185+
When `KCI_DEBUG` is set to `1`, `true`, or `yes`, KernelCI will output
186+
additional debug messages that are normally suppressed to reduce log noise.
187+
This includes verbose messages about job and platform filtering decisions
188+
during scheduling.
189+
190+
Example usage:
191+
```bash
192+
export KCI_DEBUG=1
193+
# or
194+
KCI_DEBUG=true ./run-scheduler.sh
195+
```
196+
197+
The `kci` CLI tool also provides a `--debug` / `-d` flag for commands that
198+
support it, which automatically sets `KCI_DEBUG=1`:
199+
200+
```bash
201+
kci config forecast --debug -c /path/to/config
202+
```
203+
204+
This is particularly useful for debugging why certain jobs or platforms are
205+
being filtered out during scheduling.

kernelci/api/helper.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,23 @@
99

1010
from typing import Dict
1111
import json
12+
import os
1213
import requests
1314

1415
from . import API
1516

1617

18+
def _is_debug_enabled():
19+
"""Check if KCI_DEBUG environment variable is set to enable verbose logging."""
20+
return os.environ.get('KCI_DEBUG', '').lower() in ('1', 'true', 'yes')
21+
22+
23+
def _debug_print(message):
24+
"""Print message only if KCI_DEBUG is enabled."""
25+
if _is_debug_enabled():
26+
print(message)
27+
28+
1729
def merge(primary: dict, secondary: dict):
1830
"""Deep merges dicts a and b, returning a new dict containing
1931
dictionary a updated with the contents of dictionary b.
@@ -480,13 +492,13 @@ def create_job_node(self, job_config, input_node,
480492
job_node['platform_filter'] = platform_filter
481493

482494
if self._is_job_filtered(job_node):
483-
print(f"Not creating node due to job filter. Job {job_config.name} "
484-
f"not found in jobfilter for node {input_node['id']}")
495+
_debug_print(f"Not creating node due to job filter. Job {job_config.name} "
496+
f"not found in jobfilter for node {input_node['id']}")
485497
return None
486498

487499
if not self.should_create_node(job_config.rules, job_node):
488-
print(f"Not creating node due to job rules for {job_config.name} "
489-
f"evaluating node {input_node['id']}")
500+
_debug_print(f"Not creating node due to job rules for {job_config.name} "
501+
f"evaluating node {input_node['id']}")
490502
return None
491503
# Test-specific fields inherited from parent node (kbuild or
492504
# job) if available
@@ -503,21 +515,21 @@ def create_job_node(self, job_config, input_node,
503515
if runtime:
504516
job_node['data']['runtime'] = runtime.config.name
505517
if not self.should_create_node(runtime.config.rules, job_node):
506-
print(f"Not creating node {input_node['id']} due to runtime rules "
507-
f"for {runtime.config.name}")
518+
_debug_print(f"Not creating node {input_node['id']} due to runtime rules "
519+
f"for {runtime.config.name}")
508520
return None
509521
# Filter by platform if it is test job only
510522
if platform:
511523
# if platform_filter not null, verify if platform.name exist in platform_filter
512524
if platform_filter and platform.name not in platform_filter\
513525
and job_config.kind == 'job':
514-
print(f"Filtered: Platform {platform.name} not found in platform_filter "
515-
f"for node {input_node['id']}")
526+
_debug_print(f"Filtered: Platform {platform.name} not found in platform_filter "
527+
f"for node {input_node['id']}")
516528
return None
517529
job_node['data']['platform'] = platform.name
518530
if not self.should_create_node(platform.rules, job_node):
519-
print(f"Not creating node {input_node['id']} due to platform rules "
520-
f"for {platform.name}")
531+
_debug_print(f"Not creating node {input_node['id']} due to platform rules "
532+
f"for {platform.name}")
521533
return None
522534
# Process potential f-strings in node's data with platform attributes
523535
# krev is used for ChromeOS config version mapping

kernelci/cli/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ class Args: # pylint: disable=too-few-public-methods
6767
'-v', '--verbose/--no-verbose', default=None,
6868
help="Print more details output"
6969
)
70+
debug = click.option(
71+
'-d', '--debug', is_flag=True, default=False,
72+
help="Enable debug output (sets KCI_DEBUG=1)"
73+
)
7074

7175

7276
def catch_error(func):

kernelci/cli/config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,11 @@ def do_forecast(merged_data):
243243

244244
@kci_config.command
245245
@Args.config
246-
def forecast(config):
247-
"""Dump entries from the SECTION of the pipeline YAML configuration"""
246+
@Args.debug
247+
def forecast(config, debug):
248+
"""Forecast builds and tests for each tree/branch combination"""
249+
if debug:
250+
os.environ['KCI_DEBUG'] = '1'
248251
config_paths = kernelci.config.get_config_paths(config)
249252
if not config_paths:
250253
return

0 commit comments

Comments
 (0)