Skip to content

Support migration of log indexes without Flex tier#333

Merged
michael-richey merged 3 commits intomainfrom
takuya.kajiwara/support-log-indexes-without-flex-tier
Mar 20, 2025
Merged

Support migration of log indexes without Flex tier#333
michael-richey merged 3 commits intomainfrom
takuya.kajiwara/support-log-indexes-without-flex-tier

Conversation

@k4ji
Copy link
Copy Markdown
Contributor

@k4ji k4ji commented Mar 13, 2025

Replaces #328 to resolve CI issues related to forked PRs.
Closes #332

Requirements for Contributing to this repository

  • Fill out the template below. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • The pull request must only fix one issue, or add one feature, at the time.
  • The pull request must update the test suite to demonstrate the changed functionality.
  • After you create the pull request, all status checks must be pass before a maintainer reviews your contribution. For more details, please see CONTRIBUTING.

What does this PR do?

The Log Indexes API currently returns num_flex_logs_retention_days as 0 instead of null for indexes without the Flex tier, leading to migration failures when attempting to create or update log indexes in an organization where Flex logs are not enabled.

This PR ensures that when num_flex_logs_retention_days is 0, the field is removed from the imported resource, preventing unnecessary Flex log-related parameters from being included in migration requests.

Description of the Change

  • Added a check in the import method to remove num_flex_logs_retention_days when its value is 0.

Alternate Designs

An alternative approach considered was to add a check in both the create_resource and update_resource methods to remove num_flex_logs_retention_days when its value is 0.

However, this was discarded because the issue originates from the Log Indexes API's get all indexes response, which returns num_flex_logs_retention_days as 0 instead of null. The create and update APIs do not have this issue, so modifying those methods would introduce unnecessary logic for a problem that only occurs in the retrieval step.

Verification Process

Since an existing test for log index migration behavior is currently skipped, no new tests were added or modified.
Instead, manual verification was performed using the import command:

  1. Ran import targeting log indexes with and without the Flex tier.
  2. Verified that the resulting JSON output does not include num_flex_logs_retention_days for indexes without the Flex tier.
...
  "with-flex-log": {
    "name": "with-flex-log",
    ...
    "num_flex_logs_retention_days": 180
  },
  "without-flex-log": {
    "name": "without-flex-log"
    ...
    // No num_flex_logs_retention_days entry
  }
}

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

The Log Indexes API returns `num_flex_logs_retention_days` as `0` instead of `null` for indexes without the Flex tier, causing migration failures.
This change removes the field when its value is `0` to prevent unnecessary Flex log-related parameters.
@k4ji k4ji requested a review from a team as a code owner March 13, 2025 14:24
Comment thread datadog_sync/model/logs_indexes.py Outdated
Copy link
Copy Markdown
Collaborator

@michael-richey michael-richey left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@michael-richey michael-richey merged commit c48a820 into main Mar 20, 2025
8 checks passed
@michael-richey michael-richey deleted the takuya.kajiwara/support-log-indexes-without-flex-tier branch March 20, 2025 19:06
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.

Log indexes issue using SyncCLI

2 participants