Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions internal/autoscaler/protos/externalgrpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions internal/repositories/libvirt/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,22 @@ import (
"time"

"github.com/digitalocean/go-libvirt"
libvirtsocket "github.com/digitalocean/go-libvirt/socket"
"github.com/google/uuid"
"github.com/poyrazk/thecloud/internal/core/ports"
)

type libvirtUnixDialer struct {
uri string
timeout time.Duration
}

var _ libvirtsocket.Dialer = (*libvirtUnixDialer)(nil)

func (d *libvirtUnixDialer) Dial() (net.Conn, error) {
return net.DialTimeout("unix", d.uri, d.timeout)
Comment on lines +31 to +38
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libvirtUnixDialer stores the unix socket path in a field named uri, but in this package uri is also used for libvirt connection URIs like qemu:///system (see tests/usages). This naming makes it easy to accidentally pass a non-socket URI and have Dial() try to net.DialTimeout("unix", "qemu:///system", ...). Consider renaming the field (and constructor arg) to socketPath (or similar) to make the expected format explicit.

Suggested change
uri string
timeout time.Duration
}
var _ libvirtsocket.Dialer = (*libvirtUnixDialer)(nil)
func (d *libvirtUnixDialer) Dial() (net.Conn, error) {
return net.DialTimeout("unix", d.uri, d.timeout)
socketPath string
timeout time.Duration
}
var _ libvirtsocket.Dialer = (*libvirtUnixDialer)(nil)
func (d *libvirtUnixDialer) Dial() (net.Conn, error) {
return net.DialTimeout("unix", d.socketPath, d.timeout)

Copilot uses AI. Check for mistakes.
}

const (
defaultPoolName = "default"
userDataFileName = "user-data"
Expand Down Expand Up @@ -110,8 +122,8 @@ func NewLibvirtAdapter(logger *slog.Logger, uri string) (*LibvirtAdapter, error)
}
}

//nolint:staticcheck
l := libvirt.New(c)
_ = c.Close()
l := libvirt.NewWithDialer(&libvirtUnixDialer{uri: uri, timeout: 2 * time.Second})
Comment on lines 124 to +126
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code now dials c := net.DialTimeout(...) and then immediately closes it (_ = c.Close()), but the real libvirt client is created with NewWithDialer(...) which will dial again. This introduces an extra connection attempt that wasn’t present when libvirt.New(c) reused the already-open connection. Consider removing the probe dial entirely (let ConnectToURI surface the dial error), or move the system/session fallback logic into the dialer so only one dial happens.

Copilot uses AI. Check for mistakes.
adapter := &LibvirtAdapter{
client: &RealLibvirtClient{conn: l},
logger: logger,
Expand Down
3 changes: 1 addition & 2 deletions internal/repositories/postgres/execution_ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ func (l *PgExecutionLedger) MarkFailed(ctx context.Context, jobKey string, reaso

// GetStatus returns the current status, result and start time of a job.
func (l *PgExecutionLedger) GetStatus(ctx context.Context, jobKey string) (status string, result string, startedAt time.Time, err error) {
var res pgx.Row
res = l.db.QueryRow(ctx, `
res := l.db.QueryRow(ctx, `
SELECT status, COALESCE(result, ''), started_at FROM job_executions WHERE job_key = $1
`, jobKey)

Expand Down