Skip to content

Migrate environment workflow for agentless CSPM setup to /api/fleet/managed_integrations - #7423

Merged
seanrathier merged 5 commits into
mainfrom
seanrathier/migrate-agentless-to-managed-integrations-api
Jul 28, 2026
Merged

Migrate environment workflow for agentless CSPM setup to /api/fleet/managed_integrations#7423
seanrathier merged 5 commits into
mainfrom
seanrathier/migrate-agentless-to-managed-integrations-api

Conversation

@seanrathier

@seanrathier seanrathier commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the deprecated two-step flow (POST /api/fleet/agent_policies with supports_agentless: true + POST /api/fleet/package_policies) with a single POST /api/fleet/managed_integrations call
  • Adds tests/fleet_api/managed_integration_api.py with create_managed_integration and delete_managed_integration helpers
  • Updates purge_integrations.py to call DELETE /api/fleet/managed_integrations/{id} (which handles full cleanup) when the policy was created via the new API

Context: /api/fleet/agent_policies and /api/fleet/package_policies are being deprecated for agentless integrations in 9.5 GA in favor of /api/fleet/managed_integrations. A feature flag to disallow the old path is being monitored and will be enabled in a future release. See Slack thread for context.

Test plan

  • Run install_agentless_integrations.py against a serverless project and verify CSPM AWS/Azure/GCP integrations are created successfully via the new endpoint
  • Run purge_integrations.py and verify the managed integrations are deleted cleanly

🤖 Generated with Claude Code

Replace the deprecated two-step flow (POST agent_policies + POST package_policies
with supports_agentless) with a single POST to /api/fleet/managed_integrations.
Add delete_managed_integration for cleanup, detected in purge_integrations by
agnt_policy_id == pkg_policy_id.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@seanrathier
seanrathier requested a review from a team as a code owner July 22, 2026 14:36
@seanrathier seanrathier changed the title Migrate agentless CSPM setup to /api/fleet/managed_integrations Migrate environment workflow for agentless CSPM setup to /api/fleet/managed_integrations Jul 22, 2026
@seanrathier
seanrathier enabled auto-merge July 22, 2026 16:42
@elastic elastic deleted a comment from mergify Bot Jul 23, 2026
# When agnt_policy_id == pkg_policy_id the entry was created via the managed_integrations
# API (a single combined resource). Deleting the managed integration cleans up both the
# agent policy and package policy automatically.
if policy.agnt_policy_id == policy.pkg_policy_id:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comparing IDs is fragile, future policy type that stores the same ID in both fields would be routed to the wrong deletion path.
I would suggest adding an explicit is_managed: bool = False field to PolicyState?

seanrathier and others added 4 commits July 27, 2026 17:15
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6.0.1 incorrectly groups loguru (third-party) with local-only modules.
6.1.0 correctly separates them into distinct import sections.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without this, isort can't distinguish loguru (third-party) from local
modules (fleet_api, configuration_fleet, etc.) in CI's isolated env
where loguru isn't installed. Explicit -p flags make both environments
agree on the import grouping.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The pre-commit isort hook runs in an isolated env without loguru
installed, so it can't distinguish loguru (third-party) from local
modules and applies different ordering than local isort. Rather than
changing the project-wide isort config, mark the new files with
# isort: skip_file so both environments leave them untouched.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jeniawhite
jeniawhite self-requested a review July 28, 2026 21:53
@seanrathier
seanrathier added this pull request to the merge queue Jul 28, 2026
@mergify

mergify Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 17 minutes 8 seconds in the queue, including 16 minutes 39 seconds running CI.

Required conditions to merge

Reason

Pull request #7423 has been dequeued

GitHub refused to merge the pull request. Pull Request is in the merge queue. This is usually enforced by a branch protection or ruleset rule.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@mergify mergify Bot added the queued label Jul 28, 2026
Merged via the queue into main with commit 0184f71 Jul 28, 2026
15 checks passed
@seanrathier
seanrathier deleted the seanrathier/migrate-agentless-to-managed-integrations-api branch July 28, 2026 22:12
@mergify mergify Bot added dequeued and removed queued labels Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants