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

Send data plane health request #683

Merged
merged 20 commits into from
May 23, 2024
Merged

Send data plane health request #683

merged 20 commits into from
May 23, 2024

Conversation

aphralG
Copy link
Contributor

@aphralG aphralG commented May 21, 2024

Proposed changes

Added:

  • Health Watcher Service & Plugin
  • Instance Health Monitoring Frequency in config
  • Instance Health Topic
  • Send data plane health update when

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@aphralG aphralG self-assigned this May 21, 2024
@github-actions github-actions bot added the chore Pull requests for routine tasks label May 21, 2024
Copy link

netlify bot commented May 21, 2024

Deploy Preview for agent-public-docs canceled.

Name Link
🔨 Latest commit 903aa13
🔍 Latest deploy log https://app.netlify.com/sites/agent-public-docs/deploys/664f59ae6d52600008e2e224

Comment on lines +316 to +319
if !gc.isConnected.Load() {
slog.InfoContext(ctx, "gRPC client not connected yet. Skipping sending data plane health update")
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is likely out of scope but should we be buffering messages in the event that we aren't connected?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah maybe create a separate task for that. We should be retrying until a connection is made

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, to be honest I just went off what was done for the data plane status for this.

internal/bus/topics.go Outdated Show resolved Hide resolved
internal/watcher/health_watcher_service.go Outdated Show resolved Hide resolved
internal/watcher/health_watcher_service.go Show resolved Hide resolved
internal/watcher/health_watcher_service.go Outdated Show resolved Hide resolved
internal/config/config.go Outdated Show resolved Hide resolved
internal/watcher/health_watcher_service.go Outdated Show resolved Hide resolved
internal/watcher/health_watcher_service.go Outdated Show resolved Hide resolved
}

func (hw *HealthWatcherService) Watch(ctx context.Context, ch chan<- InstanceHealthMessage) {
monitoringFrequency := hw.agentConfig.Watchers.InstanceHealthWatcher.MonitoringFrequency
Copy link
Contributor

Choose a reason for hiding this comment

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

security: Add nil checks for agentConfig and Watchers. Or at least for Watchers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed in office, will be fixed in later PR

}
}

func (hw *HealthWatcherService) health(ctx context.Context) ([]*v1.InstanceHealth, bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

I generally think that it's a good idea to have named return values if one of them is a bool, as you can't infer what the bool means based on the signature alone without them.

func (hw *HealthWatcherService) health(ctx context.Context) ([]*v1.InstanceHealth, bool,
) {
healthStatuses := make([]*v1.InstanceHealth, 0, len(hw.watchers))
currentHealth := make(map[string]*v1.InstanceHealth)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@olli-holmala olli-holmala left a comment

Choose a reason for hiding this comment

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

LGTM!

@aphralG aphralG merged commit 478a878 into v3 May 23, 2024
14 checks passed
@aphralG aphralG deleted the send-data-plane-health-request branch May 23, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for routine tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants