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 cassandra TLS support #2769

Merged
merged 5 commits into from
Nov 7, 2019
Merged

Conversation

aoby
Copy link
Contributor

@aoby aoby commented Nov 6, 2019

  • Consolidate duplicate Cassandra setup and config into a new common/cassandra package
  • Add TLS support for Cassandra
  • Add TLS flags to cadence-cassandra-tool
  • Combine TLS config structs into new common auth.TLS
  • Add more TLS options:
    • CaFile
    • EnableHostVerification
    • Remove TLS bundleFile option in favor of caFile option

solve #2681

@CLAassistant
Copy link

CLAassistant commented Nov 6, 2019

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

coveralls commented Nov 6, 2019

Coverage Status

Coverage decreased (-0.002%) to 66.653% when pulling 1d3bde4 on aoby:cassandra-tls-support into 925d24d on uber:master.

Comment on lines 67 to 77
func LoadCassandraSchema(
dir string, fileNames []string, hosts []string, port int, keyspace string, override bool,
dir string, fileNames []string, hosts []string, port int, keyspace string, override bool, useTLS bool, tlsCertPath, tlsKeyPath string,
) (err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

plz format like this:

func LoadCassandraSchema(
	dir string, 
	fileNames []string, 
	hosts []string, 
	port int, 
	keyspace string, 
	override bool, 
	useTLS bool, 
	tlsCertPath string, 
	tlsKeyPath string,
) error {

Copy link
Contributor

Choose a reason for hiding this comment

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

it will be easier to read

Comment on lines +28 to 32
"github.com/uber/cadence/common/cassandra"

"github.com/gocql/gocql"

workflow "github.com/uber/cadence/.gen/go/shared"
Copy link
Contributor

Choose a reason for hiding this comment

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

plz merge from master then do

make fmt

it will sort all imports correctly

Comment on lines 196 to 195
TLS struct {
// Optional path to a TLS client certificate
CertPath string `yaml:"certPath"`
// Optional path to the key file for a TLS client certificate
KeyPath string `yaml:"keyPath"`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put the TLS config in 'common/auth'
and reuse this definition: https://github.com/uber/cadence/blob/master/common/messaging/kafkaConfig.go#L38
?

Comment on lines 52 to 54
UseTLS bool
TLSCertPath string
TLSKeyPath string
Copy link
Contributor

@wxing1292 wxing1292 Nov 6, 2019

Choose a reason for hiding this comment

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

pls use the above TLS config for simplicity, like

CQLClientConfig struct {
		Hosts       string
		Port        int
		User        string
		Password    string
		Keyspace    string
		Timeout     int
		numReplicas int
		TLS         auth.TLS
}

@@ -64,6 +64,18 @@ func newAdminWorkflowCommands() []cli.Command {
Name: FlagKeyspace,
Usage: "cassandra keyspace",
},
cli.BoolFlag{
Name: FlagUseTLS,
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 change this to FlagEnableTLS ?

@wxing1292
Copy link
Contributor

the rest LGTM

Copy link
Contributor

@meiliang86 meiliang86 left a comment

Choose a reason for hiding this comment

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

Looks good overall. Can you address all the comments before merging? Thanks!

"strings"

"github.com/gocql/gocql"

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove extra empty line.

@@ -92,7 +65,7 @@ func DropCassandraKeyspace(s *gocql.Session, keyspace string) (err error) {

// LoadCassandraSchema loads the schema from the given .cql files on this keyspace
func LoadCassandraSchema(
dir string, fileNames []string, hosts []string, port int, keyspace string, override bool,
dir string, fileNames []string, hosts []string, port int, keyspace string, override bool, useTLS bool, tlsCertPath, tlsKeyPath string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this method is only used for testing. Can you make it private?

@aoby
Copy link
Contributor Author

aoby commented Nov 6, 2019

Thanks @wxing1292 and @meiliang86 for the quick feedback!
I made the requested changes.

I realized in local testing that I needed the settings in cadence-cassandra-tool for schema setup, so I added CLI options there as well. I also added settings for the remaining Cassandra tls/ssl options, CaPath and EnableHostVerification.

Please take another look

Comment on lines 34 to 36
BundleFile string `yaml:"bundleFile"`

CaFile string `yaml:caFile` //optional depending on server config
Copy link
Contributor

Choose a reason for hiding this comment

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

these 2 variables are the same. let us keep "CaFile string yaml:caFile" for readability.
but before landing this, let me check with one customer who is already using TLS with kafka

Copy link
Contributor

Choose a reason for hiding this comment

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

plz also do a make fmt locally

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 ran make fmt earlier, and it made some formatting changes (included in the last commit).
I just ran it again with no change. Is there something you expect to be reformatted?

Copy link
Contributor

Choose a reason for hiding this comment

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

one more thing, the Contributor License Agreement does not really recognize your name. one thing you could try is to squash all commits and force push

Copy link
Contributor

Choose a reason for hiding this comment

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

I ran make fmt earlier, and it made some formatting changes (included in the last commit).
I just ran it again with no change. Is there something you expect to be reformatted?

if that is the case, then plz just ignore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

one more thing, the Contributor License Agreement does not really recognize your name. one thing you could try is to squash all commits and force push

I think because I made the first commit from my work account, which is private. I tried to re-author it but that apparently didn't work. I'll try the squash & force push...

 - Consolidate duplicate cassandra setup and config into a new common/cassandra package
 - Add tls support

Address feedback, add more options, add tls flags to cadence-cassandra-tool

 - Combine TLS structs into new common auth.TLS
 - Fix formatting
 - Add more cassandra TLS options:
   - CaFile
   - EnableHostVerification
 - Add TLS CLI flags to cadence-cassandra-tool

Remove empty line, make test method private.
Enabled bool `yaml:"enabled"`
CertFile string `yaml:"certFile"`
KeyFile string `yaml:"keyFile"`
BundleFile string `yaml:"bundleFile"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be a breaking change for users who use TLS in Kafka.
@wxing1292 Do you know if any customer is using this? Can we notice them and get this change in?

Otherwise for safety, I would keep it for kafka, and use the new auth.TLS for Cassandra and everything else.
Or just use the old name "bundleFile"

Copy link
Contributor

Choose a reason for hiding this comment

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

talked to our customer, they are ok

@wxing1292 wxing1292 merged commit e0ef19e into uber:master Nov 7, 2019
@aoby aoby deleted the cassandra-tls-support branch November 13, 2019 18:27
anish531213 pushed a commit to anish531213/cadence that referenced this pull request Nov 18, 2019
* Consolidate duplicate Cassandra setup and config into a new common/cassandra package
* Add TLS support for Cassandra
* Add TLS flags to cadence-cassandra-tool
* Combine TLS config structs into new common auth.TLS
* Add more TLS options:
   - CaFile
   - EnableHostVerification
   - Remove TLS bundleFile option in favor of caFile option
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.

6 participants