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

Update list application query for migration task #3788

Merged
merged 3 commits into from
Jul 5, 2022

Conversation

khanhtc1202
Copy link
Member

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

@khanhtc1202 khanhtc1202 enabled auto-merge (squash) July 4, 2022 10:38
@nghialv
Copy link
Member

nghialv commented Jul 5, 2022

@khanhtc1202 Reuse this pattern to avoid adding a new index. Btw, using created_at is more stable than updated_at.
https://github.com/pipe-cd/pipecd/blob/master/pkg/app/ops/insightcollector/applications.go#L62-L79

@khanhtc1202
Copy link
Member Author

@khanhtc1202 Reuse this pattern to avoid adding a new index. Btw, using created_at is more stable than updated_at. https://github.com/pipe-cd/pipecd/blob/master/pkg/app/ops/insightcollector/applications.go#L62-L79

Ah nice point 👍 Thanks for the comment, but I still think we need to create CreatedAt_Id index in that case, since the code snippet you mentioned above works due to this index is existed
https://github.com/pipe-cd/pipecd/blob/master/pkg/app/ops/firestoreindexensurer/indexes.json#L5-L21

Let's me change the query and update index for that

@nghialv
Copy link
Member

nghialv commented Jul 5, 2022

but I still think we need to create CreatedAt_Id index in that case, since the code snippet you mentioned above works due to this index is existed

Why don't we use that index with the same query for this migration task?
Deleted applications don't need to be migrated, right?

@khanhtc1202
Copy link
Member Author

khanhtc1202 commented Jul 5, 2022

but I still think we need to create CreatedAt_Id index in that case, since the code snippet you mentioned above works due to this index is existed

Why don't we use that index with the same query for this migration task? Deleted applications don't need to be migrated, right?

@nghialv Due to this comment #3767 (comment) The deleted application should be migrated as well (to ensure the database manually changes delete status doesn't cause issues later), that's the current implementation, but happy to hear your thought.
cc @knanao

@khanhtc1202 khanhtc1202 changed the title Add firestore index for migration task query Update list application query for migration task Jul 5, 2022
@nghialv
Copy link
Member

nghialv commented Jul 5, 2022

but I still think we need to create CreatedAt_Id index in that case, since the code snippet you mentioned above works due to this index is existed

Why don't we use that index with the same query for this migration task? Deleted applications don't need to be migrated, right?

@nghialv Due to this comment #3767 (comment) The deleted application should be migrated as well (to ensure the database manually changes delete status doesn't cause issues later), that's the current implementation, but happy to hear your thought. cc @knanao

I feel that supporting the deleted entries is overdoing. The deleted ones are immutable and should not be queried anymore.
Do you guys find out any cases where the deleted entries need to be unmarshaled?

@knanao
Copy link
Member

knanao commented Jul 5, 2022

IMO, There are cases where we need to import logically deleted data, such as when we want to analyze data, and I felt that we should avoid panic in such cases.

@nghialv
Copy link
Member

nghialv commented Jul 5, 2022

Btw, there are a lot number of deleted applications and it is increasing over time, so if this policy is applied, all migration tasks from new will take a lot of time to do.

@khanhtc1202
Copy link
Member Author

since there is no validation for PlatformProvider field in Application model, we can expect that there is no panic if some deleted App model be unmarshaled for now. But we may avoid that by backup datastore and remove (hard delete) deleted Application if need. wdyt?

@nghialv
Copy link
Member

nghialv commented Jul 5, 2022

since there is no validation for PlatformProvider field in Application model, we can expect that there is no panic if some deleted App model be unmarshaled for now. But we may avoid that by backup datastore and remove (hard delete) deleted Application if need. wdyt?

I think that looks fine. 👍

@khanhtc1202
Copy link
Member Author

I updated the query to use the existed index, ptal 🙏

@khanhtc1202 khanhtc1202 merged commit 247ff50 into master Jul 5, 2022
@khanhtc1202 khanhtc1202 deleted the add-firestore-index branch July 5, 2022 06:36
@github-actions github-actions bot mentioned this pull request Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants