Skip to content
Closed
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
14 changes: 7 additions & 7 deletions go/vt/orchestrator/agent/agent_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func GetAgent(hostname string) (Agent, error) {
mySQLRunningUri := fmt.Sprintf("%s/mysql-status?token=%s", uri, token)
body, err := readResponse(httpGet(mySQLRunningUri))
if err == nil {
err = json.Unmarshal(body, &agent.MySQLRunning)
_ = json.Unmarshal(body, &agent.MySQLRunning)
}
// Actually an error is OK here since "status" returns with non-zero exit code when MySQL not running
}
Expand Down Expand Up @@ -702,8 +702,8 @@ func executeSeed(seedId int64, targetHostname string, sourceHostname string) err
if err != nil {
return updateSeedStateEntry(seedStateId, err)
}
sourceAgent, err = GetAgent(sourceHostname)
seedStateId, _ = submitSeedStateEntry(seedId, fmt.Sprintf("MySQL data volume on source host %s is %d bytes", sourceHostname, sourceAgent.MountPoint.MySQLDiskUsage), "")
sourceAgent, _ = GetAgent(sourceHostname)
_, _ = submitSeedStateEntry(seedId, fmt.Sprintf("MySQL data volume on source host %s is %d bytes", sourceHostname, sourceAgent.MountPoint.MySQLDiskUsage), "")

seedStateId, _ = submitSeedStateEntry(seedId, fmt.Sprintf("Erasing MySQL data on %s", targetHostname), "")
_, err = deleteMySQLDatadir(targetHostname)
Expand All @@ -723,10 +723,10 @@ func executeSeed(seedId int64, targetHostname string, sourceHostname string) err
}

// ...
seedStateId, _ = submitSeedStateEntry(seedId, fmt.Sprintf("%s will now receive data in background", targetHostname), "")
_, _ = submitSeedStateEntry(seedId, fmt.Sprintf("%s will now receive data in background", targetHostname), "")
ReceiveMySQLSeedData(targetHostname, seedId)

seedStateId, _ = submitSeedStateEntry(seedId, fmt.Sprintf("Waiting %d seconds for %s to start listening for incoming data", config.Config.SeedWaitSecondsBeforeSend, targetHostname), "")
_, _ = submitSeedStateEntry(seedId, fmt.Sprintf("Waiting %d seconds for %s to start listening for incoming data", config.Config.SeedWaitSecondsBeforeSend, targetHostname), "")
time.Sleep(time.Duration(config.Config.SeedWaitSecondsBeforeSend) * time.Second)

seedStateId, _ = submitSeedStateEntry(seedId, fmt.Sprintf("%s will now send data to %s in background", sourceHostname, targetHostname), "")
Expand Down Expand Up @@ -795,10 +795,10 @@ func executeSeed(seedId int64, targetHostname string, sourceHostname string) err
return updateSeedStateEntry(seedStateId, err)
}

seedStateId, _ = submitSeedStateEntry(seedId, fmt.Sprintf("Submitting MySQL instance for discovery: %s", targetHostname), "")
_, _ = submitSeedStateEntry(seedId, fmt.Sprintf("Submitting MySQL instance for discovery: %s", targetHostname), "")
SeededAgents <- &targetAgent

seedStateId, _ = submitSeedStateEntry(seedId, "Done", "")
_, _ = submitSeedStateEntry(seedId, "Done", "")

return nil
}
Expand Down
61 changes: 27 additions & 34 deletions go/vt/orchestrator/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ func getClusterName(clusterAlias string, instanceKey *inst.InstanceKey) (cluster
return clusterName
}

func assignThisInstanceKey() *inst.InstanceKey {
log.Debugf("Assuming instance is this machine, %+v", thisInstanceKey)
return thisInstanceKey
}

