Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go/test/endtoend/vtorc/readtopologyinstance/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func TestReadTopologyInstanceBufferable(t *testing.T) {
assert.False(t, primaryInstance.HasReplicationCredentials)
assert.Equal(t, primaryInstance.ReplicationIOThreadState, inst.ReplicationThreadStateNoThread)
assert.Equal(t, primaryInstance.ReplicationSQLThreadState, inst.ReplicationThreadStateNoThread)
assert.Equal(t, fmt.Sprintf("%v:%v", keyspace.Name, shard0.Name), primaryInstance.ClusterName)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This augments the existing ReadTopologyInstanceBufferable end to end test to also verify that we set the cluster_name correctly.


replicaInstance, err := inst.ReadTopologyInstanceBufferable(&inst.InstanceKey{
Hostname: utils.Hostname,
Expand Down Expand Up @@ -168,4 +169,5 @@ func TestReadTopologyInstanceBufferable(t *testing.T) {
assert.False(t, replicaInstance.HasReplicationFilters)
assert.LessOrEqual(t, int(replicaInstance.SecondsBehindPrimary.Int64), 1)
assert.False(t, replicaInstance.AllowTLS)
assert.Equal(t, fmt.Sprintf("%v:%v", keyspace.Name, shard0.Name), replicaInstance.ClusterName)
}
16 changes: 4 additions & 12 deletions go/vt/orchestrator/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
}
case registerCliCommand("reattach-replica-primary-host", "Replication, general", `Undo a detach-replica-primary-host operation`):
{
instanceKey, _ = inst.FigureInstanceKey(instanceKey, thisInstanceKey)
if instanceKey == nil {
log.Fatal("Cannot deduce instance:", instance)
}
_, err := inst.ReattachReplicaPrimaryHost(instanceKey)
if err != nil {
log.Fatal(err)
}
fmt.Println(instanceKey.DisplayString())
fmt.Println("Command deprecated")
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 have removed some API and CLI commands that would have required some changes and that we don't intend to support anyways. I could have removed them as a separate PR, but I elected to do it here as I went along.

}
case registerCliCommand("primary-pos-wait", "Replication, general", `Wait until replica reaches given replication coordinates (--binlog=file:pos)`):
{
Expand Down Expand Up @@ -671,7 +663,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
log.Fatal(err)
}
for _, clusterPoolInstance := range clusterPoolInstances {
fmt.Printf("%s\t%s\t%s\t%s:%d\n", clusterPoolInstance.ClusterName, clusterPoolInstance.ClusterAlias, clusterPoolInstance.Pool, clusterPoolInstance.Hostname, clusterPoolInstance.Port)
fmt.Printf("%s\t%s\t%s:%d\n", clusterPoolInstance.ClusterName, clusterPoolInstance.Pool, clusterPoolInstance.Hostname, clusterPoolInstance.Port)
}
}
case registerCliCommand("which-heuristic-cluster-pool-instances", "Pools", `List instances of a given cluster which are in either any pool or in a specific pool`):
Expand Down Expand Up @@ -731,7 +723,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
log.Fatal(err)
}
for _, cluster := range clusters {
fmt.Printf("%s\t%s\n", cluster.ClusterName, cluster.ClusterAlias)
fmt.Printf("%s\n", cluster.ClusterName)
}
}
case registerCliCommand("all-clusters-primaries", "Information", `List of writeable primaries, one per cluster`):
Expand Down Expand Up @@ -804,7 +796,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatal(err)
}
fmt.Println(clusterInfo.ClusterAlias)
fmt.Println(clusterInfo.ClusterName)
}
case registerCliCommand("which-cluster-domain", "Information", `Output the domain name of the cluster an instance belongs to, or error if unknown to orchestrator`):
{
Expand Down
8 changes: 4 additions & 4 deletions go/vt/orchestrator/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ type Configuration struct {
RecoverPrimaryClusterFilters []string // Only do primary recovery on clusters matching these regexp patterns (of course the ".*" pattern matches everything)
RecoverIntermediatePrimaryClusterFilters []string // Only do IM recovery on clusters matching these regexp patterns (of course the ".*" pattern matches everything)
ProcessesShellCommand string // Shell that executes command scripts
OnFailureDetectionProcesses []string // Processes to execute when detecting a failover scenario (before making a decision whether to failover or not). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterAlias}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {autoPrimaryRecovery}, {autoIntermediatePrimaryRecovery}
PreFailoverProcesses []string // Processes to execute before doing a failover (aborting operation should any once of them exits with non-zero code; order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterAlias}, {failureClusterDomain}, {failedPort}, {countReplicas}, {replicaHosts}, {isDowntimed}
PostFailoverProcesses []string // Processes to execute after doing a failover (order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterAlias}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {isSuccessful}, {lostReplicas}, {countLostReplicas}
PostUnsuccessfulFailoverProcesses []string // Processes to execute after a not-completely-successful failover (order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterAlias}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {isSuccessful}, {lostReplicas}, {countLostReplicas}
OnFailureDetectionProcesses []string // Processes to execute when detecting a failover scenario (before making a decision whether to failover or not). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {autoPrimaryRecovery}, {autoIntermediatePrimaryRecovery}
PreFailoverProcesses []string // Processes to execute before doing a failover (aborting operation should any once of them exits with non-zero code; order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterDomain}, {failedPort}, {countReplicas}, {replicaHosts}, {isDowntimed}
PostFailoverProcesses []string // Processes to execute after doing a failover (order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {isSuccessful}, {lostReplicas}, {countLostReplicas}
PostUnsuccessfulFailoverProcesses []string // Processes to execute after a not-completely-successful failover (order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {isSuccessful}, {lostReplicas}, {countLostReplicas}
PostPrimaryFailoverProcesses []string // Processes to execute after doing a primary failover (order of execution undefined). Uses same placeholders as PostFailoverProcesses
PostIntermediatePrimaryFailoverProcesses []string // Processes to execute after doing a primary failover (order of execution undefined). Uses same placeholders as PostFailoverProcesses
PostTakePrimaryProcesses []string // Processes to execute after a successful Take-Primary event has taken place
Expand Down
15 changes: 0 additions & 15 deletions go/vt/orchestrator/db/generate_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,6 @@ var generateSQLBase = []string{
`
CREATE INDEX resolved_timestamp_idx_hostname_resolve ON hostname_resolve (resolved_timestamp)
`,
`
CREATE TABLE IF NOT EXISTS cluster_alias (
cluster_name varchar(128) CHARACTER SET ascii NOT NULL,
alias varchar(128) NOT NULL,
PRIMARY KEY (cluster_name)
) ENGINE=InnoDB DEFAULT CHARSET=ascii
`,
`
CREATE TABLE IF NOT EXISTS active_node (
anchor tinyint unsigned NOT NULL,
Expand Down Expand Up @@ -425,7 +418,6 @@ var generateSQLBase = []string{
processcing_node_token varchar(128) NOT NULL,
analysis varchar(128) NOT NULL,
cluster_name varchar(128) NOT NULL,
cluster_alias varchar(128) NOT NULL,
count_affected_replicas int unsigned NOT NULL,
replica_hosts text NOT NULL,
PRIMARY KEY (detection_id)
Expand Down Expand Up @@ -736,13 +728,6 @@ var generateSQLBase = []string{
PRIMARY KEY (disable_recovery)
) ENGINE=InnoDB DEFAULT CHARSET=ascii
`,
`
CREATE TABLE IF NOT EXISTS cluster_alias_override (
cluster_name varchar(128) CHARACTER SET ascii NOT NULL,
alias varchar(128) NOT NULL,
PRIMARY KEY (cluster_name)
) ENGINE=InnoDB DEFAULT CHARSET=ascii
`,
`
CREATE TABLE IF NOT EXISTS topology_recovery_steps (
recovery_step_id bigint unsigned not null auto_increment,
Expand Down
26 changes: 0 additions & 26 deletions go/vt/orchestrator/db/generate_patches.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ var generateSQLPatches = []string{
database_instance_maintenance
ADD KEY active_timestamp_idx (maintenance_active, begin_timestamp)
`,
`
ALTER TABLE
cluster_alias
ADD UNIQUE KEY alias_uidx (alias)
`,
`
ALTER TABLE
database_instance
Expand All @@ -122,11 +117,6 @@ var generateSQLPatches = []string{
topology_recovery
ADD COLUMN cluster_name varchar(128) CHARACTER SET ascii NOT NULL
`,
`
ALTER TABLE
topology_recovery
ADD COLUMN cluster_alias varchar(128) CHARACTER SET ascii NOT NULL
`,
`
ALTER TABLE
topology_recovery
Expand Down Expand Up @@ -181,19 +171,6 @@ var generateSQLPatches = []string{
database_instance
ADD COLUMN server_uuid varchar(64) CHARACTER SET ascii NOT NULL AFTER server_id
`,
`
ALTER TABLE
database_instance
ADD COLUMN suggested_cluster_alias varchar(128) CHARACTER SET ascii NOT NULL AFTER cluster_name
`,
`
ALTER TABLE cluster_alias
ADD COLUMN last_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
`,
`
ALTER TABLE cluster_alias
ADD KEY last_registered_idx (last_registered)
`,
`
ALTER TABLE
topology_recovery
Expand Down Expand Up @@ -454,9 +431,6 @@ var generateSQLPatches = []string{
`
CREATE INDEX end_timestamp_idx_database_instance_downtime ON database_instance_downtime(end_timestamp)
`,
`
CREATE INDEX suggested_cluster_alias_idx_database_instance ON database_instance(suggested_cluster_alias)
`,
`
ALTER TABLE
topology_failure_detection
Expand Down
86 changes: 12 additions & 74 deletions go/vt/orchestrator/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,26 +620,8 @@ func (httpAPI *API) DetachReplicaPrimaryHost(params martini.Params, r render.Ren
Respond(r, &APIResponse{Code: OK, Message: fmt.Sprintf("Replica detached: %+v", instance.Key), Details: instance})
}

// ReattachReplicaPrimaryHost reverts a detachReplicaPrimaryHost command
// by resetting the original primary hostname in CHANGE MASTER TO
func (httpAPI *API) ReattachReplicaPrimaryHost(params martini.Params, r render.Render, req *http.Request, user auth.User) {
if !isAuthorizedForAction(req, user) {
Respond(r, &APIResponse{Code: ERROR, Message: "Unauthorized"})
return
}
instanceKey, err := httpAPI.getInstanceKey(params["host"], params["port"])

if err != nil {
Respond(r, &APIResponse{Code: ERROR, Message: err.Error()})
return
}
instance, err := inst.ReattachReplicaPrimaryHost(&instanceKey)
if err != nil {
Respond(r, &APIResponse{Code: ERROR, Message: err.Error()})
return
}

Respond(r, &APIResponse{Code: OK, Message: fmt.Sprintf("Replica reattached: %+v", instance.Key), Details: instance})
func (httpAPI *API) NoOp(params martini.Params, r render.Render, req *http.Request, user auth.User) {
Respond(r, &APIResponse{Code: OK, Message: "API Deprecated"})
}

// EnableGTID attempts to enable GTID on a replica
Expand Down Expand Up @@ -1375,13 +1357,7 @@ func (httpAPI *API) Cluster(params martini.Params, r render.Render, req *http.Re

// ClusterByAlias provides list of instances in given cluster
func (httpAPI *API) ClusterByAlias(params martini.Params, r render.Render, req *http.Request) {
clusterName, err := inst.GetClusterByAlias(params["clusterAlias"])
if err != nil {
Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}

params["clusterName"] = clusterName
params["clusterName"] = params["clusterAlias"]
httpAPI.Cluster(params, r, req)
}

Expand Down Expand Up @@ -1421,13 +1397,7 @@ func (httpAPI *API) ClusterInfo(params martini.Params, r render.Render, req *htt

// Cluster provides list of instances in given cluster
func (httpAPI *API) ClusterInfoByAlias(params martini.Params, r render.Render, req *http.Request) {
clusterName, err := inst.GetClusterByAlias(params["clusterAlias"])
if err != nil {
Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}

params["clusterName"] = clusterName
params["clusterName"] = params["clusterAlias"]
httpAPI.ClusterInfo(params, r, req)
}

Expand All @@ -1448,29 +1418,6 @@ func (httpAPI *API) ClusterOSCReplicas(params martini.Params, r render.Render, r
r.JSON(http.StatusOK, instances)
}

// SetClusterAlias will change an alias for a given clustername
func (httpAPI *API) SetClusterAliasManualOverride(params martini.Params, r render.Render, req *http.Request, user auth.User) {
if !isAuthorizedForAction(req, user) {
Respond(r, &APIResponse{Code: ERROR, Message: "Unauthorized"})
return
}
clusterName := params["clusterName"]
alias := req.URL.Query().Get("alias")

var err error
if orcraft.IsRaftEnabled() {
_, err = orcraft.PublishCommand("set-cluster-alias-manual-override", []string{clusterName, alias})
} else {
err = inst.SetClusterAliasManualOverride(clusterName, alias)
}

if err != nil {
Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}
Respond(r, &APIResponse{Code: OK, Message: fmt.Sprintf("Cluster %s now has alias '%s'", clusterName, alias)})
}

// Clusters provides list of known clusters
func (httpAPI *API) Clusters(params martini.Params, r render.Render, req *http.Request) {
clusterNames, err := inst.ReadClusters()
Expand Down Expand Up @@ -1878,11 +1825,7 @@ func (httpAPI *API) GetHeuristicClusterPoolInstancesLag(params martini.Params, r
Respond(r, &APIResponse{Code: ERROR, Message: "Unauthorized"})
return
}
clusterName, err := inst.ReadClusterNameByAlias(params["clusterName"])
if err != nil {
Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}
clusterName := params["clusterName"]
pool := params["pool"]

lag, err := inst.GetHeuristicClusterPoolInstancesLag(clusterName, pool)
Expand Down Expand Up @@ -2199,12 +2142,7 @@ func (httpAPI *API) ReplicationAnalysis(params martini.Params, r render.Render,

// ReplicationAnalysis retuens list of issues
func (httpAPI *API) ReplicationAnalysisForCluster(params martini.Params, r render.Render, req *http.Request) {
var clusterName string
var err error
if clusterName, err = inst.DeduceClusterName(params["clusterName"]); err != nil {
Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("Cannot get analysis: %+v", err)})
return
}
clusterName := params["clusterName"]
if clusterName == "" {
Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("Cannot get cluster name: %+v", params["clusterName"])})
return
Expand Down Expand Up @@ -2415,7 +2353,7 @@ func (httpAPI *API) AuditFailureDetection(params martini.Params, r render.Render
if derr != nil || page < 0 {
page = 0
}
audits, err = logic.ReadRecentFailureDetections(params["clusterAlias"], page)
audits, err = logic.ReadRecentFailureDetections(params["clusterName"], page)
}

if err != nil {
Expand Down Expand Up @@ -2467,7 +2405,7 @@ func (httpAPI *API) AuditRecovery(params martini.Params, r render.Render, req *h
}
unacknowledgedOnly := (req.URL.Query().Get("unacknowledged") == "true")

audits, err = logic.ReadRecentRecoveries(params["clusterName"], params["clusterAlias"], unacknowledgedOnly, page)
audits, err = logic.ReadRecentRecoveries(params["clusterName"], unacknowledgedOnly, page)
}

if err != nil {
Expand Down Expand Up @@ -2530,7 +2468,7 @@ func (httpAPI *API) AcknowledgeClusterRecoveries(params martini.Params, r render
var clusterName string
var err error
if params["clusterAlias"] != "" {
clusterName, err = inst.GetClusterByAlias(params["clusterAlias"])
clusterName = params["clusterAlias"]
} else {
clusterName, err = figureClusterName(getClusterHint(params))
}
Expand Down Expand Up @@ -2813,9 +2751,9 @@ func (httpAPI *API) RegisterRequests(m *martini.ClassicMartini) {
httpAPI.registerAPIRequest(m, "stop-replica-nice/:host/:port", httpAPI.StopReplicationNicely)
httpAPI.registerAPIRequest(m, "reset-replica/:host/:port", httpAPI.ResetReplication)
httpAPI.registerAPIRequest(m, "detach-replica/:host/:port", httpAPI.DetachReplicaPrimaryHost)
httpAPI.registerAPIRequest(m, "reattach-replica/:host/:port", httpAPI.ReattachReplicaPrimaryHost)
httpAPI.registerAPIRequest(m, "reattach-replica/:host/:port", httpAPI.NoOp)
httpAPI.registerAPIRequest(m, "detach-replica-primary-host/:host/:port", httpAPI.DetachReplicaPrimaryHost)
httpAPI.registerAPIRequest(m, "reattach-replica-primary-host/:host/:port", httpAPI.ReattachReplicaPrimaryHost)
httpAPI.registerAPIRequest(m, "reattach-replica-primary-host/:host/:port", httpAPI.NoOp)
httpAPI.registerAPIRequest(m, "flush-binary-logs/:host/:port", httpAPI.FlushBinaryLogs)
httpAPI.registerAPIRequest(m, "purge-binary-logs/:host/:port/:logFile", httpAPI.PurgeBinaryLogs)
httpAPI.registerAPIRequest(m, "restart-replica-statements/:host/:port", httpAPI.RestartReplicationStatements)
Expand Down Expand Up @@ -2849,7 +2787,7 @@ func (httpAPI *API) RegisterRequests(m *martini.ClassicMartini) {
httpAPI.registerAPIRequest(m, "cluster-info/:clusterHint", httpAPI.ClusterInfo)
httpAPI.registerAPIRequest(m, "cluster-info/alias/:clusterAlias", httpAPI.ClusterInfoByAlias)
httpAPI.registerAPIRequest(m, "cluster-osc-replicas/:clusterHint", httpAPI.ClusterOSCReplicas)
httpAPI.registerAPIRequest(m, "set-cluster-alias/:clusterName", httpAPI.SetClusterAliasManualOverride)
httpAPI.registerAPIRequest(m, "set-cluster-alias/:clusterName", httpAPI.NoOp)
httpAPI.registerAPIRequest(m, "clusters", httpAPI.Clusters)
httpAPI.registerAPIRequest(m, "clusters-info", httpAPI.ClustersInfo)

Expand Down
9 changes: 1 addition & 8 deletions go/vt/orchestrator/http/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,7 @@ func (httpWeb *Web) Cluster(params martini.Params, r render.Render, req *http.Re
}

func (httpWeb *Web) ClusterByAlias(params martini.Params, r render.Render, req *http.Request, user auth.User) {
clusterName, err := inst.GetClusterByAlias(params["clusterAlias"])
// Willing to accept the case of multiple clusters; we just present one
if clusterName == "" && err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}

params["clusterName"] = clusterName
params["clusterName"] = params["clusterAlias"]
httpWeb.Cluster(params, r, req, user)
}

Expand Down
1 change: 0 additions & 1 deletion go/vt/orchestrator/inst/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ type ReplicationAnalysis struct {
AnalyzedInstancePrimaryKey InstanceKey
TabletType topodatapb.TabletType
PrimaryTimeStamp time.Time
SuggestedClusterAlias string
ClusterDetails ClusterInfo
AnalyzedInstanceDataCenter string
AnalyzedInstanceRegion string
Expand Down
Loading