Skip to content

Commit

Permalink
Migrate to go 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXal committed Feb 19, 2024
1 parent 6461b46 commit 4ac64b7
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 217 deletions.
36 changes: 17 additions & 19 deletions cmd/clickhouse-tasks/optimize/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,24 @@ func execute(taskContext context.Context) error {
// continue
// }

group.Go(func(index int, item Item) func() error {
return func() error {
// log.Printf("optimize %s.%s", item.Database, item.Table)
query := fmt.Sprintf("optimize table %s.%s", item.Database, item.Table)
// query := fmt.Sprintf("alter table %s.%s reset setting storage_policy", item.Database, item.Table)
// query := "create table IF NOT EXISTS " + item.Database + "." + item.Table + "2 as " + item.Database + "." + item.Table
// query := "insert into " + item.Database + "." + item.Table + "2 select * from " + item.Database + "." + item.Table
// query := "alter table " + item.Database + "." + item.Table + " drop column if exists raw_report"
// query := "rename table " + item.Database + "." + item.Table + " to " + item.Database + "." + strings.TrimSuffix(item.Table, "2")
// query := fmt.Sprintf("BACKUP TABLE %s.%s TO Disk('backups', '%s_%s')", item.Database, item.Table, item.Database, item.Table)
log.Println(query)
err = db.Exec(ctx, query)
if err != nil {
return fmt.Errorf("%w", err)
}

log.Printf("optimized %s.%s (%d of %d)", item.Database, item.Table, index, len(result))
return nil
group.Go(func() error {
// log.Printf("optimize %s.%s", item.Database, item.Table)
query := fmt.Sprintf("optimize table %s.%s", item.Database, item.Table)
// query := fmt.Sprintf("alter table %s.%s reset setting storage_policy", item.Database, item.Table)
// query := "create table IF NOT EXISTS " + item.Database + "." + item.Table + "2 as " + item.Database + "." + item.Table
// query := "insert into " + item.Database + "." + item.Table + "2 select * from " + item.Database + "." + item.Table
// query := "alter table " + item.Database + "." + item.Table + " drop column if exists raw_report"
// query := "rename table " + item.Database + "." + item.Table + " to " + item.Database + "." + strings.TrimSuffix(item.Table, "2")
// query := fmt.Sprintf("BACKUP TABLE %s.%s TO Disk('backups', '%s_%s')", item.Database, item.Table, item.Database, item.Table)
log.Println(query)
err = db.Exec(ctx, query)
if err != nil {
return fmt.Errorf("%w", err)
}
}(index, item))

log.Printf("optimized %s.%s (%d of %d)", item.Database, item.Table, index, len(result))
return nil
})
}
return group.Wait()
}
150 changes: 72 additions & 78 deletions cmd/tc-collector/reportLoader.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,80 +55,78 @@ func (t *Collector) loadReports(builds []*Build, reportExistenceChecker *ReportE
if build == nil || build.Agent.Name == "Dead agent" {
continue
}
errGroup.Go((func(build *Build) func() error {
return func() error {
t.logger.Info("processing build", "id", build.Id)
if t.config.HasInstallerField && build.installerInfo == nil {
// or already processed or cannot compute installer info
return nil
}
errGroup.Go(func() error {
t.logger.Info("processing build", "id", build.Id)
if t.config.HasInstallerField && build.installerInfo == nil {
// or already processed or cannot compute installer info
return nil
}

artifacts, err := t.downloadReports(loadContext, *build)
if err != nil {
return err
}
artifacts, err := t.downloadReports(loadContext, *build)
if err != nil {
return err
}

if len(artifacts) == 0 {
t.logger.Error("cannot find any performance report", "id", build.Id, "status", build.Status)
return nil
}
if len(artifacts) == 0 {
t.logger.Error("cannot find any performance report", "id", build.Id, "status", build.Status)
return nil
}

tcBuildProperties, err := t.downloadBuildProperties(loadContext, *build)
if err != nil {
return err
}
if tcBuildProperties == nil {
tcBuildProperties, err := t.downloadBuildProperties(loadContext, *build)
if err != nil {
return err
}
if tcBuildProperties == nil {
return nil
}

for _, artifact := range artifacts {
if loadContext.Err() != nil {
return nil
}

for _, artifact := range artifacts {
if loadContext.Err() != nil {
return nil
}

data := model.ExtraData{
Machine: build.Agent.Name,
TcBuildId: build.Id,
TcBuildType: build.Type,
TcBuildProperties: tcBuildProperties,
ReportFile: artifact.path,
}
data := model.ExtraData{
Machine: build.Agent.Name,
TcBuildId: build.Id,
TcBuildType: build.Type,
TcBuildProperties: tcBuildProperties,
ReportFile: artifact.path,
}

currentBuildTime, err := analyzer.ParseTime(build.FinishDate)
if err == nil {
data.CurrentBuildTime = currentBuildTime
}
currentBuildTime, err := analyzer.ParseTime(build.FinishDate)
if err == nil {
data.CurrentBuildTime = currentBuildTime
}

if build.Private && build.TriggeredBy.User != nil {
data.TriggeredBy = build.TriggeredBy.User.Email
}
if build.Private && build.TriggeredBy.User != nil {
data.TriggeredBy = build.TriggeredBy.User.Email
}

if t.config.HasInstallerField {
installerInfo := build.installerInfo
data.BuildTime = installerInfo.buildTime
data.Changes = installerInfo.changes
data.TcInstallerBuildId = installerInfo.id
}
if t.config.HasNoInstallerButHasChanges {
data.Changes = build.buildInfo.changes
}
if t.config.HasInstallerField {
installerInfo := build.installerInfo
data.BuildTime = installerInfo.buildTime
data.Changes = installerInfo.changes
data.TcInstallerBuildId = installerInfo.id
}
if t.config.HasNoInstallerButHasChanges {
data.Changes = build.buildInfo.changes
}

if t.config.HasBuildNumber {
data.TcBuildNumber = build.BuildNumber
}
if t.config.HasBuildNumber {
data.TcBuildNumber = build.BuildNumber
}

err = reportAnalyzer.Analyze(artifact.data, data)
if err != nil {
if build.Status == "FAILURE" {
t.logger.Warn("cannot parse performance report in the failed build", "buildId", build.Id, "error", err)
} else {
return err
}
err = reportAnalyzer.Analyze(artifact.data, data)
if err != nil {
if build.Status == "FAILURE" {
t.logger.Warn("cannot parse performance report in the failed build", "buildId", build.Id, "error", err)
} else {
return err
}
}
return nil
}
})(build))
return nil
})
}
return errGroup.Wait()
}
Expand Down Expand Up @@ -168,16 +166,14 @@ func (t *Collector) loadChanges(builds []*Build, networkRequestCount int) error
continue
}

errGroup.Go((func(buildInfo *BuildInfo) func() error {
return func() error {
var err error
buildInfo.changes, err = t.loadBuildChanges(loadContext, buildInfo.id)
if err != nil {
return fmt.Errorf("failed to load changes: %w", err)
}
return nil
errGroup.Go(func() error {
var err error
buildInfo.changes, err = t.loadBuildChanges(loadContext, buildInfo.id)
if err != nil {
return fmt.Errorf("failed to load changes: %w", err)
}
})(buildInfo))
return nil
})
}
return errGroup.Wait()
}
Expand Down Expand Up @@ -230,16 +226,14 @@ func (t *Collector) loadInstallerInfo(builds []*Build, networkRequestCount int)
continue
}

