Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track actions taken against orgs #3835

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jlantz
Copy link
Contributor

@jlantz jlantz commented Sep 23, 2024

This pull request introduces a new framework for tracking individual org related actions. The goal is to provide both better observability and auditability to the dynamic decisions made by CumulusCI and hopefully to be able to replay all actions run against the previous scratch org on refresh.

I first realized the need for this while working on the OrgSnapshots functionality I'm building. I needed to know the resolved dependencies from the flow run by a previous GitHub Actions step. CumulusCI currently doesn't store that info anywhere. Also, update_dependencies doesn't store the resolved dependencies in return_values, which is also included in this branch :)

I'll be working on docs and test cases as well as using and improving this framework before bringing the PR out of draft.

For now...

  • New track_history property on orgs -> scratch -> <org_name> to enable history tracking. No history tracking is recorded on any orgs by default
  • New Pydantic models for OrgHistory and OrgAction with base classes and implementations for a common set of actions against orgs:
    • OrgCreate
    • OrgConnect
    • OrgDelete
    • OrgImport
    • Task
    • Flow
  • If track_history is enabled for the org, recording of each action with full hashed details are stored in org_config.history.actions
  • New cci history command group with subcommands:
    • list: List and filter actions for a given org for display or json
    • info <action_hash>: Get the details for an action for display or json
    • clear: Select and filter specific actions from the org's history
    • enable|disable: Enable/disable tracking on the org

I also need to go through all the built in task classes and make sure they're recording their actions:

  • ActionFileReference: Path and hash of file contents
  • ActionScratchDefReference: Extension of ActionFileReference that adds parsing the json into a Python dict in the scratchdef field and using that for the hash, reducing risk of whitespace and other formatting differences impacting the hash
  • ActionDirectoryReference: Path and hash of all recursive contents
  • ActionMetadataDeployment: Path and hash of the metadata that was deployed. Stub for future optimization of hashing
  • ActionCommandExecution: Any external command executed with command, return_code, output, and stderr

Still remaining:

- Add tracking for all file and directory access by standard tasks
- Add tracking for package uninstalls
- Add tracking for metadata retrieve operations including retrieves in transforms
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.

1 participant