Files
arcadia-cloud/config/config.exs
Giuliano Silvestro ea3101ca2f Close inventory gaps: Spaces buckets (URN-discover), droplet backups, snapshot URN aliases
Two patterns added:

1. ProjectsWorker now does URN-discover for kinds without a dedicated
   sync worker (spaces_bucket, managed_db, k8s_cluster, etc.). For these,
   it inserts a minimal placeholder row when the URN points to something
   not yet in inventory. Kinds with dedicated workers (droplet, snapshot,
   volume, etc.) still get attribution-only — the worker is source of
   truth for richer attrs. Implemented by splitting attribute_or_discover/4
   on a @dedicated_kinds whitelist.

2. New BackupsWorker pulls /v2/droplets/:id/backups for each active
   droplet. DO automated backups aren't in /v2/snapshots; they live per
   droplet. Cron: hourly at :41. Kind="droplet_backup".

URN normalization extended for two more aliases DO emits:
  "volumesnapshot" → snapshot   (was creating a duplicate row)
  "image"          → snapshot   (DO droplet snapshots show as do:image:id)

Billing.find_resource/1 gets a kind-specific clause for droplet_backup
that matches to the parent droplet by name, since invoice lines for
backups read "<droplet-name> (Weekly Backup Services)" — the line is a
per-droplet subscription, not a per-backup-snapshot fee.

Live verified on the same April 2026 invoice:
- 6 Spaces buckets discovered via URN (account has 6, only 1 visible in
  the invoice as the $5 subscription line — that's account-level so it
  can't tie to a specific bucket, expected).
- 4 droplet backups discovered via BackupsWorker; the git.sky-ai.com
  backup line now matches (repo.sky-ai.com backup line can't match — that
  droplet was destroyed).
- Of 16 unmatched lines: 11 are destroyed historic resources, 1 is GST,
  1 is the account-level Spaces subscription, 3 are likely tiny snapshot
  name variances. Effectively ~100% of currently-existing billable
  resources match.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 22:46:29 +10:00

76 lines
2.6 KiB
Elixir

# This file is responsible for configuring your application
# and its dependencies with the aid of the Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
# General application configuration
import Config
config :arcadia_cloud,
ecto_repos: [ArcadiaCloud.Repo],
generators: [timestamp_type: :utc_datetime, binary_id: true]
# Configure the endpoint
config :arcadia_cloud, ArcadiaCloudWeb.Endpoint,
url: [host: "localhost"],
adapter: Bandit.PhoenixAdapter,
render_errors: [
formats: [json: ArcadiaCloudWeb.ErrorJSON],
layout: false
],
pubsub_server: ArcadiaCloud.PubSub,
live_view: [signing_salt: "4W6q5pDB"]
# Configure Elixir's Logger
config :logger, :default_formatter,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason
# Guardian — JWTs are issued by arcadia-app. arcadia-cloud only verifies them.
# Issuer and secret_key MUST match arcadia-app's Arcadia.Guardian config.
config :arcadia_cloud, ArcadiaCloud.Guardian,
issuer: "arcadia",
verify_issuer: true
# Oban — provisioning, sync, billing, gateway-event consumption queues
config :arcadia_cloud, Oban,
engine: Oban.Engines.Basic,
queues: [
provisioning: 5,
cloud_sync_fast: 5,
cloud_sync_full: 3,
cloud_sync_slow: 1,
cloud_billing: 1,
metering: 2,
default: 5
],
plugins: [
{Oban.Plugins.Cron,
crontab: [
# ProjectsWorker first so attribution is fresh before resource syncs
{"*/15 * * * *", ArcadiaCloud.Sync.ProjectsWorker},
{"*/15 * * * *", ArcadiaCloud.Sync.DropletsWorker},
{"*/15 * * * *", ArcadiaCloud.Sync.DomainsWorker},
{"*/15 * * * *", ArcadiaCloud.Sync.VolumesWorker},
{"*/15 * * * *", ArcadiaCloud.Sync.FloatingIpsWorker},
{"*/15 * * * *", ArcadiaCloud.Sync.FirewallsWorker},
{"*/15 * * * *", ArcadiaCloud.Sync.LoadBalancersWorker},
# Snapshots change slowly; hourly is enough and reduces API churn
{"33 * * * *", ArcadiaCloud.Sync.SnapshotsWorker},
# Backups also slow-moving; hourly per-droplet walk
{"41 * * * *", ArcadiaCloud.Sync.BackupsWorker},
# Billing: hourly balance, daily invoice discovery
{"7 * * * *", ArcadiaCloud.Sync.BalanceWorker},
{"23 2 * * *", ArcadiaCloud.Sync.BillingHistoryWorker}
]}
],
repo: ArcadiaCloud.Repo
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"