Skip to content

feat(fl): per-job fl-server — flip-api scales fl-server to zero between training jobs (NVFLARE) - #1152

Draft
garciadias wants to merge 2 commits into
developfrom
735-phase0-tolerate
Draft

feat(fl): per-job fl-server — flip-api scales fl-server to zero between training jobs (NVFLARE)#1152
garciadias wants to merge 2 commits into
developfrom
735-phase0-tolerate

Conversation

@garciadias

Copy link
Copy Markdown
Collaborator

Part of #735 (does not close it). Draft — see note below.

What

Phase 0 of #735, rebuilt from scratch on current develop following the #798 review. Decouples fl-api and flip-api from the assumption that the fl-server is always up, behind PER_JOB_FL_SERVER (default false, so flag-off behaviour is byte-identical to today).

The four #798 blockers, fixed:

  1. Lazy reconnect re-authenticates. The lazy first-use connect now goes through _reconnect() (fresh Session.__init__ → new AdminAPI), not try_connect() — a failed boot-time connect leaves a half-built cell that AdminAPI.connect()'s if self.cell: return short-circuits.
  2. _connected is "currently connected", not "ever connected". _do_command now catches NoConnection, clears _connected, and reconnects before retrying.
  3. InternalError no longer escapes. The boot-tolerance path tolerates the InternalError that AdminAPI.login() produces for a server that is up but not ready (the mid-cold-start window).
  4. Tolerated set narrowed. Auth/identity failures — AuthenticationError, AuthorizationError, bare FLCommunicationError, and NoConnection("cannot authenticate\…") — still raise even with the flag on. Only transport-down and not-ready are tolerated.

Boot tolerance (session_manager.py): with the flag on, an unreachable server at boot is logged and the session connects lazily on first use; with it off, boot stays fatal exactly as today.

Offline status (check_server_status): returns ServerInfoModel(status="STOPPED") when the server is unreachable, mirroring fl-api-flower, instead of 500-ing the hub's readiness probe.

keep-alive gating (flip-api, C8): when the flag is on and no net is BUSY, the 2-minute keep-alive ping is skipped — no more "no response" noise for servers down by design.

Flag plumbing: PER_JOB_FL_SERVER threaded through fl-api-base, flip-api (unified lenient parsing — empty/commented/"false"/"0"/"no"/"off" = false; "true"/"1"/"yes"/"on" = true, identical in both services), Terraform variables.tf + locals.tf (flip_api and fl_api maps), every NVFLARE compose (dev net-1 + net-2, prod), .env.development.example. Root Makefile no longer exports commented .env lines (which previously exported PER_JOB_FL_SERVER as an empty string).

Why draft

The #798 review's restructure: the tolerate half is unfalsifiable without the scale driver, so this should merge together with (or after) the driver/readiness/IAM work. Phase 1 (TF ignore_changes + scoped ecs:UpdateService) is already up separately as #1141. This PR is the tolerate half, kept as a draft for that reason.

Verification

  • fl-services/nvflare/fl-api-base: 197 passed, ruff + mypy clean.
  • flip-api (targeted): tests/unit/fl_services/services/test_fl_service.py 94 passed; ruff clean.
  • tofu validate (deploy/providers/AWS) clean.

Not in this PR

)

Phase 0 of #735: decouple fl-api and flip-api from the assumption that the fl-server is always up, behind the PER_JOB_FL_SERVER flag (default false).

- FLIP_Session: lazy first-use connect via _reconnect (fresh Session.__init__), not try_connect. _connected tracks "currently connected"; _do_command handles NoConnection; check_server_status reports STOPPED when unreachable.
- session_manager: tolerate transport-down and not-ready at boot when the flag is on; auth/identity failures still raise.
- flip-api: skip keep-alive ping when the flag is on and no net is BUSY.
- PER_JOB_FL_SERVER threaded through both services, Terraform, NVFLARE composes, .env.example; root Makefile no longer exports commented .env lines.

Refs #735

Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
@github-actions github-actions Bot changed the title feat(fl): tolerate an unreachable fl-server at boot — per-job Phase 0 (#735) feat(fl): per-job fl-server — flip-api scales fl-server to zero between training jobs (NVFLARE) Sep 3, 2026
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.04478% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...s/nvflare/fl-api-base/fl_api/utils/flip_session.py 88.88% 3 Missing ⚠️
flip-api/src/flip_api/config.py 66.66% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

…ce, coerce (#735)

Closes the codecov gaps on the Phase 0 draft: try_connect connected-latch behaviour, the InternalError (not-ready) and cannot-authenticate boot branches, and the PER_JOB_FL_SERVER coerce spellings.

Refs #735

Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
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