Skip to content

Commit

Permalink
[#20406] yugabyted: Fix yugabyted-ui when given custom YSQL and YCQL …
Browse files Browse the repository at this point in the history
…ports

Summary:
Fixes an issue where yugabyted-ui breaks when yugabyted is given custom values for `ysql_port` and `ycql_port`.
This happens because the values aren't passed to yugabyted-ui.
The fix involves adding a new flag to yugabyted-ui for the YCQL port number, and also changing yugabyted to pass the values to yugabyted-ui
Jira: DB-9402

Test Plan: no test plan

Reviewers: sgarg-yb, nikhil

Reviewed By: nikhil

Subscribers: yugabyted-dev, djiang

Differential Revision: https://phorge.dev.yugabyte.com/D31585
  • Loading branch information
Daniel Jiang committed Jan 16, 2024
1 parent c93ccda commit 85283b1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions bin/yugabyted
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,13 @@ class ControlScript(object):
"-database_password={}".format(
self.configs.saved_data.get("database_password"))])

if self.configs.saved_data.get("ysql_port"):
yugabyted_ui_cmd.append("-ysql_port={}".format(
self.configs.saved_data.get("ysql_port")))
if self.configs.saved_data.get("ycql_port"):
yugabyted_ui_cmd.append("-ycql_port={}".format(
self.configs.saved_data.get("ycql_port")))

self.processes["yugabyted-ui"] = ProcessManager(
"yugabyted-ui", yugabyted_ui_cmd,
self.configs.saved_data.get("log_dir"),
Expand Down
2 changes: 1 addition & 1 deletion yugabyted-ui/apiserver/cmd/server/handlers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (c *Container) GetConnectionFromMap(host string, database ...string) (*pgxp
User: helpers.DbYsqlUser,
Password: helpers.DbPassword,
Host: host,
Port: helpers.PORT,
Port: helpers.YsqlPort,
Database: dbName,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type PgClientConnectionParams struct {
func (h *HelperContainer) CreateGoCqlClient(log logger.Logger) *gocql.ClusterConfig {

// Initialize gocql client
cluster := gocql.NewCluster(HOST)
cluster := gocql.NewCluster(fmt.Sprintf("%s:%d", HOST, YcqlPort))

if Secure {
cluster.Authenticator = gocql.PasswordAuthenticator{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (

var (
HOST string
PORT int
YsqlPort int
YcqlPort int
Secure bool
DbName string
DbYsqlUser string
Expand All @@ -22,7 +23,8 @@ var (
func init() {
flag.StringVar(&HOST, "database_host", "127.0.0.1",
"Advertise address of the local YugabyteDB node.")
flag.IntVar(&PORT, "database_port", 5433, "YSQL port.")
flag.IntVar(&YsqlPort, "ysql_port", 5433, "YSQL port.")
flag.IntVar(&YcqlPort, "ycql_port", 9042, "YCQL port.")
flag.BoolVar(&Secure, "secure", false, "API server use secure or insecure mode.")
flag.StringVar(&DbName, "database_name", "yugabyte", "database for retrieving metrics.")
flag.StringVar(&DbYsqlUser, "ysql_username", "yugabyte",
Expand Down

0 comments on commit 85283b1

Please sign in to comment.