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

Change rule_evaluations upsert to set migrated to true #4124

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

dmjb
Copy link
Contributor

@dmjb dmjb commented Aug 12, 2024

This query is always called after an upsert into the evaluation history table, so migrated should always be set to true. Due to the lack of the update in the ON CONFLICT DO UPDATE clause, we ran into a situation where unmigrated rows in rule_evaluations were being implicitly migrated by the policy migration (i.e. the code was creating a corresponding row in evaluation_rule_entities) but the migrated flag was still set to false. The migration script would then attempt to copy the data to the evaluation_rule_entities table, which would error out because the data for that rule/entity pair already existed.

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes #(related issue)

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

This query is always called after an upsert into the evaluation history
table, so migrated should always be set to true. Due to the lack of the
update in the `ON CONFLICT DO UPDATE` clause, we ran into a situation
where unmigrated rows in rule_evaluations were being implicitly migrated
by the policy migration (i.e. the code was creating a corresponding row
in evaluation_rule_entities) but the migrated flag was still set to
false. The migration script would then attempt to copy the data to the
evaluation_rule_entities table, which would error out because the data
for that rule/entity pair already existed.
@dmjb dmjb requested a review from a team as a code owner August 12, 2024 16:08
@dmjb
Copy link
Contributor Author

dmjb commented Aug 12, 2024

Red build is caused by the known OpenFGA CVE issue, and does not relate to the changes here.

@coveralls
Copy link

Coverage Status

coverage: 53.891% (-0.01%) from 53.904%
when pulling 326adc7 on rule-eval-upsert-migrate
into 0d2c3b8 on main.

@dmjb dmjb merged commit 98c9331 into main Aug 12, 2024
23 of 26 checks passed
@dmjb dmjb deleted the rule-eval-upsert-migrate branch August 12, 2024 16:22
dmjb added a commit that referenced this pull request Aug 13, 2024
Refer to PR #4065 for a description of the change. This was merged in
but had to be rolled back due to a bug. That bug was fixed in PR #4124.
As part of this roll out. Part of migration script 88 needs to be
repeated to fix any rows affected by that bug before applying it.
@dmjb dmjb mentioned this pull request Aug 13, 2024
10 tasks
dmjb added a commit that referenced this pull request Aug 14, 2024
Refer to PR #4065 for a description of the change. This was merged in
but had to be rolled back due to a bug. That bug was fixed in PR #4124.
As part of this roll out. Part of migration script 88 needs to be
repeated to fix any rows affected by that bug before applying it.
dmjb added a commit that referenced this pull request Aug 14, 2024
Refer to PR #4065 for a description of the change. This was merged in
but had to be rolled back due to a bug. That bug was fixed in PR #4124.
As part of this roll out. Part of migration script 88 needs to be
repeated to fix any rows affected by that bug before applying it.
psekar pushed a commit to tinytrail/minder that referenced this pull request Aug 15, 2024
)

This query is always called after an upsert into the evaluation history
table, so migrated should always be set to true. Due to the lack of the
update in the `ON CONFLICT DO UPDATE` clause, we ran into a situation
where unmigrated rows in rule_evaluations were being implicitly migrated
by the policy migration (i.e. the code was creating a corresponding row
in evaluation_rule_entities) but the migrated flag was still set to
false. The migration script would then attempt to copy the data to the
evaluation_rule_entities table, which would error out because the data
for that rule/entity pair already existed.
psekar pushed a commit to tinytrail/minder that referenced this pull request Aug 15, 2024
Refer to PR mindersec#4065 for a description of the change. This was merged in
but had to be rolled back due to a bug. That bug was fixed in PR mindersec#4124.
As part of this roll out. Part of migration script 88 needs to be
repeated to fix any rows affected by that bug before applying it.
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.

3 participants