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

fixed orchestrator govet errors #6781

Merged
merged 1 commit into from
Sep 24, 2020
Merged
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
fixed orchestrator govet errors
Signed-off-by: Shlomi Noach <[email protected]>
shlomi-noach committed Sep 24, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2964d682b440a939b67ed8f78d3708d10a1acf2f
4 changes: 2 additions & 2 deletions go/vt/orchestrator/http/api.go
Original file line number Diff line number Diff line change
@@ -3219,7 +3219,7 @@ func (this *HttpAPI) AutomatedRecoveryFilters(params martini.Params, r render.Re
// AuditFailureDetection provides list of topology_failure_detection entries
func (this *HttpAPI) AuditFailureDetection(params martini.Params, r render.Render, req *http.Request) {

var audits []logic.TopologyRecovery
var audits []*logic.TopologyRecovery
var err error

if detectionId, derr := strconv.ParseInt(params["id"], 10, 0); derr == nil && detectionId > 0 {
@@ -3267,7 +3267,7 @@ func (this *HttpAPI) ReadReplicationAnalysisChangelog(params martini.Params, r r

// AuditRecovery provides list of topology-recovery entries
func (this *HttpAPI) AuditRecovery(params martini.Params, r render.Render, req *http.Request) {
var audits []logic.TopologyRecovery
var audits []*logic.TopologyRecovery
var err error

if recoveryUID := params["uid"]; recoveryUID != "" {
40 changes: 20 additions & 20 deletions go/vt/orchestrator/logic/topology_recovery_dao.go
Original file line number Diff line number Diff line change
@@ -268,8 +268,8 @@ func ClearActiveRecoveries() error {

// RegisterBlockedRecoveries writes down currently blocked recoveries, and indicates what recovery they are blocked on.
// Recoveries are blocked thru the in_active_period flag, which comes to avoid flapping.
func RegisterBlockedRecoveries(analysisEntry *inst.ReplicationAnalysis, blockingRecoveries []TopologyRecovery) error {
for _, recovery := range blockingRecoveries { //nolint:govet
func RegisterBlockedRecoveries(analysisEntry *inst.ReplicationAnalysis, blockingRecoveries []*TopologyRecovery) error {
for _, recovery := range blockingRecoveries {
_, err := db.ExecOrchestrator(`
insert
into blocked_topology_recovery (
@@ -502,8 +502,8 @@ func writeResolveRecovery(topologyRecovery *TopologyRecovery) error {
}

// readRecoveries reads recovery entry/audit entries from topology_recovery
func readRecoveries(whereCondition string, limit string, args []interface{}) ([]TopologyRecovery, error) {
res := []TopologyRecovery{}
func readRecoveries(whereCondition string, limit string, args []interface{}) ([]*TopologyRecovery, error) {
res := []*TopologyRecovery{}
query := fmt.Sprintf(`
select
recovery_id,
@@ -578,15 +578,15 @@ func readRecoveries(whereCondition string, limit string, args []interface{}) ([]

topologyRecovery.LastDetectionId = m.GetInt64("last_detection_id")

res = append(res, topologyRecovery) //nolint:govet
res = append(res, &topologyRecovery)
return nil
})

return res, log.Errore(err)
}

// ReadActiveRecoveries reads active recovery entry/audit entries from topology_recovery
func ReadActiveClusterRecovery(clusterName string) ([]TopologyRecovery, error) {
func ReadActiveClusterRecovery(clusterName string) ([]*TopologyRecovery, error) {
whereClause := `
where
in_active_period=1
@@ -597,7 +597,7 @@ func ReadActiveClusterRecovery(clusterName string) ([]TopologyRecovery, error) {

// ReadInActivePeriodClusterRecovery reads recoveries (possibly complete!) that are in active period.
// (may be used to block further recoveries on this cluster)
func ReadInActivePeriodClusterRecovery(clusterName string) ([]TopologyRecovery, error) {
func ReadInActivePeriodClusterRecovery(clusterName string) ([]*TopologyRecovery, error) {
whereClause := `
where
in_active_period=1
@@ -606,7 +606,7 @@ func ReadInActivePeriodClusterRecovery(clusterName string) ([]TopologyRecovery,
}

// ReadRecentlyActiveClusterRecovery reads recently completed entries for a given cluster
func ReadRecentlyActiveClusterRecovery(clusterName string) ([]TopologyRecovery, error) {
func ReadRecentlyActiveClusterRecovery(clusterName string) ([]*TopologyRecovery, error) {
whereClause := `
where
end_recovery > now() - interval 5 minute
@@ -616,7 +616,7 @@ func ReadRecentlyActiveClusterRecovery(clusterName string) ([]TopologyRecovery,

// ReadInActivePeriodSuccessorInstanceRecovery reads completed recoveries for a given instance, where said instance
// was promoted as result, still in active period (may be used to block further recoveries should this instance die)
func ReadInActivePeriodSuccessorInstanceRecovery(instanceKey *inst.InstanceKey) ([]TopologyRecovery, error) {
func ReadInActivePeriodSuccessorInstanceRecovery(instanceKey *inst.InstanceKey) ([]*TopologyRecovery, error) {
whereClause := `
where
in_active_period=1
@@ -626,7 +626,7 @@ func ReadInActivePeriodSuccessorInstanceRecovery(instanceKey *inst.InstanceKey)
}

// ReadRecentlyActiveInstanceRecovery reads recently completed entries for a given instance
func ReadRecentlyActiveInstanceRecovery(instanceKey *inst.InstanceKey) ([]TopologyRecovery, error) {
func ReadRecentlyActiveInstanceRecovery(instanceKey *inst.InstanceKey) ([]*TopologyRecovery, error) {
whereClause := `
where
end_recovery > now() - interval 5 minute
@@ -636,7 +636,7 @@ func ReadRecentlyActiveInstanceRecovery(instanceKey *inst.InstanceKey) ([]Topolo
}

// ReadActiveRecoveries reads active recovery entry/audit entries from topology_recovery
func ReadActiveRecoveries() ([]TopologyRecovery, error) {
func ReadActiveRecoveries() ([]*TopologyRecovery, error) {
return readRecoveries(`
where
in_active_period=1
@@ -645,27 +645,27 @@ func ReadActiveRecoveries() ([]TopologyRecovery, error) {
}

// ReadCompletedRecoveries reads completed recovery entry/audit entries from topology_recovery
func ReadCompletedRecoveries(page int) ([]TopologyRecovery, error) {
func ReadCompletedRecoveries(page int) ([]*TopologyRecovery, error) {
limit := `
limit ?
offset ?`
return readRecoveries(`where end_recovery is not null`, limit, sqlutils.Args(config.AuditPageSize, page*config.AuditPageSize))
}

// ReadRecovery reads completed recovery entry/audit entries from topology_recovery
func ReadRecovery(recoveryId int64) ([]TopologyRecovery, error) {
func ReadRecovery(recoveryId int64) ([]*TopologyRecovery, error) {
whereClause := `where recovery_id = ?`
return readRecoveries(whereClause, ``, sqlutils.Args(recoveryId))
}

// ReadRecoveryByUID reads completed recovery entry/audit entries from topology_recovery
func ReadRecoveryByUID(recoveryUID string) ([]TopologyRecovery, error) {
func ReadRecoveryByUID(recoveryUID string) ([]*TopologyRecovery, error) {
whereClause := `where uid = ?`
return readRecoveries(whereClause, ``, sqlutils.Args(recoveryUID))
}

// ReadCRecoveries reads latest recovery entries from topology_recovery
func ReadRecentRecoveries(clusterName string, clusterAlias string, unacknowledgedOnly bool, page int) ([]TopologyRecovery, error) {
func ReadRecentRecoveries(clusterName string, clusterAlias string, unacknowledgedOnly bool, page int) ([]*TopologyRecovery, error) {
whereConditions := []string{}
whereClause := ""
args := sqlutils.Args()
@@ -690,8 +690,8 @@ func ReadRecentRecoveries(clusterName string, clusterAlias string, unacknowledge
}

// readRecoveries reads recovery entry/audit entries from topology_recovery
func readFailureDetections(whereCondition string, limit string, args []interface{}) ([]TopologyRecovery, error) {
res := []TopologyRecovery{}
func readFailureDetections(whereCondition string, limit string, args []interface{}) ([]*TopologyRecovery, error) {
res := []*TopologyRecovery{}
query := fmt.Sprintf(`
select
detection_id,
@@ -737,15 +737,15 @@ func readFailureDetections(whereCondition string, limit string, args []interface

failureDetection.AnalysisEntry.ClusterDetails.ReadRecoveryInfo()

res = append(res, failureDetection) //nolint:govet
res = append(res, &failureDetection)
return nil
})

return res, log.Errore(err)
}

// ReadRecentFailureDetections
func ReadRecentFailureDetections(clusterAlias string, page int) ([]TopologyRecovery, error) {
func ReadRecentFailureDetections(clusterAlias string, page int) ([]*TopologyRecovery, error) {
whereClause := ""
args := sqlutils.Args()
if clusterAlias != "" {
@@ -760,7 +760,7 @@ func ReadRecentFailureDetections(clusterAlias string, page int) ([]TopologyRecov
}

// ReadFailureDetection
func ReadFailureDetection(detectionId int64) ([]TopologyRecovery, error) {
func ReadFailureDetection(detectionId int64) ([]*TopologyRecovery, error) {
whereClause := `where detection_id = ?`
return readFailureDetections(whereClause, ``, sqlutils.Args(detectionId))
}