Skip to content

Feat/messaging pr 0 crossplane config - #91

Open
flaviomarcheni wants to merge 9 commits into
grid-labs-tech:mainfrom
flaviomarcheni:feat/messaging-pr-0-crossplane-config
Open

Feat/messaging pr 0 crossplane config#91
flaviomarcheni wants to merge 9 commits into
grid-labs-tech:mainfrom
flaviomarcheni:feat/messaging-pr-0-crossplane-config

Conversation

@flaviomarcheni

Copy link
Copy Markdown

PR-0 — Crossplane config por Environment

Branch: feat/messaging-pr-0-crossplane-config
Jira: NS-190
ADR: 002-messaging-org-level-catalog.md

Summary

  • Configuração Crossplane por environment como recurso dedicado (environment_crossplane_configs), não no bag genérico de settings.
  • Bounded context api/app/crossplane/ (api / core / infra): config, validação e probe de health.
  • UI em Environments para habilitar Crossplane, escolher o cluster e informar região / conta AWS / provider config.
  • Validação no save: campos obrigatórios quando enabled=true, cluster do mesmo environment, e probe live de Crossplane healthy no cluster.
  • Coluna Crossplane na listagem de Clusters (mesmo padrão do Gateway API): status live via probe do BC Crossplane — sem flag manual crossplane_available.
  • Prepara sync de messaging (PRs seguintes): Topic/Queue não carregam region / provider_config no payload — herdam do environment.

Bounded context

Responsabilidade Onde
Config por env + save/validate crossplane/ (service, validators, repo, handlers)
Probe live (available / healthy / providers) crossplane/infra/k8s_crossplane_probe.pyK8sClient.check_crossplane_status
Listagem de Clusters embute status ClusterService recebe probe_crossplane injetado no composition root (cluster_handlers); core de Clusters não chama Crossplane APIs direto
DTO de status (CrossplaneFeatures) crossplane/api/crossplane_dto.py (Clusters só compõe no response)

ClusterUpdate / update de gateway não mudam nesta PR — permanecem iguais a main (ClusterCreate no PUT).

Justificativa das configs (envs / campos)

Crossplane é por environment, não por Topic/Queue: um env tem um cluster K8s fixo para sync de messaging e uma conta/região AWS. Isso evita drift e ARNs pré-montados no Jinja.

Mapeamento legado (settings bag) → recurso atual:

Setting legado Campo atual Por que é necessário Onde é utilizado
crossplane_enabled enabled Gate: sem isso o Tron não aplica Managed Resources SNS/SQS. Environments sem messaging Crossplane ficam desligados. Save da config; resolve_context_for_sync — se false, sync de messaging não provisiona
crossplane_cluster_uuid cluster_uuid Messaging usa cluster fixo do env (não o cluster do workload / least-load). Evita Managed Resources órfãos se o cluster de deploy mudar. Resolve K8sClient no sync; no save, probe de health do Crossplane nesse cluster
crossplane_aws_region aws_region Região dos recursos AWS. Input explícitoClusterProviderConfig / provider AWS não guardam region; cada MR precisa de spec.forProvider.region. Templates Jinja (region: em Topic/Queue/Subscription); validação no save
crossplane_provider_config provider_config Nome do ClusterProviderConfig no cluster (ex.: default). Define credenciais/endpoint AWS (IRSA em stg, Secret+Floci no local). Templates: providerConfigRef.name + kind: ClusterProviderConfig

aws_account_id (também no recurso)

Não existia na lista antiga de keys do settings bag, mas faz parte da config atual:

Campo Por que é necessário Onde é utilizado
aws_account_id Montar ARNs/URLs de display e contexto de IAM nos templates. A account não vem do ClusterProviderConfig quando skip_requesting_account_id está ativo (ex.: Floci local). Enrichment / sync messaging; validação de 12 dígitos no save

Resumo

  • enabled → liga/desliga provisionamento Crossplane no env
  • cluster_uuidonde aplicar os manifests (cluster Crossplane do env)
  • aws_regionem qual região AWS criar SNS/SQS
  • provider_configcom quais credenciais o provider AWS fala com a conta
  • aws_account_idqual conta para ARNs/contexto (sem inferir do provider)

