Skip to content

Commit 307ab85

Browse files
authored
docs: add a troubleshooting section and a table of contents (#175)
The README documents every option well, but says nothing about what to do when a run fails. The failures that cost the most time are the ones where the driver's message is accurate and still unhelpful without knowing GCE: "Image family ubuntu-2204-lts is not valid" almost always means a missing image_project rather than a wrong family name, and a create that hangs at "Waiting for server to be ready" has three quite different causes. Covers the validation errors the driver raises by name, the two that come back from GCE instead (quota and disk type), the hang, the two Windows failures, and how to find instances and disks left behind by a Ctrl-C - which the driver's own cleanup cannot handle, because Interrupt is not a StandardError. Also adds a table of contents. The page is long enough now that the Configuration tables are hard to find from the top. Signed-off-by: Tim Smith <tim@mondoo.com>
1 parent fc27a0b commit 307ab85

1 file changed

Lines changed: 139 additions & 0 deletions

File tree

README.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ Compared to other IaaS providers, GCE offers fast instance launch times and sub-
99

1010
> This documentation uses [Cinc Workstation](https://cinc.sh/) and the `cinc` commands throughout. Everything here works identically with Chef Workstation — see [Using with Chef](#using-with-chef).
1111
12+
## Contents
13+
14+
- [Requirements](#requirements)
15+
- [Installation](#installation)
16+
- [Authentication](#authentication)
17+
- [Quick Start](#quick-start)
18+
- [Configuration](#configuration)
19+
- [Examples](#examples)
20+
- [Troubleshooting](#troubleshooting)
21+
- [Using with Chef](#using-with-chef)
22+
- [Contributing](#contributing)
23+
- [License](#license)
24+
1225
## Requirements
1326

1427
- Ruby 3.1 or later (already satisfied if you use Cinc Workstation)
@@ -433,6 +446,132 @@ driver:
433446
count: 1
434447
```
435448

449+
## Troubleshooting
450+
451+
Almost every failure below is reported by the driver before it creates
452+
anything, so nothing is billing while you work out what is wrong.
453+
454+
**`Project my-project is not a valid project`.** Usually credentials rather
455+
than the project name: the driver cannot see a project it is not authorised
456+
for, and reports that the same way as one that does not exist. Check with
457+
`gcloud auth application-default print-access-token`, then confirm the Compute
458+
Engine API is enabled on the project:
459+
460+
```sh
461+
gcloud services enable compute.googleapis.com --project my-gcp-project
462+
```
463+
464+
**`Either zone or region must be specified`.** Neither has a default. Set
465+
`zone` for a specific zone, or `region` to let the driver pick a zone that is
466+
up. `region: any` was removed.
467+
468+
**`Either image family or name must be specified`.** Same again — set
469+
`image_family` for the current image in a family, or `image_name` to pin one
470+
exactly.
471+
472+
**`Image family ubuntu-2204-lts is not valid - it was not found in project
473+
my-gcp-project`.** The family exists, but not in the project the driver
474+
searched. Public images live in their own projects, so `image_project` is
475+
almost always needed alongside `image_family`:
476+
477+
```yaml
478+
driver:
479+
image_family: ubuntu-2204-lts
480+
image_project: ubuntu-os-cloud # not your own project
481+
```
482+
483+
`gcloud compute images list` shows which project owns each family. The same
484+
applies to `custom_image` on a non-boot disk, which is resolved in
485+
`image_project` too — so if you boot from a public image, your own images are
486+
not visible to it.
487+
488+
**`Machine type e2-medium is not valid`.** Machine types are per-zone, and not
489+
every family exists in every zone. `gcloud compute machine-types list --zones
490+
us-central1-a` lists the ones you can actually use.
491+
492+
**`Disk type pd-standard for disk boot is not valid`, or a create that fails
493+
on `diskType`.** Disk types are per-zone as well, and newer machine series
494+
reject the older ones outright. Leave `disk_type` unset unless you need
495+
something specific — see [Disk types and machine
496+
series](#disk-types-and-machine-series).
497+
498+
**`Instance name ... is not valid`.** GCE names must start with a lowercase
499+
letter and end with a lowercase letter or a digit. The driver folds case and
500+
substitutes anything else, but it cannot fix a name that starts with a digit or
501+
an underscore. This comes from `inst_name`, or from a suite or platform name
502+
that begins with something GCE will not accept.
503+
504+
**`Disk name ... is too long`.** Disk names are `<instance name>-<disk name>`
505+
and share the same 63-character budget, so a long key under `disks:` leaves no
506+
room for the instance name. Shorten the disk name.
507+
508+
**`Unable to find a suitable zone in us-central1`.** No zone in the region
509+
reported itself as `UP`. Check the region name, and
510+
[Google Cloud status](https://status.cloud.google.com/).
511+
512+
**Quota errors on create.** `Quota 'CPUS' exceeded` and friends come back from
513+
GCE, not from the driver. Quotas are per-region: check
514+
`gcloud compute regions describe us-central1`, and remember that a failed run
515+
that was interrupted may still be holding instances.
516+
517+
**`kitchen create` hangs at "Waiting for server to be ready".** The instance is
518+
running and the transport cannot reach it. In order of likelihood:
519+
520+
- **A firewall rule.** The default VPC allows SSH and RDP but not WinRM. Add a
521+
rule for TCP 5985 and tag the instances — see [Windows](#windows).
522+
- **`use_private_ip: true` from outside the network.** There is no route to the
523+
internal address unless you are on the VPC or behind a VPN.
524+
- **OS Login.** If the project or the instance enforces it, keys published as
525+
`ssh-keys` metadata are ignored. Either grant the account
526+
`roles/compute.osLogin` and let `gcloud compute ssh` provision it, or set
527+
`enable-oslogin: "FALSE"` in the instance `metadata`.
528+
529+
The wait itself belongs to the transport, not to `wait_time` — see
530+
[Timing](#timing). Lowering `max_wait_until_ready` turns a ten-minute hang into
531+
a two-minute failure while you work out which of the three it is.
532+
533+
**`WinRM::WinRMAuthorizationError` on a Windows platform.** The transport is
534+
connecting as `Administrator`, which Google's images ship disabled. The guest
535+
agent resets its password without enabling it, so the login is refused. Set
536+
`transport.username` to anything else and the agent creates that account
537+
instead. The driver warns about this before it creates the instance.
538+
539+
**`Timed out after 120 seconds waiting for the GCE agent to reset the
540+
password`.** The in-guest agent never answered on the serial port. Windows
541+
images take several minutes to first boot, so raise `winpass_timeout`. If it
542+
still times out, the image probably has no guest agent — use one from
543+
`windows-cloud` rather than a custom image built without it.
544+
545+
**`Request did not complete in 600 seconds`.** A GCE operation did not finish
546+
within `wait_time`. The operation is still running on Google's side, so look at
547+
the instance in the Cloud Console before retrying.
548+
549+
**Instances or disks left behind after an interrupted run.** `Ctrl-C` raises
550+
`Interrupt`, which is not a `StandardError`, so the driver's own cleanup does
551+
not run. It records what it created in the state file first, precisely so that
552+
a follow-up `kitchen destroy` can find it:
553+
554+
```sh
555+
cinc kitchen destroy
556+
```
557+
558+
If the state file is gone too, the driver stamps `created-by: test-kitchen`
559+
into every instance's metadata, so they can be found and removed by hand:
560+
561+
```sh
562+
gcloud compute instances list --filter="metadata.items.key=created-by AND metadata.items.value=test-kitchen"
563+
gcloud compute disks list --filter="-users:*"
564+
```
565+
566+
**Anything else.** Run with `-l debug`:
567+
568+
```sh
569+
cinc kitchen create default-ubuntu-2204 -l debug
570+
```
571+
572+
The debug log records every API call the driver makes and the error the Google
573+
client returned, which is usually enough to see what GCE actually objected to.
574+
436575
## Using with Chef
437576

438577
This driver is not tied to Cinc. The examples above use Cinc Workstation and the `cinc_infra` provisioner, but the driver works exactly the same with [Chef Workstation](https://www.chef.io/downloads/tools/workstation) — run `kitchen` instead of `cinc kitchen`, and use `chef_infra` instead of `cinc_infra`:

0 commit comments

Comments
 (0)