func validateInstanceIsFound(instanceKey *inst.InstanceKey) (instance *inst.Instance) {
instance, _, err := inst.ReadInstance(instanceKey)
if err != nil {
Expand Down Expand Up @@ -227,7 +222,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), destinationKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), destinationKey.DisplayString())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Out of curiosity, were these changes automated by some tool? If so, which and how?

}
case registerCliCommand("relocate-replicas", "Smart relocation", `Relocates all or part of the replicas of a given instance under another instance`):
{
Expand Down Expand Up @@ -274,8 +269,8 @@ func Cli(command string, strict bool, instance string, destination string, owner
if promotedReplica == nil {
log.Fatalf("Could not regroup replicas of %+v; error: %+v", *instanceKey, err)
}
fmt.Println(fmt.Sprintf("%s lost: %d, trivial: %d, pseudo-gtid: %d",
promotedReplica.Key.DisplayString(), len(lostReplicas), len(equalReplicas), len(aheadReplicas)))
fmt.Printf("%s lost: %d, trivial: %d, pseudo-gtid: %d\n",
promotedReplica.Key.DisplayString(), len(lostReplicas), len(equalReplicas), len(aheadReplicas))
if err != nil {
log.Fatale(err)
}
Expand All @@ -289,7 +284,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), instance.MasterKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), instance.MasterKey.DisplayString())
}
case registerCliCommand("move-up-replicas", "Classic file:pos relocation", `Moves replicas of the given instance one level up the topology`):
{
Expand Down Expand Up @@ -320,7 +315,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), destinationKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), destinationKey.DisplayString())
}
case registerCliCommand("move-equivalent", "Classic file:pos relocation", `Moves a replica beneath another server, based on previously recorded "equivalence coordinates"`):
{
Expand All @@ -332,7 +327,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), destinationKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), destinationKey.DisplayString())
}
case registerCliCommand("repoint", "Classic file:pos relocation", `Make the given instance replicate from another instance without changing the binglog coordinates. Use with care`):
{
Expand All @@ -342,7 +337,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), instance.MasterKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), instance.MasterKey.DisplayString())
}
case registerCliCommand("repoint-replicas", "Classic file:pos relocation", `Repoint all replicas of given instance to replicate back from the instance. Use with care`):
{
Expand All @@ -355,7 +350,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
log.Errore(e)
}
for _, replica := range repointedReplicas {
fmt.Println(fmt.Sprintf("%s<%s", replica.Key.DisplayString(), instanceKey.DisplayString()))
fmt.Printf("%s<%s\n", replica.Key.DisplayString(), instanceKey.DisplayString())
}
}
}
Expand Down Expand Up @@ -422,7 +417,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), destinationKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), destinationKey.DisplayString())
}
case registerCliCommand("move-replicas-gtid", "GTID relocation", `Moves all replicas of a given instance under another (destination) instance using GTID`):
{
Expand Down Expand Up @@ -456,8 +451,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if promotedReplica == nil {
log.Fatalf("Could not regroup replicas of %+v; error: %+v", *instanceKey, err)
}
fmt.Println(fmt.Sprintf("%s lost: %d, moved: %d",
promotedReplica.Key.DisplayString(), len(lostReplicas), len(movedReplicas)))
fmt.Printf("%s lost: %d, moved: %d\n", promotedReplica.Key.DisplayString(), len(lostReplicas), len(movedReplicas))
if err != nil {
log.Fatale(err)
}
Expand All @@ -473,7 +467,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), destinationKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), destinationKey.DisplayString())
}
case registerCliCommand("match-up", "Pseudo-GTID relocation", `Transport the replica one level up the hierarchy, making it child of its grandparent, using Pseudo-GTID`):
{
Expand All @@ -482,7 +476,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), instance.MasterKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), instance.MasterKey.DisplayString())
}
case registerCliCommand("rematch", "Pseudo-GTID relocation", `Reconnect a replica onto its master, via PSeudo-GTID.`):
{
Expand All @@ -491,7 +485,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%s<%s", instanceKey.DisplayString(), instance.MasterKey.DisplayString()))
fmt.Printf("%s<%s\n", instanceKey.DisplayString(), instance.MasterKey.DisplayString())
}
case registerCliCommand("match-replicas", "Pseudo-GTID relocation", `Matches all replicas of a given instance under another (destination) instance using Pseudo-GTID`):
{
Expand Down Expand Up @@ -550,8 +544,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if promotedReplica == nil {
log.Fatalf("Could not regroup replicas of %+v; error: %+v", *instanceKey, err)
}
fmt.Println(fmt.Sprintf("%s lost: %d, trivial: %d, pseudo-gtid: %d",
promotedReplica.Key.DisplayString(), len(lostReplicas), len(equalReplicas), len(aheadReplicas)))
fmt.Printf("%s lost: %d, trivial: %d, pseudo-gtid: %d\n", promotedReplica.Key.DisplayString(), len(lostReplicas), len(equalReplicas), len(aheadReplicas))
if err != nil {
log.Fatale(err)
}
Expand Down Expand Up @@ -844,7 +837,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%+v:%s", *coordinates, text))
fmt.Printf("%+v:%s\n", *coordinates, text)
}
case registerCliCommand("locate-gtid-errant", "Binary logs", `List binary logs containing errant GTIDs`):
{
Expand Down Expand Up @@ -881,7 +874,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%+v:%d", *binlogEvent, binlogEvent.NextEventPos))
fmt.Printf("%+v:%d\n", *binlogEvent, binlogEvent.NextEventPos)
}
case registerCliCommand("correlate-relaylog-pos", "Binary logs", `Given an instance (-i) and relaylog coordinates (--binlog=file:pos), find the correlated coordinates in another instance's relay logs (-d)`):
{
Expand Down Expand Up @@ -917,7 +910,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%+v;%+v;%+v", *instanceCoordinates, *correlatedCoordinates, *nextCoordinates))
fmt.Printf("%+v;%+v;%+v\n", *instanceCoordinates, *correlatedCoordinates, *nextCoordinates)
}
case registerCliCommand("find-binlog-entry", "Binary logs", `Get binlog file:pos of entry given by --pattern (exact full match, not a regular expression) in a given instance`):
{
Expand All @@ -939,7 +932,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%+v", *coordinates))
fmt.Printf("%+v\n", *coordinates)
}
case registerCliCommand("correlate-binlog-pos", "Binary logs", `Given an instance (-i) and binlog coordinates (--binlog=file:pos), find the correlated coordinates in another instance (-d)`):
{
Expand Down Expand Up @@ -980,7 +973,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%+v", *coordinates))
fmt.Printf("%+v\n", *coordinates)
}
// Pool
case registerCliCommand("submit-pool-instances", "Pools", `Submit a pool name with a list of instances in that pool`):
Expand All @@ -1000,7 +993,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
log.Fatale(err)
}
for _, clusterPoolInstance := range clusterPoolInstances {
fmt.Println(fmt.Sprintf("%s\t%s\t%s\t%s:%d", clusterPoolInstance.ClusterName, clusterPoolInstance.ClusterAlias, clusterPoolInstance.Pool, clusterPoolInstance.Hostname, clusterPoolInstance.Port))
fmt.Printf("%s\t%s\t%s\t%s:%d\n", clusterPoolInstance.ClusterName, clusterPoolInstance.ClusterAlias, 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 @@ -1060,7 +1053,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
log.Fatale(err)
}
for _, cluster := range clusters {
fmt.Println(fmt.Sprintf("%s\t%s", cluster.ClusterName, cluster.ClusterAlias))
fmt.Printf("%s\t%s\n", cluster.ClusterName, cluster.ClusterAlias)
}
}
case registerCliCommand("all-clusters-masters", "Information", `List of writeable masters, one per cluster`):
Expand Down Expand Up @@ -1272,7 +1265,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
log.Fatale(err)
}
for _, kvPair := range kvPairs {
fmt.Println(fmt.Sprintf("%s:%s", kvPair.Key, kvPair.Value))
fmt.Printf("%s:%s\n", kvPair.Key, kvPair.Value)
}
}

