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 gRPC calls for Fulcio on prober #1062

Merged
merged 4 commits into from
Apr 16, 2024

Conversation

javanlacerda
Copy link
Contributor

@javanlacerda javanlacerda commented Apr 11, 2024

Closes #700

Summary

It implements a client for make requests via gRPC for prober against Fulcio. Only for reading methods were implemented.

This PR doesn't update any already existing feature, just add gRPC calls to the set of calls.

Release Note

Documentation

@javanlacerda javanlacerda marked this pull request as draft April 11, 2024 15:00
@javanlacerda javanlacerda force-pushed the javan.grpc-prober branch 2 times, most recently from 09c2612 to d6030e3 Compare April 11, 2024 18:37
@javanlacerda javanlacerda marked this pull request as ready for review April 11, 2024 18:41
@javanlacerda javanlacerda changed the title creating poc for getting TrustBundle via grpc Add gRPC calls for Fulcio on prober Apr 11, 2024
Help: "API endpoint latency distribution across Rekor and Fulcio (milliseconds)",
Buckets: []float64{0.0, 200.0, 400.0, 600.0, 800.0, 1000.0},
},
[]string{hostLabel, methodLabel})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any other metrics I could add here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we reuse the existing metrics? The method name should be enough to distinguish, or you could also prepend grpc:// to the host.

@javanlacerda javanlacerda force-pushed the javan.grpc-prober branch 2 times, most recently from e7e18a8 to 1023a0f Compare April 11, 2024 18:53
@@ -201,6 +221,15 @@ func runProbers(ctx context.Context, freq int, runOnce bool) {
Logger.Errorf("error running request %s: %v", r.Endpoint, err)
}
}

// Performing requests against Fulcio gRPC API
for _, method := range fulciopb.CA_ServiceDesc.Methods {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than iterate over all possible methods, can we just pick one representative endpoint? GetTrustBundle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!! I tried to replicate the behavior for http requests, making requests for all available endpoints.

@@ -185,7 +194,18 @@ func main() {
Logger.Fatal(http.ListenAndServe(addr, nil))
}

func runProbers(ctx context.Context, freq int, runOnce bool) {
func NewFulcioClient() (fulciopb.CAClient, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, I would mention "GRPC" in the name since this is only creating a gRPC client. Also you can make this method lowercase so it's not exported.

go runProbers(ctx, frequency, oneTime)

if fulcioClient, err := NewFulcioClient(); err != nil {
Logger.Errorf("error creating fulcio grpc client %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be Fatalf since if the client isn't properly initialized, it will fail again later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will not fail again. I agree that should be a Fatalf instead Error

Help: "API endpoint latency distribution across Rekor and Fulcio (milliseconds)",
Buckets: []float64{0.0, 200.0, 400.0, 600.0, 800.0, 1000.0},
},
[]string{hostLabel, methodLabel})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we reuse the existing metrics? The method name should be enough to distinguish, or you could also prepend grpc:// to the host.

if err != nil {
return err
}
exportGrpcDataToPrometheus(0, "grpc://"+fulcioGrpcURL, "GetTrustBundle", "GET", latency)
Copy link
Contributor

Choose a reason for hiding this comment

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

gRPC is different than HTTP in that response status codes are a part of error when it returns a 4xx/5xx error. Can we log the code using something like https://github.com/sigstore/fulcio/blob/main/pkg/server/grpc_server_test.go#L126-L128 instead of 0?

You'll need to also not return early when there is an error.

Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

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

Thanks!

@haydentherapper haydentherapper merged commit 38b0c7e into sigstore:main Apr 16, 2024
26 checks passed
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.

Add support for probing over gRPC
2 participants