Skip to content

CloudStack modernization: Java 17 + Jakarta + Phase 4 decomposition complete - #1

Open
d4m14ndx wants to merge 677 commits into
mainfrom
modernize-2026
Open

CloudStack modernization: Java 17 + Jakarta + Phase 4 decomposition complete#1
d4m14ndx wants to merge 677 commits into
mainfrom
modernize-2026

Conversation

@d4m14ndx

@d4m14ndx d4m14ndx commented May 16, 2026

Copy link
Copy Markdown
Owner

Summary

Modernization fork of Apache CloudStack covering dead-code removal, dependency upgrades, Java 17 + Jakarta + Spring 6 migration, cloud-native operability, container/Helm packaging, and the Phase 4 god-class decomposition program.

Status at modernize-2026@cdcb59f40b: Phase 4 tracked god-class line-count closeout is complete. Every tracked Phase 4 target is now below the 3K stopping rule.

Phase Status

Phase 1 - Dead Code Removal

  • Removed discontinued/dead integrations and tooling from the fork baseline.
  • Removed insecure legacy auth modules and other dead surface area.

Phase 2 - Dependency Modernization

  • Upgraded major dependency families for Java 17, security, and build support.
  • Reworked abandoned or outdated libraries where the fork needed maintained replacements.

Phase 3 - Java 17, Jakarta, Spring 6

  • Migrated from Java 11 to Java 17.
  • Migrated Spring 5.3 to Spring 6.1 and Jetty 9.4 to Jetty 11.
  • Moved application EE imports from javax.* to jakarta.* while preserving Java SE packages.
  • Fixed migration breakage across Spring, Jetty websocket, WireMock, cglib, ESAPI, CXF, Groovy, and related tests.

Phase 4 - God-Class Decomposition And Operability

God-class decomposition is now below the 3K threshold for the tracked closeout list:

File Current size Status
UserVmManagerImpl 2,867 DONE
NfsSecondaryStorageResource 2,988 DONE
ApiResponseHelper 2,642 DONE
VirtualMachineManagerImpl (engine) 2,912 DONE
NetworkOrchestrator 2,999 DONE
StorageSystemDataMotionStrategy 2,968 DONE
KubernetesClusterManagerImpl 2,948 DONE
ConfigurationManagerImpl 2,701 DONE
QueryManagerImpl 2,955 DONE
NetworkServiceImpl 2,999 DONE
AccountManagerImpl 2,935 DONE

Decomposition pattern:

  • Extract coherent behavior from large Spring manager classes into focused services/components.
  • Keep public API contracts and test spy hooks stable where needed.
  • Verify each slice with focused unit tests before merging.
  • Preserve broad CloudStack support; this fork did not narrow hypervisor scope as part of Phase 4.

Operability and packaging work in this branch includes:

  • Health endpoints for liveness/readiness.
  • Prometheus metrics surface.
  • OpenTelemetry tracing hooks.
  • JSON logging support.
  • Docker, docker-compose, Helm, and fork CI workflow work.

Phase 5 - UI Rebuild And SSO

Phase 5a is already in the branch: Next.js scaffold, design system shell, route stubs, Dockerfile, and web CI workflow. Phase 5b remains next: Auth.js, Redis/session BFF, and Java-side createUserSessionToken API work.

Latest Verification

Recent focused gates from the Phase 4 closeout:

  • mvn -pl services/secondary-storage/server -Dtest=NfsPostUploadRequestValidationServiceTest,NfsSecondaryStorageResourceTest,NfsPostUploadServiceTest -Dsurefire.failIfNoSpecifiedTests=false test - 21 tests, 0 failures.
  • mvn -pl server -Dtest=UserVmManagerImplTest,VmAssignmentValidatorImplTest,VmAssignmentNetworkServiceImplTest,VmAssignmentOwnershipServiceImplTest -Dsurefire.failIfNoSpecifiedTests=false test - 180 tests, 0 failures.
  • Web workflow permissions cleanup added permissions: contents: read to .github/workflows/web.yml.

Before final upstream-facing merge/release, rerun the broader server/reactor and UI checks because this PR is intentionally a long-running modernization diff.

Docs

  • docs/AUDIT.md
  • docs/OBSERVABILITY.md
  • docs/DEVELOPMENT.md
  • docs/REFACTORING.md
  • docs/DEPLOYMENT.md
  • docs/PROGRESS.md

Remaining Follow-Up

  • Git/GitHub branch cleanup after preserving only useful long-lived branches.
  • Phase 5b implementation decisions and execution.
  • Broader full-suite verification after the cleanup pass.
  • Manual smoke tests for deployed health, metrics, JSON logging, tracing, and UI flows.

