"error reading server preface: EOF" when connecting to containerd socket on mac
- Lingua principale
- Go
- Stelle
- 30.8k
- Fork
- 613
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Description
When attempting to connect to the containerd socket via gRPC or containerd APIs, we encounter the error "error reading server preface: EOF". `colima nerdctl` works. The socket is owned by the same user running the test program.
### Version
```
colima version && limactl --version && qemu-img --version
colima version 0.8.1
git commit: 96598cc5b64e5e9e1e64891642b91edc8ac49d16
limactl version 1.0.6
qemu-img version 9.2.2
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
```
### Operating System
- [ ] macOS Intel <= 13 (Ventura)
- [ ] macOS Intel >= 14 (Sonoma)
- [ ] Apple Silicon <= 13 (Ventura)
- [x] Apple Silicon >= 14 (Sonoma)
- [ ] Linux
### Output of `colima status`
colima version && limactl --version && qemu-img --version
colima version 0.8.1
git commit: 96598cc5b64e5e9e1e64891642b91edc8ac49d16
limactl version 1.0.6
qemu-img version 9.2.2
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
### Reproduction Steps
`colima start -p contd --runtime containerd`
`export CONTAINERD_ADDRESS=/Users/me/.colima/contd/containerd.sock`
Example program to exercise it, via raw gRPC or containerd API (commented-out):
```go
package main
import (
"context"
"log"
"os"
// "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/v2/defaults"
"google.golang.org/protobuf/types/known/emptypb"
versionservice "github.com/containerd/containerd/api/services/version/v1"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func main() {
address := os.Getenv("CONTAINERD_ADDRESS")
if address == "" {
address = defaults.DefaultAddress
}
log.Printf("Using containerd socket: %s", address)
gopts := []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
}
conn, err := grpc.NewClient("unix://"+address, gopts...)
if err != nil {
log.Fatalf("Failed to create gRPC connection: %v", err)
}
defer conn.Close()
client := versionservice.NewVersionClient(conn)
v, err := client.Version(context.Background(), &emptypb.Empty{})
if err != nil {
log.Fatalf("Failed to get containerd version: %v", err)
}
log.Printf("Containerd version: %s", v.Version)
// // Create a client with default namespace
// containerdClient, err := client.New(
// address,
// )
// if err != nil {
// log.Fatalf("Failed to create containerd client: %v", err)
// }
// ctx := context.Background()
// version, err := containerdClient.Version(ctx)
// if err != nil {
// log.Fatalf("Failed to get containerd version: %v", err)
// }
// log.Printf("Containerd version: %s", version)
// defer containerdClient.Close()
}
```
### Expected behaviour
Test program should run successfully displaying the version of the containerd runtime.
### Additional context
As far as I can tell, the traffic from the test program is being sent to the mac side socket, but it is not being forwarded to the linux side.
If I do:
```
colima -p contd ssh
# (in the vm)
sudo chmod a+rwx /run/containerd/
sudo chmod a+rwx /run/containerd/containerd.sock
colima ssh-config -p contd > ssh.conf
ssh -F ssh.conf -L /tmp/containerd.sock:/run/containerd/containerd.sock colima-contd -N
```
The resulting socket at `/tmp/containerd.sock` works with the given test program.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
La issue riguarda il forwarding del socket tra macOS e la VM Lima. Inizia esaminando come Colima configura il mapping del socket containerd, probabilmente nel codice di provisioning o di rete della VM. Esamina la gestione dei socket nella codebase di Colima e confrontala con l’approccio funzionante del tunnel SSH. Prova le modifiche compilando Colima localmente ed eseguendo il programma Go fornito per verificare che la connessione funzioni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go, grpc, linux, macos
- Ambito
- backend, cli, devops
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100