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

purge status events #232

Merged
merged 1 commit into from
Dec 20, 2024
Merged

purge status events #232

merged 1 commit into from
Dec 20, 2024

Conversation

skeeey
Copy link
Contributor

@skeeey skeeey commented Dec 17, 2024

No description provided.

@skeeey
Copy link
Contributor Author

skeeey commented Dec 17, 2024

/cc @morvencao @clyang82 @qiujian16

@@ -22,7 +22,7 @@ func addConsumers() *gormigrate.Migration {
}

if err := CreateFK(tx, fkMigration{
"resources", "consumers", "consumer_name", "consumers(name)",
"resources", "consumers", "consumer_name", "consumers(name)", "ON DELETE RESTRICT ON UPDATE RESTRICT",
Copy link
Contributor

Choose a reason for hiding this comment

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

from SRE comments, we can't modify existing migrations, we need to create new migration to ensure their data can migrated to new schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change will not effect the db, the change due to refact the CreateFK (make it can support configing constrains )

For the event-instances part, I create a new migration to ensure the db update

@clyang82
Copy link
Contributor

/ok-to-test

@@ -136,6 +136,10 @@ func (d *instanceDaoMock) FindByUpdatedTime(ctx context.Context, updatedTime tim
return instances, nil
}

func (d *instanceDaoMock) FindReadyIDs(ctx context.Context) ([]string, error) {
return []string{}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

we can check if instance Ready == true from instances list, instead of return empty slice. this is useful for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

"event_instances", "server_instances", "instance_id", "server_instances(id)", "ON DELETE CASCADE",
}, fkMigration{
"event_instances", "status_events", "event_id", "status_events(id)", "ON DELETE CASCADE",
})
Copy link
Contributor

Choose a reason for hiding this comment

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

would you alse add foreign key for spec_event_id on events table?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@skeeey skeeey force-pushed the purge-se branch 5 times, most recently from 5996bb1 to 645bb12 Compare December 20, 2024 01:28
@clyang82
Copy link
Contributor

/ok-to-test

@skeeey
Copy link
Contributor Author

skeeey commented Dec 20, 2024

/retest

@clyang82
Copy link
Contributor

/ok-to-test

@clyang82
Copy link
Contributor

/retest


// batch delete the handled status events
batchSize := 500
for i := 0; i < len(statusEventIDs); i += batchSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

we may need to add UT to test this method. It may have problem if the length of statusEventIDs is 800.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Signed-off-by: Wei Liu <[email protected]>
Copy link
Contributor

@clyang82 clyang82 left a comment

Choose a reason for hiding this comment

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

LGTM

@clyang82
Copy link
Contributor

/ok-to-test

@clyang82 clyang82 merged commit 8f85093 into openshift-online:main Dec 20, 2024
7 checks passed
@skeeey skeeey deleted the purge-se branch December 24, 2024 05:48
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