errGroup.Go((func(installerInfo *InstallerInfo) func() error {
return func() error {
var err error
installerInfo.changes, err = t.loadBuildChanges(loadContext, installerInfo.id)
if err != nil {
return fmt.Errorf("failed to load changes: %w", err)
}
return nil
errGroup.Go(func() error {
var err error
installerInfo.changes, err = t.loadBuildChanges(loadContext, installerInfo.id)
if err != nil {
return fmt.Errorf("failed to load changes: %w", err)
}
})(installerInfo))
return nil
})
}
return errGroup.Wait()
}
Expand Down
28 changes: 13 additions & 15 deletions cmd/tc-collector/tcCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,19 @@ func collectFromTeamCity(taskContext context.Context, clickHouseUrl string, tcUr
if taskContext.Err() != nil {
return fmt.Errorf("error in context: %w", taskContext.Err())
}
errGroup.Go(func(buildTypeId string) func() error {
return func() error {
return collectBuildConfiguration(
loadContext,
httpClient,
db,
config,
buildTypeId,
serverUrl,
tcUrl,
userSpecifiedSince,
slog.With("buildTypeId", buildTypeId),
)
}
}(buildTypeId))
errGroup.Go(func() error {
return collectBuildConfiguration(
loadContext,
httpClient,
db,
config,
buildTypeId,
serverUrl,
tcUrl,
userSpecifiedSince,
slog.With("buildTypeId", buildTypeId),
)
})
}
err = errGroup.Wait()
return err
Expand Down
2 changes: 1 addition & 1 deletion deployment/app-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM buildpack-deps:curl

ENV NODE_VERSION 21.6.1
ENV GOLANG_VERSION 1.21.6
ENV GOLANG_VERSION 1.22.0

RUN cd /usr/local/bin && \
curl -L https://github.com/google/ko/releases/download/v0.15.1/ko_0.15.1_Linux_x86_64.tar.gz | tar xvz ko && \
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/JetBrains/ij-perf-report-aggregator

go 1.21
go 1.22

require (
github.com/Altinity/clickhouse-backup v1.6.3-0.20230612080849-d0f5b1987694
Expand Down
15 changes: 1 addition & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,6 @@ github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJ
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
github.com/mozillazg/go-httpheader v0.4.0 h1:aBn6aRXtFzyDLZ4VIRLsZbbJloagQfMnCiYgOq6hK4w=
github.com/mozillazg/go-httpheader v0.4.0/go.mod h1:PuT8h0pw6efvp8ZeUec1Rs7dwjK08bt6gKSReGMqtdA=
github.com/nats-io/nats.go v1.32.0 h1:Bx9BZS+aXYlxW08k8Gd3yR2s73pV5XSoAQUyp1Kwvp0=
github.com/nats-io/nats.go v1.32.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
github.com/nats-io/nats.go v1.33.1 h1:8TxLZZ/seeEfR97qV0/Bl939tpDnt2Z2fK3HkPypj70=
github.com/nats-io/nats.go v1.33.1/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=
Expand Down Expand Up @@ -486,8 +484,6 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -517,8 +513,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -546,8 +540,6 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -594,17 +586,14 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down Expand Up @@ -648,8 +637,6 @@ golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
1 change: 0 additions & 1 deletion pkg/degradation-detector/fetchMetricValues.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func fetchMetricsFromClickhouse(settings []Settings, client *http.Client, backen
pool := pond.New(5, 1000)
for _, setting := range settings {
wg.Add(1)
setting := setting
pool.Submit(func() {
defer wg.Done()
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
Expand Down
Loading

0 comments on commit 4ac64b7

Please sign in to comment.