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

Add RemoveMatches in snapshot template #558

Merged
merged 11 commits into from
Sep 17, 2024
Merged

Conversation

davidjumani
Copy link
Contributor

@davidjumani davidjumani commented Sep 3, 2024

  • Adds the RemoveMatches method in snapshot_template.go that removes all resources that match the given crietria.
  • Adds the ability for event loops to determine if the Syncer passed is a SyncDecider to determine if a sync is necessary.

@solo-changelog-bot
Copy link

Issues linked to changelog:
solo-io/gloo#9274

continue // skip syncing this syncer
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied over from

if syncDecider, isDecider := syncer.({{ .GoName }}SyncDecider); isDecider {

Copy link
Contributor

@sam-heilbron sam-heilbron left a comment

Choose a reason for hiding this comment

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

Looking good! A couple of small thoughts

for {
select {
case snapshot, ok := <-watch:
if !ok {
return
}

if syncDecider, isDecider := el.syncer.(TestingSyncDecider); isDecider {
Copy link
Contributor

Choose a reason for hiding this comment

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

When this is running, how should I expect to debug this behavior? Should we have metrics or logs emitted when a sync is not necessary?

Copy link
Contributor Author

@davidjumani davidjumani Sep 12, 2024

Choose a reason for hiding this comment

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

Yes, the Syncer that implements SyncDecider can have metrics to track this

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that something that we need to implement here, or in Gloo we can define that SyncDecider?

test/mocks/v1/testing_snapshot.sk.go Outdated Show resolved Hide resolved
test/mocks/v1/testing_snapshot.sk.go Show resolved Hide resolved
@davidjumani davidjumani changed the title Add RemoveAllResourcesInNamespace in snapshot template Add RemoveMatches in snapshot template Sep 17, 2024
for {
select {
case snapshot, ok := <-watch:
if !ok {
return
}

if syncDecider, isDecider := el.syncer.({{ .GoName }}SyncDecider); isDecider {
if shouldSync := syncDecider.ShouldSync(previousSnapshot, snapshot); !shouldSync {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
if shouldSync := syncDecider.ShouldSync(previousSnapshot, snapshot); !shouldSync {
if !syncDecider.ShouldSync(previousSnapshot, snapshot) {

continue // skip syncing this syncer
}
} else if syncDeciderWithContext, isDecider := el.syncer.({{ .GoName }}SyncDeciderWithContext); isDecider {
if shouldSync := syncDeciderWithContext.ShouldSync(opts.Ctx, previousSnapshot, snapshot); !shouldSync {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
if shouldSync := syncDeciderWithContext.ShouldSync(opts.Ctx, previousSnapshot, snapshot); !shouldSync {
if !syncDeciderWithContext.ShouldSync(opts.Ctx, previousSnapshot, snapshot) {

@soloio-bulldozer soloio-bulldozer bot merged commit 95038fc into main Sep 17, 2024
2 checks passed
@soloio-bulldozer soloio-bulldozer bot deleted the add-delete-ns-snapshot branch September 17, 2024 21:10
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.

4 participants