Skip to content

Flip to using DNSCluster for cluster discovery#3327

Merged
michaeljguarino merged 1 commit intomasterfrom
libcluster-to-dnscluster
Mar 17, 2026
Merged

Flip to using DNSCluster for cluster discovery#3327
michaeljguarino merged 1 commit intomasterfrom
libcluster-to-dnscluster

Conversation

@michaeljguarino
Copy link
Copy Markdown
Member

This will give two things:

  • eliminate libclusters use of the endpoints api that will be deprecated in kubernetes
  • still provide cluster discovery in a way that aligns w/ k8s readiness probes (which is when it is added to the headless service)

Test Plan

e2e

Checklist

  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a meaningful title and summary to convey the impact of this PR to a user.

Plural Flow: console

@michaeljguarino michaeljguarino requested a review from a team March 15, 2026 17:28
@michaeljguarino michaeljguarino added the enhancement New feature or request label Mar 15, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 15, 2026

Greptile Summary

This PR replaces libcluster (which uses the deprecated Kubernetes Endpoints API) with DNSCluster for Erlang cluster discovery, aligning node membership with Kubernetes readiness probes via a headless service. It also introduces base64 encoding for service_file content over GraphQL (extending this to stack_tarball as well), and cleans up an invalid JSON Schema type in plan.json.

Key changes:

  • Cluster discovery: libcluster + Cluster.Strategy.Kubernetes removed; replaced by {DNSCluster, query: ...} configured via a DNS_CLUSTER_QUERY env var or a default of console-headless.<NAMESPACE>.
  • Base64 encoding of file content: The :service_file GraphQL object now encodes content with Base.encode64/1, and the frontend decodeBase64 helper (using atob) decodes it before display. The same encoding now applies to stackTarball (previously returned the raw :stack_file type).
  • Azure provider refactor: deployment_url/2 simplified to idiomatic Elixir pattern matching.
  • JSON Schema fix: "type": "enum" corrected to "type": "string" in plan.json.

Confidence Score: 4/5

  • Safe to merge with one logic issue to address: atob will garble non-ASCII UTF-8 file content in the browser.
  • The cluster discovery migration is clean and straightforward, and the base64 encoding/decoding pipeline is correctly wired end-to-end. The one issue is the use of atob in decodeBase64, which doesn't handle multi-byte UTF-8 sequences correctly and would silently corrupt file content containing non-ASCII characters (e.g. comments or strings in non-English languages).
  • assets/src/components/cd/services/service/ServiceComponentsFiles.tsx — the decodeBase64 helper needs to use TextDecoder instead of raw atob to handle UTF-8 content correctly.

Important Files Changed

Filename Overview
assets/src/components/cd/services/service/ServiceComponentsFiles.tsx Adds base64 decoding for service file content. The decodeBase64 helper uses atob, which doesn't correctly handle UTF-8 multi-byte sequences in file content.
lib/console/graphql/deployments/service.ex Adds a custom resolver to the :service_file object that base64-encodes content before returning it over GraphQL, enabling safe transport of binary or complex text content.
lib/console/graphql/deployments/stack.ex Changes stack_tarball resolver return type from :stack_file to :service_file, which will now base64-encode its content field. Test updated accordingly.
lib/console/application.ex Replaces {Cluster.Supervisor, [topologies, ...]} with {DNSCluster, query: ...} for cluster discovery, removing the libcluster dependency entirely from the supervision tree.
rel/runtime.exs Replaces libcluster topology config with a single dns_cluster_query config key, defaulting to console-headless.<NAMESPACE> with a fallback namespace of plrl-console.

Comments Outside Diff (1)

  1. assets/src/components/cd/services/service/ServiceComponentsFiles.tsx, line 116-122 (link)

    atob does not correctly handle UTF-8 content

    atob decodes base64 to a binary string where each character represents one byte. For file content that contains multi-byte UTF-8 sequences (e.g. non-ASCII characters like accented letters, CJK characters, or emoji), this will produce garbled output since atob doesn't interpret the bytes as UTF-8.

    The backend uses Base.encode64 on raw bytes, so decoding should account for UTF-8:

    This ensures multi-byte UTF-8 sequences are correctly decoded from the raw binary data returned by atob.

Last reviewed commit: f4c9c64

@michaeljguarino michaeljguarino force-pushed the libcluster-to-dnscluster branch 2 times, most recently from 703dad8 to dcbfade Compare March 15, 2026 18:59
@michaeljguarino michaeljguarino force-pushed the libcluster-to-dnscluster branch 3 times, most recently from 90127d4 to f4c9c64 Compare March 16, 2026 16:57
@michaeljguarino
Copy link
Copy Markdown
Member Author

@greptileai

@michaeljguarino michaeljguarino force-pushed the libcluster-to-dnscluster branch from f4c9c64 to 032e9a5 Compare March 16, 2026 20:08
This will give two things:

* eliminate libclusters use of the endpoints api that will be deprecated in kubernetes
* still provide cluster discovery in a way that aligns w/ k8s readiness probes (which is when it is added to the headless service)
@michaeljguarino michaeljguarino force-pushed the libcluster-to-dnscluster branch from 032e9a5 to d68c587 Compare March 17, 2026 04:23
@michaeljguarino michaeljguarino merged commit 48fd26a into master Mar 17, 2026
13 checks passed
@michaeljguarino michaeljguarino deleted the libcluster-to-dnscluster branch March 17, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants