Skip to content

feat: add unix socket#505

Open
nmartorell wants to merge 2 commits into
mainfrom
feat/add-unix-socket
Open

feat: add unix socket#505
nmartorell wants to merge 2 commits into
mainfrom
feat/add-unix-socket

Conversation

@nmartorell
Copy link
Copy Markdown
Contributor

@nmartorell nmartorell commented Jun 2, 2026

Description

This PR extends the Unix socket listener support added on this branch by making the socket path and socket access mode configurable via environment variables and config.

Changes included:

  • Added PROXY_UNIX_SOCKET_PATH as the env var to enable the main API listener on a Unix socket instead of PROXY_PORT.
  • Added UnixSocketAccessMode config support, plus PROXY_UNIX_SOCKET_ACCESS_MODE as the env override.
  • Supported access modes are:
    • USER -> 0600
    • GROUP -> 0660
    • ALL -> 0666
  • Kept the default behavior aligned with the previous implementation by defaulting Unix socket access mode to USER.
  • Added validation for invalid access mode values when Unix socket mode is enabled.
  • Updated the Unix socket listener to apply the configured access mode instead of hardcoding 0600.
  • Updated tests covering config validation, env loading, and access-mode-to-chmod mapping.
  • Updated the README with documentation for PROXY_UNIX_SOCKET_PATH and how it interacts with socket access mode.

Linked Issue

Closes #460

Type of Change

  • Bug fix
  • New feature
  • Refactor / code quality
  • Documentation update
  • CI / build change

Testing Done

Tested proxy via Unix socket and TCP exposition (to ensure no regressions).

Suggested manual test plan for reviewer:

  • Ensure TCP exposition still works (and is the default mode)
  • Enable Unix sockets exposition and test proxy
  • Test different socket permissions modes

Checklist

  • make test-go and make test pass locally
  • make lint reports no new errors
  • New PII detection changes are covered by unit tests in tests/
  • Go proxy changes include test coverage in src/ or model/
  • Documentation updated if behavior or configuration changed
  • No sensitive data or credentials included

@nmartorell nmartorell requested a review from hanneshapke June 2, 2026 20:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Warning

This PR touches 3+ distinct areas of the codebase.

Consider splitting into smaller, focused PRs — each covering a single semantic type.
This makes reviews easier and keeps the git history clean.

Categories found:

docs:

  • README.md

code:

  • src/backend/config/config.development.json
  • src/backend/config/config.go
  • src/backend/main.go
  • src/backend/server/server.go

test:

  • src/backend/config/config_test.go
  • src/backend/main_test.go

@nmartorell nmartorell requested a review from Davidnet June 2, 2026 20:37
@nmartorell nmartorell changed the title Feat/add unix socket feat: add unix socket Jun 3, 2026
@nmartorell
Copy link
Copy Markdown
Contributor Author

@hanneshapke @Davidnet I'd be open to nuking the PROXY_UNIX_SOCKET_ACCESS_MODE env var, and making it so that the unix chmod is just configurable from the config file.

Tbh I added this initially because I thought I'd need it for DSS, but then noticed that I do not need it. I could even see the argument for not even allowing the perm mode to be configurable (i.e. just default to 600), and then make it the responsibility of the caller to chmod the unix socket file (if required).

@hanneshapke
Copy link
Copy Markdown
Collaborator

Looking great - @nmartorell you need to sign the CLA :)

return fmt.Errorf("remove stale Unix socket %s: %w", socketPath, err)
}

listener, err := net.Listen("unix", socketPath)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we mkdir -p socketPath ? like in the case that people run in /run/

@@ -104,9 +110,15 @@ func (c *Config) ResolveModelDirectory() string {
func (c *Config) ValidateConfig() error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I propose that we expand this to check both in this case a test:

PROXY_UNIX_SOCKET_PATH=/tmp/kiji.sock PROXY_PORT=some-invalid ./build/kiji-proxy

this will silently pass.

We could do a safe check in both:

// one of these must work)
if c.UnixSocketPath != "" {
    // Unix socket mode
    if err := validateSocketAccessMode(c.UnixSocketAccessMode); err != nil {
        errs = append(errs, err.Error())
    }
} else {
    // TCP mode (default)
    if err := validatePort(c.ProxyPort, "ProxyPort"); err != nil {
        errs = append(errs, err.Error())
    }
}

// validate transparent proxy port
if err := validatePort(c.Proxy.ProxyPort, "Proxy.ProxyPort"); err != nil {
    errs = append(errs, err.Error())
}

This way, both fields are validated regardless of mode.

@Davidnet
Copy link
Copy Markdown
Member

Davidnet commented Jun 3, 2026

I am also keen to remove ALL, is there any scenario where this socket might be need it to run that open for everyone? (I suspect that this might be like paranoid thing), in the case that does, maybe a umask, but yeah I would like to understand a bit more in the case for the ALL case

@hanneshapke
Copy link
Copy Markdown
Collaborator

hanneshapke commented Jun 3, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch Dataiku DSS extension to Unix sockets for proxy communication

3 participants