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

separate clean up of host and registry images #1183

Merged
merged 3 commits into from
May 31, 2023
Merged

Conversation

gnmahanth
Copy link
Contributor

@gnmahanth gnmahanth requested a review from noboruma May 31, 2023 10:39
@gnmahanth gnmahanth changed the title sepereate clean up of host and registry images separate clean up of host and registry images May 31, 2023
Comment on lines 149 to 158
// host images
if _, err = session.Run(`
MATCH (n:ContainerImage)
WHERE n.active = false
MATCH (n:ContainerImage)
WHERE exists((n)<-[:HOSTS]-(:Node))
AND NOT exists((n)<-[:HOSTS]-(:RegistryAccount))
AND n.active = false
AND NOT exists((n) <-[:SCANNED]-())
OR n.updated_at < TIMESTAMP()-$old_time_ms
WITH n LIMIT 100000
DETACH DELETE n`,
map[string]interface{}{
"old_time_ms": dbScannedResourceCleanUpTimeout.Milliseconds(),
}); err != nil {
log.Error().Msgf("Error in Clean up DB task: %v", err)
return err
}

// registry images
if _, err = session.Run(`
MATCH (n:ContainerImage)
WHERE exists((n)<-[:HOSTS]-(:RegistryAccount))
AND n.active = false
AND NOT exists((n) <-[:SCANNED]-())
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need this because active = false is already holding the information (shall we delete the image or not)

@gnmahanth gnmahanth force-pushed the v2-images-cleanup branch from 37bee43 to 8b5c53f Compare May 31, 2023 16:22
@gnmahanth gnmahanth force-pushed the v2-images-cleanup branch from 8b5c53f to 5d49f42 Compare May 31, 2023 16:30
@gnmahanth gnmahanth merged commit 0c0c9c6 into v2 May 31, 2023
@gnmahanth gnmahanth deleted the v2-images-cleanup branch May 31, 2023 16:32
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.

2 participants