Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add steps for debugging in the README #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 61 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ in the files (`<your company>-<lab>-config`).

Add the credentials for your remoteci in `~/.config/dci-pipeline/dci_credentials.yml`.

Then create the required directories and files for DCI to work:
Then, create the required directories and files for DCI to work:

```ShellSession
$ cd
$ cd ~
$ git clone [email protected]:dci-labs/<your company>-<lab>-config.git
$ mkdir -p dci-cache-dir upload-errors .config/dci-pipeline
$ cat > .config/dci-pipeline/config <<EOF
Expand Down Expand Up @@ -59,6 +59,13 @@ $ KUBECONFIG=$KUBECONFIG dci-pipeline-schedule workload

## Testing a PR

First, setup Github credentials in `~/.config/dci-pipeline/config`:

```
GITHUB_TOKEN=<your_github_token>
GITHUB_LOGIN=<your_github_user>
```

For testing a PR with the full pipeline:

```ShellSession
Expand All @@ -70,3 +77,55 @@ Or only with the workload:
```ShellSession
$ dci-pipeline-check https://github.com/dci-labs/<your company>-<lab>-config/pull/1 $KUBECONFIG workload
```

## How to debug and fix issues

1. Locate the logs of the job in `~/.dci-queue/log/pool/`. Typically, you'll need the latest created file:

```ShellSession
cat "$(ls -1t ~/.dci-queue/log/pool/ | head -n 1)"
```

Check the ansible-playbook invocation, verify and fix possible permission errors, and make a note of the job URL.

2. If encountering an unusual situation with dci-queue, consider removing and recreating the pool from scratch:

```ShellSession
$ dci-queue remove-pool pool
$ dci-queue add-pool pool
$ dci-queue add-resource pool cluster1
```

3. If making dci-queue work immediately is challenging, consider running a job first with dci-pipeline.

To do this, modify the pipeline files to replace dynamic paths. The following command will change `@QUEUE` to `pool` and `@RESOURCE` to `cluster1`:

```ShellSession
$ export CONFIG_REPO_PATH="$HOME/<your company>-<lab>-config"
$ cd $CONFIG_REPO_PATH
$ find pipelines -type f -exec sed -i 's/@QUEUE/pool/g; s/@RESOURCE/cluster1/g' {} +
```

Start a DCI job with dci-pipeline:

```ShellSession
dci-pipeline \
workload:ansible_extravars=kubeconfig_path:$KUBECONFIG \
workload:ansible_inventory=$CONFIG_REPO_PATH/inventories/pool/cluster1 \
workload:ansible_cfg=$CONFIG_REPO_PATH/pipelines/ansible.cfg \
$CONFIG_REPO_PATH/pipelines/workload-pipeline.yml
```

Debug by checking the logs in `~/.dci-queue/log/pool/`. Once the `dci-pipeline` invocation is working, revert to using dynamic paths by replacing `pool` with `@QUEUE` and `cluster1` with `@RESOURCE`:

```ShellSession
$ export CONFIG_REPO_PATH="$HOME/<your company>-<lab>-config"
$ cd $CONFIG_REPO_PATH
$ find pipelines -type f -exec sed -i 's/pool/@QUEUE/g; s/cluster1/@RESOURCE/g' {} +
```

and return to using `dci-pipeline-schedule`:

```ShellSession
$ KUBECONFIG=$KUBECONFIG dci-pipeline-schedule workload
```