Skip to content

Matchbox terraform provider context deadline exceeded #1530

@RiRa12621

Description

@RiRa12621

Description

Terraform plan does not succeed

Steps to Reproduce

matchbox on an RPI in a container:

$ sudo docker run --rm --net=host -v /var/lib/matchbox:/var/lib/matchbox:Z -v /etc/matchbox:/etc/matchbox:Z,ro quay.io/poseidon/matchbox:v0.11.0-87-g4622144b-arm64 -address=0.0.0.0:8080 -rpc-address=0.0.0.0:8081 -log-level=debug
time="2024-10-23T19:52:24Z" level=info msg="Starting matchbox gRPC server on 0.0.0.0:8081"
time="2024-10-23T19:52:24Z" level=info msg="Using TLS server certificate: /etc/matchbox/server.crt"
time="2024-10-23T19:52:24Z" level=info msg="Using TLS server key: /etc/matchbox/server.key"
time="2024-10-23T19:52:24Z" level=info msg="Using CA certificate: /etc/matchbox/ca.crt to authenticate client certificates"
time="2024-10-23T19:52:24Z" level=info msg="Starting matchbox HTTP server on 0.0.0.0:8080"

terraform providers file:

provider "matchbox" {
  endpoint    = "matchbox.rackow.lab:8081"
  client_cert = file("~/.config/matchbox/client.crt")
  client_key  = file("~/.config/matchbox/client.key")
  ca          = file("~/.config/matchbox/ca.crt")
}

provider "ct" {}

terraform {
  required_providers {
    ct = {
      source  = "poseidon/ct"
      version = "0.13.0"
    }
    matchbox = {
      source = "poseidon/matchbox"
      version = "0.5.4"
    }
  }
}

Error:

Plan: 33 to add, 0 to change, 0 to destroy.
╷
│ Error: failed to create Matchbox client or connect to matchbox.rackow.lab:8081: context deadline exceeded
│
│   with provider["registry.terraform.io/poseidon/matchbox"],
│   on providers.tf line 1, in provider "matchbox":
│    1: provider "matchbox" {
│
╵

Verify: Steps (from same host that also runs terraform)

$ curl  matchbox.rackow.lab:8080
matchbox
$ curl  matchbox.rackow.lab:8081
curl: (52) Empty reply from server

$ openssl s_client -connect matchbox.rackow.lab:8081 -CAfile ~/.config/matchbox/ca.crt -cert ~/.config/matchbox/client.crt -key ~/.config/matchbox/client.key
Connecting to 10.12.0.231
CONNECTED(00000005)
depth=1 CN=fake-ca
verify return:1
depth=0 CN=fake-server
verify return:1
---
Certificate chain
 0 s:CN=fake-server
   i:CN=fake-ca
   a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA256

Test the following:
Not a go issue:

package main

import (
        "fmt"
        "net"
)

func main() {
        hosts, err := net.LookupHost("matchbox.rackow.lab")
        if err != nil {
                fmt.Println("Error:", err)
                return
        }

        for _, host := range hosts {
                fmt.Println("Resolved address:", host)
        }
}

prints

$ go run main.go
Resolved address: 10.12.0.231

not a terraform issue:

provider "http" {}

data "http" "local_test_grpc" {
  url = "http://matchbox.rackow.lab:8081"
}

output "response_status_grpc" {
  value = data.http.local_test_grpc.status_code
}

data "http" "local_test_http" {
  url = "http://matchbox.rackow.lab:8080"
}

output "response_status_http" {
  value = data.http.local_test_http.status_code
}

prints

$ terraform apply
data.http.local_test_grpc: Reading...
data.http.local_test_http: Reading...
data.http.local_test_http: Read complete after 0s [id=http://matchbox.rackow.lab:8080]

Changes to Outputs:
  + response_status_http = 200

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
╷
│ Error: Error making request
│
│   with data.http.local_test_grpc,
│   on main.tf line 3, in data "http" "local_test_grpc":
│    3: data "http" "local_test_grpc" {
│
│ Error making request: GET http://matchbox.rackow.lab:8081 giving up after 1 attempt(s): Get "http://matchbox.rackow.lab:8081": EOF

Which is expected, since running a http request against a grpc endpoint isn't going to do much.

Expected behavior

terraform should succeed

Environment

  • RPI 3, raspberry OS, docker as matchbox host
  • matchbox in a container

Macbook Air M2 to run terraform from.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions