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

feat: improve agent startup time #5976

Closed
wants to merge 1 commit into from
Closed

Conversation

WitoDelnat
Copy link
Contributor

Pull request description

Checklist (choose whats happened)

  • breaking change! (describe)
  • tested locally
  • tested on cluster
  • added new dependencies
  • updated the docs
  • added a test

Breaking changes

Changes

Fixes

@WitoDelnat WitoDelnat requested a review from a team as a code owner October 28, 2024 14:25
@@ -126,16 +124,32 @@ func main() {

inspector := commons.CreateImageInspector(cfg, configMapClient, secretClient)

// Connect to NATS
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving NATS first staggers the gRPC connection a bit when we start agent and control plane together. gRPC backoff is quite steep, but I want to avoid tweaking it until absolutely needed as these defaults are there for a reason.

defer grpcConn.Close()

// First request will 'wait for ready' with a timeout of agent.InitialTimeout.
proContext, err := commons.ReadProContext(ctx, cfg, grpcClient)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this up a bit, as it groups nicely with the grpcConnection part, this is where we actually wait for the connection to move from idle -> transient error -> ready.

@@ -31,7 +31,8 @@ import (
)

const (
timeout = 10 * time.Second
InitialTimeout = 30 * time.Second
Copy link
Contributor Author

@WitoDelnat WitoDelnat Oct 28, 2024

Choose a reason for hiding this comment

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

With gRPC backoff this would amount to: 1 + 1.6 + 2.5 + 4 +6.5 + 10.5 -> CRASH after 30s, last attempt at 26.1s. Kubernetes will then restart the pod and it will try again.

@WitoDelnat WitoDelnat closed this Oct 28, 2024
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.

1 participant