scheduler: fix changegroup names

run changegroup names are based on the run path but it will contain slashes and
could be very long. So calculate the sha256 sum of the path and use it as the
changegroup name.
This commit is contained in:
Simone Gotti 2019-04-29 10:14:10 +02:00
parent 2c3e6bf9e4
commit 340cc15268
1 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import (
slog "github.com/sorintlab/agola/internal/log"
"github.com/sorintlab/agola/internal/services/config"
rsapi "github.com/sorintlab/agola/internal/services/runservice/scheduler/api"
"github.com/sorintlab/agola/internal/util"
"github.com/pkg/errors"
"go.uber.org/zap"
@ -89,7 +90,8 @@ func (s *Scheduler) scheduleRun(ctx context.Context, groupID string) error {
//log.Infof("queued runs: %s", queuedRunsResponse.Runs)
run := queuedRunsResponse.Runs[0]
runningRunsResponse, _, err := s.runserviceClient.GetGroupRunningRuns(ctx, groupID, 1, []string{fmt.Sprintf("changegroup-%s", groupID)})
changegroup := util.EncodeSha256Hex(fmt.Sprintf("changegroup-%s", groupID))
runningRunsResponse, _, err := s.runserviceClient.GetGroupRunningRuns(ctx, groupID, 1, []string{changegroup})
if err != nil {
return errors.Wrapf(err, "failed to get running runs")
}