Expand Down Expand Up @@ -1544,7 +1537,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
log.Fatale(err)
}
for _, entry := range analysis {
fmt.Println(fmt.Sprintf("%s (cluster %s): %s", entry.AnalyzedInstanceKey.DisplayString(), entry.ClusterDetails.ClusterName, entry.AnalysisString()))
fmt.Printf("%s (cluster %s): %s\n", entry.AnalyzedInstanceKey.DisplayString(), entry.ClusterDetails.ClusterName, entry.AnalysisString())
}
}
case registerCliCommand("ack-all-recoveries", "Recovery", `Acknowledge all recoveries; this unblocks pending future recoveries`):
Expand All @@ -1556,7 +1549,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%d recoveries acknowldged", countRecoveries))
fmt.Printf("%d recoveries acknowldged\n", countRecoveries)
}
case registerCliCommand("ack-cluster-recoveries", "Recovery", `Acknowledge recoveries for a given cluster; this unblocks pending future recoveries`):
{
Expand All @@ -1568,7 +1561,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%d recoveries acknowldged", countRecoveries))
fmt.Printf("%d recoveries acknowldged\n", countRecoveries)
}
case registerCliCommand("ack-instance-recoveries", "Recovery", `Acknowledge recoveries for a given instance; this unblocks pending future recoveries`):
{
Expand All @@ -1581,7 +1574,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
if err != nil {
log.Fatale(err)
}
fmt.Println(fmt.Sprintf("%d recoveries acknowldged", countRecoveries))
fmt.Printf("%d recoveries acknowldged\n", countRecoveries)
}
// Instance meta
case registerCliCommand("register-candidate", "Instance, meta", `Indicate that a specific instance is a preferred candidate for master promotion`):
Expand Down Expand Up @@ -1787,7 +1780,7 @@ func Cli(command string, strict bool, instance string, destination string, owner
// Help
case "help":
{
fmt.Fprintf(os.Stderr, availableCommandsUsage())
fmt.Fprint(os.Stderr, availableCommandsUsage())
}
default:
log.Fatalf("Unknown command: \"%s\". %s", command, availableCommandsUsage())
Expand Down
3 changes: 1 addition & 2 deletions go/vt/orchestrator/app/command_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,5 @@ func init() {
}

func HelpCommand(command string) {
fmt.Println(
fmt.Sprintf("%s:\n%s", command, CommandHelp[command]))
fmt.Printf("%s:\n%s\n", command, CommandHelp[command])
}
2 changes: 1 addition & 1 deletion go/vt/orchestrator/app/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var discoveryMetrics *collection.Collection
// Http starts serving
func Http(continuousDiscovery bool) {
promptForSSLPasswords()
process.ContinuousRegistration(process.OrchestratorExecutionHttpMode, "")
process.ContinuousRegistration(string(process.OrchestratorExecutionHttpMode), "")

martini.Env = martini.Prod
if config.Config.ServeAgentsHttp {
Expand Down
21 changes: 0 additions & 21 deletions go/vt/orchestrator/attributes/attributes_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,14 @@
package attributes

import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"strings"

"vitess.io/vitess/go/vt/orchestrator/db"
"vitess.io/vitess/go/vt/orchestrator/external/golib/log"
"vitess.io/vitess/go/vt/orchestrator/external/golib/sqlutils"
)

func readResponse(res *http.Response, err error) ([]byte, error) {
if err != nil {
return nil, err
}

defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}

if res.Status == "500" {
return body, errors.New("Response Status 500")
}

return body, nil
}

// SetHostAttributes
func SetHostAttributes(hostname string, attributeName string, attributeValue string) error {
_, err := db.ExecOrchestrator(`
Expand Down
4 changes: 2 additions & 2 deletions go/vt/orchestrator/collection/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ func (c *Collection) Append(m Metric) error {
if c == nil {
return errors.New("Collection.Append: c == nil")
}
c.Lock()
defer c.Unlock()
c.Lock() //nolint SA5011: possible nil pointer dereference
defer c.Unlock() //nolint SA5011: possible nil pointer dereference

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

possible nil pointer dereference

incorrect. bad linter ☝️

// we don't want to add nil metrics
if c == nil {
return errors.New("Collection.Append: c == nil")
Expand Down
23 changes: 0 additions & 23 deletions go/vt/orchestrator/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,6 @@ const (
SelectTrueQuery = "select 1"
)

var deprecatedConfigurationVariables = []string{
"DatabaselessMode__experimental",
"BufferBinlogEvents",
"BinlogFileHistoryDays",
"MaintenanceOwner",
"ReadLongRunningQueries",
"DiscoveryPollSeconds",
"ActiveNodeExpireSeconds",
"AuditPageSize",
"SlaveStartPostWaitMilliseconds",
"MySQLTopologyMaxPoolConnections",
"MaintenancePurgeDays",
"MaintenanceExpireMinutes",
"HttpTimeoutSeconds",
"AgentAutoDiscover",
"PseudoGTIDCoordinatesHistoryHeuristicMinutes",
"PseudoGTIDPreferIndependentMultiMatch",
"MaxOutdatedKeysToShow",
}

// Configuration makes for orchestrator configuration input, which can be provided by user via JSON formatted file.
// Some of the parameteres have reasonable default values, and some (like database credentials) are
// strictly expected from user.
Expand Down Expand Up @@ -547,9 +527,6 @@ func (this *Configuration) postReadAdjustments() error {
if this.IsSQLite() && this.SQLite3DataFile == "" {
return fmt.Errorf("SQLite3DataFile must be set when BackendDB is sqlite3")
}
if this.IsSQLite() {
// this.HostnameResolveMethod = "none"
}
if this.RaftEnabled && this.RaftDataDir == "" {
return fmt.Errorf("RaftDataDir must be defined since raft is enabled (RaftEnabled)")
}
Expand Down
Loading