Skip to content

[codex] expose per-instance replica state on phala_app#7

Draft
h4x3rotab wants to merge 1 commit intomainfrom
feat/app-instances-no-ordinal-243
Draft

[codex] expose per-instance replica state on phala_app#7
h4x3rotab wants to merge 1 commit intomainfrom
feat/app-instances-no-ordinal-243

Conversation

@h4x3rotab
Copy link
Copy Markdown
Contributor

Summary

This PR adds an additive per-instance view to phala_app without changing the backend API shape.

It keeps phala_app as the app-level lifecycle resource and exposes current app members through a computed instances attribute sourced from the existing app/CVM APIs.

What Changed

  • add computed phala_app.instances
  • each instance exposes:
    • id
    • app_id
    • name
    • vm_uuid
    • instance_id
    • status
    • region
    • instance_type
    • endpoint
    • created_at
  • include created_at in the provider CVM response model
  • extend the smoke fixture outputs with:
    • app_instances
    • app_instance_vm_uuids
    • app_instance_ids
  • document the new computed state in the resource docs

Why

Issue #243 asks for primitives closer to GCP MIG / StatefulSet semantics for stateful replica sets.

Without backend API changes, the smallest honest Terraform slice is not a new lifecycle resource or fake ordinal model. It is exposing the real per-instance identity that already exists in the backend/API:

  • app = set identity
  • CVM = concrete instance identity
  • vm_uuid = operator-safe per-instance handle
  • instance_id = runtime/workload identity

This PR makes that shape available in Terraform state while preserving backward compatibility for existing phala_app users.

Intentionally Deferred

  • no phala_app_instance resource yet
  • no ordinals / slots
  • no rollout policy semantics
  • no lifecycle hooks / auto-heal semantics

Those need either a stronger backend contract or a separate provider design pass.

Validation

  • go test ./internal/provider/...
  • real-env smoke run against live Phala Cloud with replicas=2
    • verified phala_app.instances returned two concrete members
    • verified each member included distinct vm_uuid and instance_id
    • verified destroy cleaned up the smoke app

Additional Fixes Found During Smoke

The live smoke run surfaced two provider bugs that are fixed in this PR:

  1. instances must be a Terraform types.List, not a plain Go slice, so plan-time unknown values are handled correctly.
  2. Auto-placement should not backfill region into state when the user left region unset, otherwise apply can fail with an inconsistent result.

Closes #243

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.

1 participant