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

init node location updater #2427

Merged
merged 4 commits into from
Oct 9, 2024
Merged

init node location updater #2427

merged 4 commits into from
Oct 9, 2024

Conversation

Omarabdul3ziz
Copy link
Contributor

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring

- add updater package
- expose GetState from registerer
- fix longitude spelling
Copy link
Member

@muhamadazmy muhamadazmy left a comment

Choose a reason for hiding this comment

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

While i am not sure why zos needs to update location every 24 hours i don't believe this is the right way.

The registration service should be the only service to issue an update node (or create node) start to update the node outside this context can lead to unmanaged and hard to debug code.

Registration service already has a mechanism to update the node when some changes are detected (like ip change) and i think this should be included there

@Omarabdul3ziz
Copy link
Contributor Author

the issue is updates happen to some ips on the MaxMind database it may be a change in the country name from English chars to native chars like Turkey > Türkiye or the country name changed.

the suggestion was to update the node location periodically. since the changes in the database aren't frequent i thought once a day is a good period to check.

i moved the code for update location to be part of the register package

@@ -146,6 +152,10 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen
if err := r.reActivate(ctx, cl, env); err != nil {
log.Error().Err(err).Msg("failed to reactivate account")
}
case <-time.After(updateLocationInterval):
if err := r.updateLocation(ctx, cl); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Code in general looks way better. But why just not call register() here. It already collects the location, then compare if the node information has changed before calling update.

@Omarabdul3ziz Omarabdul3ziz merged commit c812462 into main Oct 9, 2024
24 checks passed
@Omarabdul3ziz Omarabdul3ziz deleted the main_location_updater branch October 9, 2024 07: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.

2 participants