Skip to content

Fix GRPC/HTTP/TLS - #3300

Merged
joe-elliott merged 13 commits into
grafana:mainfrom
joe-elliott:websockets-https
Jan 17, 2024
Merged

Fix GRPC/HTTP/TLS#3300
joe-elliott merged 13 commits into
grafana:mainfrom
joe-elliott:websockets-https

Conversation

@joe-elliott

@joe-elliott joe-elliott commented Jan 16, 2024

Copy link
Copy Markdown
Collaborator

What this PR does:
Tempo currently has the ability to support both HTTP and GRPC requests on its primary HTTP port. It accomplishes it by using cmux through a feature in dskit. Unfortunately cmux breaks TLS on this port. This PR reworks our implementation of the shared GRPC/HTTP port to allow TLS to work.

Also:

  • Add a TLS integration test
  • Adds a "TempoServer" shim that controls the way HTTP routes are registered.
  • Default internalserver to listen on all IPs instead of just localhost

Which issue(s) this PR fixes:
Fixes #3278

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>

@zalegrala zalegrala left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks pretty good. Just a couple comments.

util_log "github.com/grafana/tempo/pkg/util/log"
)

type TempoServer interface {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need the interface? It looks like we would be able to use the struct directly. Are you anticipating adding another implementation?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the primary reason i used an interface was to limit the ways in which the rest of the code could interact with the t.server var. Another option would have been to move this into its own package but i suppose that didn't feel necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suppose my feeling is that interfaces should have more than one implementation, but I see your perspective to limit the interactions.

Comment thread integration/e2e/ca/ca.go
}

type ca struct {
key *ecdsa.PrivateKey

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see this is only in the e2e, but are we restricted to ecdsa in the implementation?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we are restricted to whatever go supports i suppose. we're using vanilla HTTP everything.

Comment thread integration/e2e/ca/ca.go
return err
}

template.IsCA = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be true for the CA cert?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the ca cert is handled in writeCACertificate() which uses the ca.cert struct which sets IsCA to true.

to be transparent, i lifted this file directly from dskit and am not familiar with all choices made.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I read this a little quick. Now I see that this is the cert signed by the ca.

util.SearchAndAssertTrace(t, apiClient, info)
util.SearchTraceQLAndAssertTrace(t, apiClient, info)

creds := credentials.NewTLS(&tls.Config{InsecureSkipVerify: true})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to validate the server cert in this case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i think this is fine. TLS is still in use and functional. we're just not validating the cert against the CA's


// RegisterFlags add internal server flags to flagset
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.StringVar(&cfg.Config.HTTPListenAddress, "internal-server.http-listen-address", "localhost", "HTTP internal server listen address.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With an empty string here, does the underlying implementation listen on everything or local or fail?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it listens on everything which is the default behavior for our main server as well. it took me awhile to figure out why the internal server wasn't responding and this was the reason.

imo, if you turn on/configure internal server you know you are exposing a new port and at that time you will make configuration choices to secure it in whatever way makes sense for your org.

right now if you do the minimal config to start the internal server it refuses requests and it's difficult to determine why.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, I agree listen on everything unless you know better.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

netstat -luntp or apk add iproute2 && ss -ltn are friends of mine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i am not the networking wizard you are :)

@zalegrala zalegrala left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. One comment about the behavior of an empty listen address for the internal server.

@joe-elliott

Copy link
Copy Markdown
Collaborator Author

thanks for the review!

@joe-elliott
joe-elliott merged commit c4b7f8e into grafana:main Jan 17, 2024
mattdurham pushed a commit to mattdurham/tempo that referenced this pull request Jun 18, 2026
* first pass - working

Signed-off-by: Joe Elliott <number101010@gmail.com>

* refactor

Signed-off-by: Joe Elliott <number101010@gmail.com>

* working?

Signed-off-by: Joe Elliott <number101010@gmail.com>

* vendor

Signed-off-by: Joe Elliott <number101010@gmail.com>

* integration test

Signed-off-by: Joe Elliott <number101010@gmail.com>

* updated go.mod to latest

Signed-off-by: Joe Elliott <number101010@gmail.com>

* cleanup

Signed-off-by: Joe Elliott <number101010@gmail.com>

* changelog

Signed-off-by: Joe Elliott <number101010@gmail.com>

* lint

Signed-off-by: Joe Elliott <number101010@gmail.com>

* update servless mods

Signed-off-by: Joe Elliott <number101010@gmail.com>

* satisfy interface updates

Signed-off-by: Joe Elliott <number101010@gmail.com>

* lint

Signed-off-by: Joe Elliott <number101010@gmail.com>

---------

Signed-off-by: Joe Elliott <number101010@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants