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

Stop channel bug fix and reload frequency #20425

Merged
merged 2 commits into from
Jul 15, 2024
Merged

Conversation

getvictor
Copy link
Member

Unreleased bug fix for #19352

@getvictor getvictor marked this pull request as ready for review July 12, 2024 21:34
@sharon-fdm sharon-fdm added ~unreleased bug This bug was found in an unreleased version of Fleet. :release Ready to write code. Scheduled in a release. See "Making changes" in handbook. #g-endpoint-ops Endpoint ops product group ~backend Backend-related issue. :ai Request AI PR review and removed ~backend Backend-related issue. :release Ready to write code. Scheduled in a release. See "Making changes" in handbook. #g-endpoint-ops Endpoint ops product group ~unreleased bug This bug was found in an unreleased version of Fleet. labels Jul 12, 2024
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

  • Fixed bug in ee/server/calendar/google_calendar.go to ensure event channel stops only once
  • Improved reliability of Google Calendar integration by proper cleanup of event watches
  • Adjusted reload frequency for calendar events in server/cron/calendar_cron.go from 12 hours to 30 minutes
  • Reordered import statements in server/cron/calendar_cron.go

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@@ -350,6 +348,14 @@ func (c *GoogleCalendar) GetAndUpdateEvent(event *fleet.CalendarEvent, genBodyFn
}
}

// If event was deleted/cancelled, we need to stop watching it
if !channelStopped {
Copy link
Collaborator

@sharon-fdm sharon-fdm Jul 12, 2024

Choose a reason for hiding this comment

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

@getvictor Are you sure there are no paths where the function returns and this will not be called even if it's needed?
Maybe consider putting under defer?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is OK as is -- I reviewed the code. I will rework the code so that we don't stop/create a new channel to watch the calendar if event changes. Maybe that will help with callback latency. That change can go into the next release/patch.

sharon-fdm
sharon-fdm previously approved these changes Jul 12, 2024
Copy link
Collaborator

@sharon-fdm sharon-fdm left a comment

Choose a reason for hiding this comment

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

I am approving this for the case your answer is negative to my question.
LGTM other than the question.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Moved removal of calendar event from queue to post-database update in /server/cron/calendar_cron.go
  • Adjusted reload frequency for calendar events to 30 minutes in /server/cron/calendar_cron.go

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Comment on lines +351 to +357
// If event was deleted/cancelled, we need to stop watching it
if !channelStopped {
err = c.config.API.Stop(details.ChannelID, details.ResourceID)
if err != nil {
level.Warn(c.config.Logger).Log("msg", "stopping Google calendar event watch", "err", err)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain the change? It seems there are two paths where the watching of the event is not stopped (all day events and one that says // Delete this event to prevent confusion. This operation should be rare. ). Were any of these two scenarios causing issues?

Copy link
Member Author

Choose a reason for hiding this comment

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

The bug was when we deleted the event from Google calendar, we did not stop watching the notification channel. When event is deleted, it comes back from Google calendar with status = "cancelled". With this change, we will now be stopping the notification channel for that case.

Copy link
Member

@lucasmrod lucasmrod left a comment

Choose a reason for hiding this comment

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

Looks good. Left one question.

@getvictor getvictor merged commit dc7a3cd into main Jul 15, 2024
14 checks passed
@getvictor getvictor deleted the victor/19352-bug-fix branch July 15, 2024 14:25
getvictor added a commit that referenced this pull request Jul 15, 2024
Unreleased bug fix for #19352

(cherry picked from commit dc7a3cd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:ai Request AI PR review
Development

Successfully merging this pull request may close these issues.

3 participants