Comment thread .github/workflows/web.yml Fixed
Damian Guppy and others added 29 commits May 22, 2026 02:55
Expand coverage from 5 to 10 tests covering account network access
checks, default network list building, and permission denial paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Expand coverage from 4 to 10 tests covering VPC hypervisor validation,
system-only network rejection, and default network selection edge cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Expand coverage from 4 to 10 tests covering NIC tracking, load
scheduling, stopped VM filtering, and agent IP fetch retry logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Expand coverage from 7 to 10 tests covering zone-wide store detection
and storage-free migration eligibility checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Expand coverage from 6 to 10 tests covering VM limit validation,
permission checks, DNS update no-ops, and user data delegation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… services

Brings each of 15 Codex Phase 4 extractions from <10 tests to >=10 tests
per the playbook minimum. Pure-test additions plus a handful of small mock-stub
fixes (lenient() for UnnecessaryStubbing, non-null returns for impls that
don't null-guard).

Services covered:
  KvmLiveStorageMigrationHandler, KvmNonLiveStorageMigrationHandler,
  VmTerminationService, VmStopOrchestrationService, VmRuntimeLifecycleService,
  VmUpdateOrchestrationService, VmLiveMigrationOrchestrationService,
  VmAssignmentNetworkService, VmCreationNetworkSelectionService,
  VmExternalDhcpIpFetchService, VmScaleReconfigurationService,
  ApiVpcVpnResponseService, ApiAddressVlanResponseService,
  ApiHostZoneCapacityResponseService, ApiLoadBalancerFirewallResponseService

13 commits, ~840 net new test lines.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Three fixes plus tests, addressing findings from a security review of the
Phase 5b auth + BFF foundation.

1. Dev-session escape hatch (web/lib/bff/config.ts)
   `allowDevSession` previously returned true on any of BFF_DEV_SESSION,
   NEXT_PUBLIC_APP_ENV=dev, or NEXT_PUBLIC_APP_ENV=development without any
   NODE_ENV gate. Because `.env.example` shipped NEXT_PUBLIC_APP_ENV=dev as
   its default, anyone copying the example into a deployed environment got
   a wide-open BFF that proxies anonymous requests to CloudStack with a
   hardcoded ROOT session. The flag is now ignored entirely when
   NODE_ENV=production (the build phase is still treated as non-production
   so `next build` keeps tree-shaking correctly).

2. CSRF defence on /api/cs/* POSTs (web/app/api/cs/[command]/route-core.ts)
   SameSite=Lax on the BFF cookie blocks most cross-site POSTs but not
   top-level form submissions. The route now rejects POSTs whose Origin
   header doesn't match either NEXTAUTH_URL or the request's own host.
   Missing Origin is allowed in non-production (curl/tests) and rejected
   in production. GET is unchanged.

3. Authorisation fallback (web/lib/auth/server.ts)
   `getCurrentUser()` used to silently return `mockUser` (role: ROOT) when
   no Auth.js session existed, turning absence-of-auth into presence-of-
   root for any server consumer. The fallback is removed; getCurrentUser
   now returns null (alias for getAuthenticatedUser). `hasRole` now denies
   by default when no user is present. Pages that explicitly want the
   Phase 5a placeholder can import `mockUser` directly.

Bonus: clarified .env.example so the dev-session env vars are explicit
and labelled NEVER-IN-PROD, and the public sidebar-label var defaults to
"local" rather than "dev".

Tests added (14 new, 222 total passing):
  - 6 cases in app/api/cs/route-core.test.ts for the Origin allowlist
    (cross-origin reject, same-origin accept, NEXTAUTH_URL match, missing-
    Origin allow in non-prod, missing-Origin reject in prod, GET bypass)
  - 8 cases in lib/bff/config.test.ts for the allowDevSession matrix
    (each enabling flag, production block, build-phase exception, etc.)

Verified: npm run lint (clean), typecheck (strict, clean), test:unit
(222/222), build (production bundle generated, 87.3 kB shared First Load).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Three Phase 5b auth/BFF fixes from a security review:
- Block allowDevSession when NODE_ENV=production (was unconditional via
  NEXT_PUBLIC_APP_ENV=dev, which was the .env.example default)
- Add Origin allowlist on /api/cs/* POSTs (CSRF defence beyond SameSite=Lax)
- Remove silent mockUser fallback in getCurrentUser/hasRole (deny-by-default
  authorization on no session)

Plus 14 new tests (6 CSRF, 8 dev-session gating). 222/222 unit tests pass,
typecheck strict, lint clean, production build OK.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts:
#	web/lib/settings-messages.test.ts
# Conflicts:
#	web/lib/settings-messages.test.ts
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.

2 participants