Skip to content

feat(datasource): add etcd key-value datasource - #416

Open
48N6E wants to merge 2 commits into
ClouGence:mainfrom
48N6E:feat/etcd-support
Open

48N6E wants to merge 2 commits into
ClouGence:mainfrom
48N6E:feat/etcd-support

Conversation

@48N6E

@48N6E 48N6E commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add a standalone etcd key-value datasource, modeled on Redis rather than a full command console.

  • Datasource registration, driver loading, and the etcd icon.
  • One or more endpoints in the host field, default port 2379.
  • Username and password authentication, connection test, and a configurable API timeout.
  • Read-only sessions that allow get and reject put and del.
  • Instance-level key browsing. Prefix listing returns at most 500 keys.
  • Chinese and English labels.
  • SQL tickets and explain for datasources that have only Env and Instance levels, so catalog and schema are not required.

Supported commands

Commands are case-insensitive, one per line. A trailing semicolon is ignored. A line starting with # is a comment. Keys and values may be wrapped in single or double quotes.

Command Form Result columns
get get <key> key, value. No row when the key is missing.
put put <key> <value> key, value. A missing value is stored as an empty string.
del del <key> key, deleted. deleted is 0 when the key is missing.
put /demo/a hello
get /demo/a
put "/demo/b c" "hello world"
put /demo/empty
del /demo/a

Related Issues

#411

Test plan

  • Manual verification
  • Backend build: :ds-etcd:compileJava
  • A plaintext endpoint connects and the connection test succeeds
  • A correct username and password connect; a wrong password is rejected
  • A read-only session can get, and put / del are rejected
  • put /demo/a hello then get /demo/a returns hello
  • put /demo/a world then get returns world
  • put "/demo/b c" "hello world" reads back the key and value with spaces
  • put /demo/empty then get returns an empty value
  • get /demo/missing returns no row
  • del /demo/a returns deleted=1, and the next get returns no row
  • del /demo/missing returns deleted=0
  • GET matches get. A trailing semicolon is ignored. A line starting with # is not executed
  • put, get, and foo /demo/a report an unsupported command or a missing key
  • Double-clicking the instance lists the keys just written, at most 500 keys

Register a standalone etcd datasource with get, put, and del, instance-level key browse, and ticket handling for datasources that have no catalog or schema.
@48N6E
48N6E requested a review from a team October 19, 2026 13:37
@Pika-Yalei

Copy link
Copy Markdown
Contributor

Thanks for the contribution! That was incredibly fast.

@Pika-Yalei

Copy link
Copy Markdown
Contributor

Could you share a screenshot showing an etcd query command and its results in CloudDM?

@Pika-Yalei

Copy link
Copy Markdown
Contributor

Could you address these three issues? This is a static review of 6912fbc; I haven't verified them against a running etcd instance.

  1. P1: Failed commands are reported as successful.
    EtcdSession.executeQuery throws on parsing errors, read-only writes, and request failures without emitting an error result. SessionAgent.failedAndContinue ignores the exception and emits an After phase, which SidecarSqlNotifyServiceImpl records as SUCCESS. The user gets no corresponding error result, and the execution record is misleading. Please follow KafkaSession's error path: emit a notify=true Error message, finish the result as failed, then rethrow.

  2. P2: PUT splits quoted keys at the first space.
    EtcdCommandParser uses rest.indexOf(' ') without tracking quotes. The example put "/demo/b c" "hello world" therefore targets the wrong key and value, so get "/demo/b c" cannot read it back. Please parse the complete quoted key before separating the value, and cover single/double quotes, spaces, and empty values.

  3. P2: CA mode ignores the uploaded CA certificate.
    EtcdConfig.asDriverProperties forwards sslMode but not sslCaFilePath. EtcdClients only changes the endpoint scheme to HTTPS and never configures the uploaded CA. A cluster signed by a private CA will still fail TLS validation even with the correct CA supplied. Please propagate the materialized CA file and use it in the jetcd client's trust configuration.

Please also verify the failure-result/audit path, the quoted-key round trip, and a private-CA connection when testing the fixes.

@48N6E

48N6E commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

  1. Failed commands are no longer recorded as success. EtcdSession.executeQuery follows the Kafka path: it emits an Error message with notify=true, finishes the result as failed, and then rethrows. SessionAgent uses that flag to mark the execution FAILURE.

  2. put reads the complete quoted key before the value. Single quotes, double quotes, a space inside the key, and a missing value (stored as an empty string) are handled. put "/demo/b c" "hello world" keeps the key /demo/b c.

  3. CA mode uses the uploaded certificate. The session factory materializes the CA file, and the jetcd client trusts that file. It no longer only switches the endpoint scheme to HTTPS.

The demo recording shows the CA certificate setup, a successful connection test, and a console query.
ETCD2

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.

2 participants