Regras de validação no save

Com enabled=true:

  1. Todos os campos acima são obrigatórios.
  2. O cluster deve pertencer ao mesmo environment.
  3. Crossplane deve estar installed + healthy no cluster (probe live via probe_crossplane_health / BC Crossplane).

Com enabled=false, a config pode ser salva sem os demais campos (e sem probe).

O probe de health no save da env roda só nesse caminho — não a cada resolve de sync — para que outages temporários do control plane não bloqueiem leituras do catálogo.

A coluna na listagem de Clusters usa o mesmo probe (informativo Available / Unhealthy / Not Available + providers).

UI — modal Environments

Save fica desabilitado até o GET da config Crossplane completar (evita gravar draft vazio e apagar config existente).

Commits

Commit Descrição
e9703d9 feat(environments): add Crossplane cluster and environment config
253d494 feat(clusters): allow Crossplane-only edits without resubmitting token
59705d3 feat(crossplane): store config as a dedicated environment resource
630669e feat(crossplane): add aws_account_id to environment Crossplane config
682f8cf fix(environments): show Crossplane errors inside the modal
811a27d docs(adr): expand messaging org-level catalog ADR

(Alterações locais ainda não commitadas: BC probe + coluna Crossplane na listagem, remoção de crossplane_available, gate de Save no modal.)

Test plan

  • Abrir Environments → Crossplane: listar todos os clusters do env
  • Abrir modal: Save desabilitado / “Loading…” até o GET; depois form editável
  • Salvar com enabled=false sem demais campos → sucesso
  • Salvar com enabled=true sem region/account/provider/cluster → erro de validação
  • Salvar com cluster de outro environment → erro
  • Salvar com Crossplane unhealthy/ausente no cluster → erro no modal
  • Salvar com Crossplane healthy + campos válidos → config persistida e retornada no GET
  • Clusters list: coluna Crossplane reflete Available / Unhealthy / Not Available (live)
  • Update de cluster (gateway/token) continua funcionando sem regressão (igual main)

Screenshots

Environments — modal Crossplane

image
image

Clusters — coluna Crossplane

image

flaviomarcheni and others added 6 commits August 19, 2026 14:59
…onfig

Messaging sync needs a fixed Crossplane cluster and AWS region per environment instead of least-load selection or inferring region from api_address.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ting token

Make cluster token optional on update, keep generic Crossplane setting descriptions, and improve Portal edit flow for crossplane_available.

Co-authored-by: Cursor <cursoragent@cursor.com>
…source

Move Crossplane settings out of the generic environment settings bag into a
dedicated table, API, and portal feature so messaging sync can read a typed
environment-scoped config.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ne config

Store the AWS account id alongside region and provider_config so messaging
and sync can resolve ARNs from environment settings instead of env vars.

Co-authored-by: Cursor <cursoragent@cursor.com>
Surface load/save failures in the Crossplane dialog so they are not hidden
behind the overlay when the page-level notification sits under z-50.

Co-authored-by: Cursor <cursoragent@cursor.com>
Align ADR 002 with the existing ADR structure and document ownership,
SNS/SQS catalog rules, and Crossplane environment prerequisites.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation portal api tests database labels Aug 21, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👋 Welcome to Tron! Thanks for your first pull request.

A maintainer will review it soon. Here's what to expect:

  1. ✅ Automated tests will run on your changes
  2. 👀 A maintainer will review your code
  3. 💬 You may receive feedback or requests for changes
  4. 🎉 Once approved, your PR will be merged!

While you wait:

  • Make sure all tests pass
  • Check that your PR follows the contribution guidelines
  • Feel free to ask questions if you need help

Thank you for contributing to Tron! 🚀

flaviomarcheni and others added 3 commits August 21, 2026 11:35
…sterUpdate

Keep cluster update on ClusterCreate (same as main), surface Crossplane health
on the clusters list through the injected Crossplane probe, and gate the env
modal save until config has loaded.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove docs/pr-0-messaging-crossplane-config.md from the remote tree and
ignore docs/pr-*.md so these notes stay on the machine.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep PR writeups on the machine and out of the remote branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api database documentation Improvements or additions to documentation portal tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant