Skip to content

stdio dialer support - #3265

Closed
aluzzardi wants to merge 3 commits into
dagger:mainfrom
aluzzardi:dagger-go-sdk-client
Closed

aluzzardi wants to merge 3 commits into
dagger:mainfrom
aluzzardi:dagger-go-sdk-client

Conversation

@aluzzardi

@aluzzardi aluzzardi commented Oct 6, 2022 •

Copy link
Copy Markdown
Contributor
  • engine: stdio dialer support (e.g. dagger dial-stdio command)
  • Go SDK: dial stdio support

NOTE: Go SDK still uses the embedded engine. the stdio dialer is for testing purposes, the real user are going to be the TS/Python SDKs.

In action:

$ dagger do -f git.graphql
{
    "core": {
        "git": {
        }
    }
}

$ DAGGER_HOST=bin:///Users/al/.bin/dagger dagger do -f git.graphql
{
    "core": {
        "git": {
        }
    }
}

/cc @helderco

@aluzzardi
aluzzardi changed the base branch from cloak to main October 14, 2022 18:25
@aluzzardi
aluzzardi force-pushed the dagger-go-sdk-client branch from 38bf3fa to da83121 Compare October 15, 2022 01:56
@aluzzardi aluzzardi changed the title Go SDK: Revamp Client library stdio dialer support Oct 15, 2022
@aluzzardi
aluzzardi marked this pull request as ready for review October 15, 2022 02:06
@helderco

Copy link
Copy Markdown
Contributor

[...] the real user are going to be the TS/Python SDKs

Sorry, I'm missing some context.

  • Is dagger dial-stdio to replace dagger dev when running an (embedded) client?
  • Does anything change for extensions?
  • When I run go run ./cmd/dagger dial-stdio I get the following panic:
http: panic serving : too many concurrent operations on a single file or socket (max 1048575)
goroutine 1051810 [running]:
net/http.(*conn).serve.func1()
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:1850 +0xb0
panic({0x105a47e00, 0x105be5dc0})
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/runtime/panic.go:890 +0x258
internal/poll.(*fdMutex).rwlock(0x140001ae000, 0x80?)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/internal/poll/fd_mutex.go:147 +0x134
internal/poll.(*FD).readLock(...)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/internal/poll/fd_mutex.go:221
internal/poll.(*FD).Read(0x140001ae000, {0x14470b3f000, 0x1000, 0x1000})
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/internal/poll/fd_unix.go:144 +0x44
os.(*File).read(...)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/os/file_posix.go:31
os.(*File).Read(0x140001ac000, {0x14470b3f000?, 0x1434dc94690?, 0x1446ebf7e38?})
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/os/file.go:118 +0x5c
main.(*stdioConn).Read(0x1446ebf7e30?, {0x14470b3f000?, 0x16318ea00?, 0x16318e900?})
	/Users/helder/Projects/dagger/cmd/dagger/dial_stdio.go:66 +0x2c
net/http.(*connReader).Read(0x1446ebf7e30, {0x14470b3f000, 0x1000, 0x1000})
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:786 +0x234
bufio.(*Reader).fill(0x144704aa8a0)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/bufio/bufio.go:106 +0xfc
bufio.(*Reader).ReadSlice(0x144704aa8a0, 0x7f?)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/bufio/bufio.go:372 +0x30
bufio.(*Reader).ReadLine(0x144704aa8a0)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/bufio/bufio.go:401 +0x24
net/textproto.(*Reader).readLineSlice(0x1446ebf7e60)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/net/textproto/reader.go:56 +0x78
net/textproto.(*Reader).ReadLine(...)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/net/textproto/reader.go:37
net/http.readRequest(0xc0cb6eaef7664040?)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/net/http/request.go:1036 +0x54
net/http.(*conn).readRequest(0x1445c160f00, {0x105bf54c8, 0x1446e5ffc40})
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:994 +0x1e4
net/http.(*conn).serve(0x1445c160f00, {0x105bf5570, 0x14000a9e5d0})
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:1916 +0x2e4
created by net/http.(*Server).Serve
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:3102 +0x444

@aluzzardi aluzzardi mentioned this pull request Oct 26, 2022
4 of 7 tasks
@aluzzardi

Copy link
Copy Markdown
Contributor Author

Is dagger dial-stdio to replace dagger dev when running an (embedded) client?

Yep.

  • dagger dev is a workaround: it's supposed to be called by humans, not code
  • Even if we keep communication over tcp, it should be a different command (dagger engine start? I don't know)
  • dial-stdio allows to communicate over stdio rather than tcp (avoid binding a port, port collision, etc)

Does anything change for extensions?

Not really.

As part of dagger.Connect() (Go SDK), the SDK supports DAGGER_HOST:

  • bin://<path to dagger> -- uses dial-stdio
  • For extensions, DAGGER_HOST is automatically set to unix:///dagger.sock (same behavior as today)

When I run go run ./cmd/dagger dial-stdio I get the following panic

Ouch. Yeah this PR is not ready

@aluzzardi
aluzzardi force-pushed the dagger-go-sdk-client branch from da83121 to b587c2d Compare October 26, 2022 23:58
Signed-off-by: Andrea Luzzardi <[email protected]>
@aluzzardi

Copy link
Copy Markdown
Contributor Author

This PR should be ready to go

@helderco @dolanor The Python & Node SDKs should be able to communicate over stdio as well

@dagger dagger deleted a comment from netlify Bot Oct 27, 2022
)

func init() {
engineconn.Register("bin", New)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why bin?
Why not stdio? (is that what would be the defined scheme? (xxx://)

}

func New(u *url.URL) (engineconn.EngineConn, error) {
return &Bin{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we check that the scheme is valid here as well?

Comment thread cmd/dagger/dial_stdio.go
@@ -0,0 +1,131 @@
package main

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be under cmd/cloak now?

Comment thread cmd/dagger/dial_stdio.go
Comment on lines +75 to +76
// Return stdio connection ONLY on the first `Accept()`
// since we can't multiplex on stdio.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there any immediate needs for multiplexing? I think there may be in the future w/ services and/or filesync stuff, just wondering if I'm not thinking of already existing needs.

Comment thread cmd/dagger/main.go
devCmd.Flags().IntVar(&devServerPort, "port", 8080, "dev server port")
devCmd.Flags().StringSliceVarP(&localDirsInput, "local-dir", "l", []string{}, "local directory to import")

dialStdioCmd.Flags().StringSliceVarP(&localDirsInput, "local-dir", "l", []string{}, "local directory to import")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no longer needed 🎉

@@ -0,0 +1,54 @@
package embedded

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be bin right?

Signed-off-by: Andrea Luzzardi <[email protected]>
@TomChv TomChv mentioned this pull request Nov 3, 2022
2 of 3 tasks
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants