mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-10 19:50:30 +00:00
Compare commits
1 Commits
update-run
...
Link-/dock
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09b542320d |
2
.github/workflows/gha-e2e-tests.yaml
vendored
2
.github/workflows/gha-e2e-tests.yaml
vendored
@@ -16,7 +16,7 @@ env:
|
|||||||
TARGET_ORG: actions-runner-controller
|
TARGET_ORG: actions-runner-controller
|
||||||
TARGET_REPO: arc_e2e_test_dummy
|
TARGET_REPO: arc_e2e_test_dummy
|
||||||
IMAGE_NAME: "arc-test-image"
|
IMAGE_NAME: "arc-test-image"
|
||||||
IMAGE_VERSION: "0.8.2"
|
IMAGE_VERSION: "0.8.1"
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
# This will make sure we only apply the concurrency limits on pull requests
|
# This will make sure we only apply the concurrency limits on pull requests
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -6,7 +6,7 @@ endif
|
|||||||
DOCKER_USER ?= $(shell echo ${DOCKER_IMAGE_NAME} | cut -d / -f1)
|
DOCKER_USER ?= $(shell echo ${DOCKER_IMAGE_NAME} | cut -d / -f1)
|
||||||
VERSION ?= dev
|
VERSION ?= dev
|
||||||
COMMIT_SHA = $(shell git rev-parse HEAD)
|
COMMIT_SHA = $(shell git rev-parse HEAD)
|
||||||
RUNNER_VERSION ?= 2.312.0
|
RUNNER_VERSION ?= 2.311.0
|
||||||
TARGETPLATFORM ?= $(shell arch)
|
TARGETPLATFORM ?= $(shell arch)
|
||||||
RUNNER_NAME ?= ${DOCKER_USER}/actions-runner
|
RUNNER_NAME ?= ${DOCKER_USER}/actions-runner
|
||||||
RUNNER_TAG ?= ${VERSION}
|
RUNNER_TAG ?= ${VERSION}
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ type: application
|
|||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
# to the chart and its templates, including the app version.
|
# to the chart and its templates, including the app version.
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
version: 0.8.2
|
version: 0.8.1
|
||||||
|
|
||||||
# This is the version number of the application being deployed. This version number should be
|
# This is the version number of the application being deployed. This version number should be
|
||||||
# incremented each time you make changes to the application. Versions are not expected to
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
# It is recommended to use it with quotes.
|
# It is recommended to use it with quotes.
|
||||||
appVersion: "0.8.2"
|
appVersion: "0.8.1"
|
||||||
|
|
||||||
home: https://github.com/actions/actions-runner-controller
|
home: https://github.com/actions/actions-runner-controller
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ type: application
|
|||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
# to the chart and its templates, including the app version.
|
# to the chart and its templates, including the app version.
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
version: 0.8.2
|
version: 0.8.1
|
||||||
|
|
||||||
# This is the version number of the application being deployed. This version number should be
|
# This is the version number of the application being deployed. This version number should be
|
||||||
# incremented each time you make changes to the application. Versions are not expected to
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
# It is recommended to use it with quotes.
|
# It is recommended to use it with quotes.
|
||||||
appVersion: "0.8.2"
|
appVersion: "0.8.1"
|
||||||
|
|
||||||
home: https://github.com/actions/actions-runner-controller
|
home: https://github.com/actions/actions-runner-controller
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ volumeMounts:
|
|||||||
image: docker:dind
|
image: docker:dind
|
||||||
args:
|
args:
|
||||||
- dockerd
|
- dockerd
|
||||||
- --host=unix:///run/docker/docker.sock
|
- --host=unix:///var/run/docker.sock
|
||||||
- --group=$(DOCKER_GROUP_GID)
|
- --group=$(DOCKER_GROUP_GID)
|
||||||
env:
|
env:
|
||||||
- name: DOCKER_GROUP_GID
|
- name: DOCKER_GROUP_GID
|
||||||
@@ -110,7 +110,7 @@ volumeMounts:
|
|||||||
- name: work
|
- name: work
|
||||||
mountPath: /home/runner/_work
|
mountPath: /home/runner/_work
|
||||||
- name: dind-sock
|
- name: dind-sock
|
||||||
mountPath: /run/docker
|
mountPath: /var/run
|
||||||
- name: dind-externals
|
- name: dind-externals
|
||||||
mountPath: /home/runner/externals
|
mountPath: /home/runner/externals
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -223,7 +223,7 @@ env:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $setDockerHost }}
|
{{- if $setDockerHost }}
|
||||||
- name: DOCKER_HOST
|
- name: DOCKER_HOST
|
||||||
value: unix:///run/docker/docker.sock
|
value: unix:///var/run/docker.sock
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $setRunnerWaitDocker }}
|
{{- if $setRunnerWaitDocker }}
|
||||||
- name: RUNNER_WAIT_FOR_DOCKER_IN_SECONDS
|
- name: RUNNER_WAIT_FOR_DOCKER_IN_SECONDS
|
||||||
@@ -264,7 +264,7 @@ volumeMounts:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $mountDindCert }}
|
{{- if $mountDindCert }}
|
||||||
- name: dind-sock
|
- name: dind-sock
|
||||||
mountPath: /run/docker
|
mountPath: /var/run
|
||||||
readOnly: true
|
readOnly: true
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $mountGitHubServerTLS }}
|
{{- if $mountGitHubServerTLS }}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ type Listener interface {
|
|||||||
//go:generate mockery --name Worker --output ./mocks --outpkg mocks --case underscore
|
//go:generate mockery --name Worker --output ./mocks --outpkg mocks --case underscore
|
||||||
type Worker interface {
|
type Worker interface {
|
||||||
HandleJobStarted(ctx context.Context, jobInfo *actions.JobStarted) error
|
HandleJobStarted(ctx context.Context, jobInfo *actions.JobStarted) error
|
||||||
HandleDesiredRunnerCount(ctx context.Context, count int) (int, error)
|
HandleDesiredRunnerCount(ctx context.Context, desiredRunnerCount int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config config.Config) (*App, error) {
|
func New(config config.Config) (*App, error) {
|
||||||
|
|||||||
@@ -15,28 +15,18 @@ type Worker struct {
|
|||||||
mock.Mock
|
mock.Mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleDesiredRunnerCount provides a mock function with given fields: ctx, count
|
// HandleDesiredRunnerCount provides a mock function with given fields: ctx, desiredRunnerCount
|
||||||
func (_m *Worker) HandleDesiredRunnerCount(ctx context.Context, count int) (int, error) {
|
func (_m *Worker) HandleDesiredRunnerCount(ctx context.Context, desiredRunnerCount int) error {
|
||||||
ret := _m.Called(ctx, count)
|
ret := _m.Called(ctx, desiredRunnerCount)
|
||||||
|
|
||||||
var r0 int
|
var r0 error
|
||||||
var r1 error
|
if rf, ok := ret.Get(0).(func(context.Context, int) error); ok {
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, int) (int, error)); ok {
|
r0 = rf(ctx, desiredRunnerCount)
|
||||||
return rf(ctx, count)
|
|
||||||
}
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, int) int); ok {
|
|
||||||
r0 = rf(ctx, count)
|
|
||||||
} else {
|
} else {
|
||||||
r0 = ret.Get(0).(int)
|
r0 = ret.Error(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(context.Context, int) error); ok {
|
return r0
|
||||||
r1 = rf(ctx, count)
|
|
||||||
} else {
|
|
||||||
r1 = ret.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0, r1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleJobStarted provides a mock function with given fields: ctx, jobInfo
|
// HandleJobStarted provides a mock function with given fields: ctx, jobInfo
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ type Client interface {
|
|||||||
DeleteMessage(ctx context.Context, messageQueueUrl, messageQueueAccessToken string, messageId int64) error
|
DeleteMessage(ctx context.Context, messageQueueUrl, messageQueueAccessToken string, messageId int64) error
|
||||||
AcquireJobs(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error)
|
AcquireJobs(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error)
|
||||||
RefreshMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*actions.RunnerScaleSetSession, error)
|
RefreshMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*actions.RunnerScaleSetSession, error)
|
||||||
DeleteMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -114,7 +113,7 @@ func New(config Config) (*Listener, error) {
|
|||||||
//go:generate mockery --name Handler --output ./mocks --outpkg mocks --case underscore
|
//go:generate mockery --name Handler --output ./mocks --outpkg mocks --case underscore
|
||||||
type Handler interface {
|
type Handler interface {
|
||||||
HandleJobStarted(ctx context.Context, jobInfo *actions.JobStarted) error
|
HandleJobStarted(ctx context.Context, jobInfo *actions.JobStarted) error
|
||||||
HandleDesiredRunnerCount(ctx context.Context, count int) (int, error)
|
HandleDesiredRunnerCount(ctx context.Context, desiredRunnerCount int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen listens for incoming messages and handles them using the provided handler.
|
// Listen listens for incoming messages and handles them using the provided handler.
|
||||||
@@ -127,12 +126,6 @@ func (l *Listener) Listen(ctx context.Context, handler Handler) error {
|
|||||||
return fmt.Errorf("createSession failed: %w", err)
|
return fmt.Errorf("createSession failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if err := l.deleteMessageSession(); err != nil {
|
|
||||||
l.logger.Error(err, "failed to delete message session")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
initialMessage := &actions.RunnerScaleSetMessage{
|
initialMessage := &actions.RunnerScaleSetMessage{
|
||||||
MessageId: 0,
|
MessageId: 0,
|
||||||
MessageType: "RunnerScaleSetJobMessages",
|
MessageType: "RunnerScaleSetJobMessages",
|
||||||
@@ -140,21 +133,28 @@ func (l *Listener) Listen(ctx context.Context, handler Handler) error {
|
|||||||
Body: "",
|
Body: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.session.Statistics == nil {
|
if l.session.Statistics.TotalAvailableJobs > 0 || l.session.Statistics.TotalAssignedJobs > 0 {
|
||||||
return fmt.Errorf("session statistics is nil")
|
acquirableJobs, err := l.client.GetAcquirableJobs(ctx, l.scaleSetID)
|
||||||
}
|
if err != nil {
|
||||||
l.metrics.PublishStatistics(initialMessage.Statistics)
|
return fmt.Errorf("failed to call GetAcquirableJobs: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
desiredRunners, err := handler.HandleDesiredRunnerCount(ctx, initialMessage.Statistics.TotalAssignedJobs)
|
acquirableJobsJson, err := json.Marshal(acquirableJobs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to marshal acquirable jobs: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
initialMessage.Body = string(acquirableJobsJson)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := handler.HandleDesiredRunnerCount(ctx, initialMessage.Statistics.TotalAssignedJobs); err != nil {
|
||||||
return fmt.Errorf("handling initial message failed: %w", err)
|
return fmt.Errorf("handling initial message failed: %w", err)
|
||||||
}
|
}
|
||||||
l.metrics.PublishDesiredRunners(desiredRunners)
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return fmt.Errorf("context cancelled: %w", ctx.Err())
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,52 +167,27 @@ func (l *Listener) Listen(ctx context.Context, handler Handler) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// New context is created to avoid cancelation during message handling.
|
statistics, jobsStarted, err := l.parseMessage(ctx, msg)
|
||||||
if err := l.handleMessage(context.Background(), handler, msg); err != nil {
|
|
||||||
return fmt.Errorf("failed to handle message: %w", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Listener) handleMessage(ctx context.Context, handler Handler, msg *actions.RunnerScaleSetMessage) error {
|
|
||||||
parsedMsg, err := l.parseMessage(ctx, msg)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to parse message: %w", err)
|
|
||||||
}
|
|
||||||
l.metrics.PublishStatistics(parsedMsg.statistics)
|
|
||||||
|
|
||||||
if len(parsedMsg.jobsAvailable) > 0 {
|
|
||||||
acquiredJobIDs, err := l.acquireAvailableJobs(ctx, parsedMsg.jobsAvailable)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to acquire jobs: %w", err)
|
return fmt.Errorf("failed to parse message: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
l.logger.Info("Jobs are acquired", "count", len(acquiredJobIDs), "requestIds", fmt.Sprint(acquiredJobIDs))
|
l.lastMessageID = msg.MessageId
|
||||||
}
|
|
||||||
|
|
||||||
for _, jobCompleted := range parsedMsg.jobsCompleted {
|
if err := l.deleteLastMessage(ctx); err != nil {
|
||||||
l.metrics.PublishJobCompleted(jobCompleted)
|
return fmt.Errorf("failed to delete message: %w", err)
|
||||||
}
|
|
||||||
|
|
||||||
l.lastMessageID = msg.MessageId
|
|
||||||
|
|
||||||
if err := l.deleteLastMessage(ctx); err != nil {
|
|
||||||
return fmt.Errorf("failed to delete message: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, jobStarted := range parsedMsg.jobsStarted {
|
|
||||||
if err := handler.HandleJobStarted(ctx, jobStarted); err != nil {
|
|
||||||
return fmt.Errorf("failed to handle job started: %w", err)
|
|
||||||
}
|
}
|
||||||
l.metrics.PublishJobStarted(jobStarted)
|
|
||||||
}
|
|
||||||
|
|
||||||
desiredRunners, err := handler.HandleDesiredRunnerCount(ctx, parsedMsg.statistics.TotalAssignedJobs)
|
for _, jobStarted := range jobsStarted {
|
||||||
if err != nil {
|
if err := handler.HandleJobStarted(ctx, jobStarted); err != nil {
|
||||||
return fmt.Errorf("failed to handle desired runner count: %w", err)
|
return fmt.Errorf("failed to handle job started: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := handler.HandleDesiredRunnerCount(ctx, statistics.TotalAssignedJobs); err != nil {
|
||||||
|
return fmt.Errorf("failed to handle desired runner count: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
l.metrics.PublishDesiredRunners(desiredRunners)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Listener) createSession(ctx context.Context) error {
|
func (l *Listener) createSession(ctx context.Context) error {
|
||||||
@@ -296,57 +271,48 @@ func (l *Listener) deleteLastMessage(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type parsedMessage struct {
|
func (l *Listener) parseMessage(ctx context.Context, msg *actions.RunnerScaleSetMessage) (*actions.RunnerScaleSetStatistic, []*actions.JobStarted, error) {
|
||||||
statistics *actions.RunnerScaleSetStatistic
|
|
||||||
jobsStarted []*actions.JobStarted
|
|
||||||
jobsAvailable []*actions.JobAvailable
|
|
||||||
jobsCompleted []*actions.JobCompleted
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Listener) parseMessage(ctx context.Context, msg *actions.RunnerScaleSetMessage) (*parsedMessage, error) {
|
|
||||||
if msg.MessageType != "RunnerScaleSetJobMessages" {
|
|
||||||
l.logger.Info("Skipping message", "messageType", msg.MessageType)
|
|
||||||
return nil, fmt.Errorf("invalid message type: %s", msg.MessageType)
|
|
||||||
}
|
|
||||||
|
|
||||||
l.logger.Info("Processing message", "messageId", msg.MessageId, "messageType", msg.MessageType)
|
l.logger.Info("Processing message", "messageId", msg.MessageId, "messageType", msg.MessageType)
|
||||||
if msg.Statistics == nil {
|
if msg.Statistics == nil {
|
||||||
return nil, fmt.Errorf("invalid message: statistics is nil")
|
return nil, nil, fmt.Errorf("invalid message: statistics is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
l.logger.Info("New runner scale set statistics.", "statistics", msg.Statistics)
|
l.logger.Info("New runner scale set statistics.", "statistics", msg.Statistics)
|
||||||
|
|
||||||
|
if msg.MessageType != "RunnerScaleSetJobMessages" {
|
||||||
|
l.logger.Info("Skipping message", "messageType", msg.MessageType)
|
||||||
|
return nil, nil, fmt.Errorf("invalid message type: %s", msg.MessageType)
|
||||||
|
}
|
||||||
|
|
||||||
var batchedMessages []json.RawMessage
|
var batchedMessages []json.RawMessage
|
||||||
if len(msg.Body) > 0 {
|
if len(msg.Body) > 0 {
|
||||||
if err := json.Unmarshal([]byte(msg.Body), &batchedMessages); err != nil {
|
if err := json.Unmarshal([]byte(msg.Body), &batchedMessages); err != nil {
|
||||||
return nil, fmt.Errorf("failed to unmarshal batched messages: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal batched messages: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parsedMsg := &parsedMessage{
|
var availableJobs []int64
|
||||||
statistics: msg.Statistics,
|
var startedJobs []*actions.JobStarted
|
||||||
}
|
|
||||||
|
|
||||||
for _, msg := range batchedMessages {
|
for _, msg := range batchedMessages {
|
||||||
var messageType actions.JobMessageType
|
var messageType actions.JobMessageType
|
||||||
if err := json.Unmarshal(msg, &messageType); err != nil {
|
if err := json.Unmarshal(msg, &messageType); err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode job message type: %w", err)
|
return nil, nil, fmt.Errorf("failed to decode job message type: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch messageType.MessageType {
|
switch messageType.MessageType {
|
||||||
case messageTypeJobAvailable:
|
case messageTypeJobAvailable:
|
||||||
var jobAvailable actions.JobAvailable
|
var jobAvailable actions.JobAvailable
|
||||||
if err := json.Unmarshal(msg, &jobAvailable); err != nil {
|
if err := json.Unmarshal(msg, &jobAvailable); err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode job available: %w", err)
|
return nil, nil, fmt.Errorf("failed to decode job available: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
l.logger.Info("Job available message received", "jobId", jobAvailable.RunnerRequestId)
|
l.logger.Info("Job available message received", "jobId", jobAvailable.RunnerRequestId)
|
||||||
parsedMsg.jobsAvailable = append(parsedMsg.jobsAvailable, &jobAvailable)
|
availableJobs = append(availableJobs, jobAvailable.RunnerRequestId)
|
||||||
|
|
||||||
case messageTypeJobAssigned:
|
case messageTypeJobAssigned:
|
||||||
var jobAssigned actions.JobAssigned
|
var jobAssigned actions.JobAssigned
|
||||||
if err := json.Unmarshal(msg, &jobAssigned); err != nil {
|
if err := json.Unmarshal(msg, &jobAssigned); err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode job assigned: %w", err)
|
return nil, nil, fmt.Errorf("failed to decode job assigned: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
l.logger.Info("Job assigned message received", "jobId", jobAssigned.RunnerRequestId)
|
l.logger.Info("Job assigned message received", "jobId", jobAssigned.RunnerRequestId)
|
||||||
@@ -354,37 +320,41 @@ func (l *Listener) parseMessage(ctx context.Context, msg *actions.RunnerScaleSet
|
|||||||
case messageTypeJobStarted:
|
case messageTypeJobStarted:
|
||||||
var jobStarted actions.JobStarted
|
var jobStarted actions.JobStarted
|
||||||
if err := json.Unmarshal(msg, &jobStarted); err != nil {
|
if err := json.Unmarshal(msg, &jobStarted); err != nil {
|
||||||
return nil, fmt.Errorf("could not decode job started message. %w", err)
|
return nil, nil, fmt.Errorf("could not decode job started message. %w", err)
|
||||||
}
|
}
|
||||||
l.logger.Info("Job started message received.", "RequestId", jobStarted.RunnerRequestId, "RunnerId", jobStarted.RunnerId)
|
l.logger.Info("Job started message received.", "RequestId", jobStarted.RunnerRequestId, "RunnerId", jobStarted.RunnerId)
|
||||||
parsedMsg.jobsStarted = append(parsedMsg.jobsStarted, &jobStarted)
|
startedJobs = append(startedJobs, &jobStarted)
|
||||||
|
|
||||||
case messageTypeJobCompleted:
|
case messageTypeJobCompleted:
|
||||||
var jobCompleted actions.JobCompleted
|
var jobCompleted actions.JobCompleted
|
||||||
if err := json.Unmarshal(msg, &jobCompleted); err != nil {
|
if err := json.Unmarshal(msg, &jobCompleted); err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode job completed: %w", err)
|
return nil, nil, fmt.Errorf("failed to decode job completed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
l.logger.Info("Job completed message received.", "RequestId", jobCompleted.RunnerRequestId, "Result", jobCompleted.Result, "RunnerId", jobCompleted.RunnerId, "RunnerName", jobCompleted.RunnerName)
|
l.logger.Info("Job completed message received.", "RequestId", jobCompleted.RunnerRequestId, "Result", jobCompleted.Result, "RunnerId", jobCompleted.RunnerId, "RunnerName", jobCompleted.RunnerName)
|
||||||
parsedMsg.jobsCompleted = append(parsedMsg.jobsCompleted, &jobCompleted)
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
l.logger.Info("unknown job message type.", "messageType", messageType.MessageType)
|
l.logger.Info("unknown job message type.", "messageType", messageType.MessageType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsedMsg, nil
|
l.logger.Info("Available jobs.", "count", len(availableJobs), "requestIds", fmt.Sprint(availableJobs))
|
||||||
}
|
if len(availableJobs) > 0 {
|
||||||
|
acquired, err := l.acquireAvailableJobs(ctx, availableJobs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
func (l *Listener) acquireAvailableJobs(ctx context.Context, jobsAvailable []*actions.JobAvailable) ([]int64, error) {
|
l.logger.Info("Jobs are acquired", "count", len(acquired), "requestIds", fmt.Sprint(acquired))
|
||||||
ids := make([]int64, 0, len(jobsAvailable))
|
|
||||||
for _, job := range jobsAvailable {
|
|
||||||
ids = append(ids, job.RunnerRequestId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
l.logger.Info("Acquiring jobs", "count", len(ids), "requestIds", fmt.Sprint(ids))
|
return msg.Statistics, startedJobs, nil
|
||||||
|
}
|
||||||
|
|
||||||
ids, err := l.client.AcquireJobs(ctx, l.scaleSetID, l.session.MessageQueueAccessToken, ids)
|
func (l *Listener) acquireAvailableJobs(ctx context.Context, availableJobs []int64) ([]int64, error) {
|
||||||
|
l.logger.Info("Acquiring jobs")
|
||||||
|
|
||||||
|
ids, err := l.client.AcquireJobs(ctx, l.scaleSetID, l.session.MessageQueueAccessToken, availableJobs)
|
||||||
if err == nil { // if NO errors
|
if err == nil { // if NO errors
|
||||||
return ids, nil
|
return ids, nil
|
||||||
}
|
}
|
||||||
@@ -398,7 +368,7 @@ func (l *Listener) acquireAvailableJobs(ctx context.Context, jobsAvailable []*ac
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ids, err = l.client.AcquireJobs(ctx, l.scaleSetID, l.session.MessageQueueAccessToken, ids)
|
ids, err = l.client.AcquireJobs(ctx, l.scaleSetID, l.session.MessageQueueAccessToken, availableJobs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to acquire jobs after session refresh: %w", err)
|
return nil, fmt.Errorf("failed to acquire jobs after session refresh: %w", err)
|
||||||
}
|
}
|
||||||
@@ -416,16 +386,3 @@ func (l *Listener) refreshSession(ctx context.Context) error {
|
|||||||
l.session = session
|
l.session = session
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Listener) deleteMessageSession() error {
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
l.logger.Info("Deleting message session")
|
|
||||||
|
|
||||||
if err := l.client.DeleteMessageSession(ctx, l.session.RunnerScaleSet.Id, l.session.SessionId); err != nil {
|
|
||||||
return fmt.Errorf("failed to delete message session: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package listener
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -10,6 +9,7 @@ import (
|
|||||||
|
|
||||||
listenermocks "github.com/actions/actions-runner-controller/cmd/ghalistener/listener/mocks"
|
listenermocks "github.com/actions/actions-runner-controller/cmd/ghalistener/listener/mocks"
|
||||||
"github.com/actions/actions-runner-controller/cmd/ghalistener/metrics"
|
"github.com/actions/actions-runner-controller/cmd/ghalistener/metrics"
|
||||||
|
metricsmocks "github.com/actions/actions-runner-controller/cmd/ghalistener/metrics/mocks"
|
||||||
"github.com/actions/actions-runner-controller/github/actions"
|
"github.com/actions/actions-runner-controller/github/actions"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -38,6 +38,22 @@ func TestNew(t *testing.T) {
|
|||||||
assert.NotNil(t, l)
|
assert.NotNil(t, l)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("SetStaticMetrics", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
metrics := metricsmocks.NewPublisher(t)
|
||||||
|
|
||||||
|
metrics.On("PublishStatic", mock.Anything, mock.Anything).Once()
|
||||||
|
|
||||||
|
config := Config{
|
||||||
|
Client: listenermocks.NewClient(t),
|
||||||
|
ScaleSetID: 1,
|
||||||
|
Metrics: metrics,
|
||||||
|
}
|
||||||
|
l, err := New(config)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.NotNil(t, l)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListener_createSession(t *testing.T) {
|
func TestListener_createSession(t *testing.T) {
|
||||||
@@ -419,8 +435,6 @@ func TestListener_Listen(t *testing.T) {
|
|||||||
Statistics: &actions.RunnerScaleSetStatistic{},
|
Statistics: &actions.RunnerScaleSetStatistic{},
|
||||||
}
|
}
|
||||||
client.On("CreateMessageSession", ctx, mock.Anything, mock.Anything).Return(session, nil).Once()
|
client.On("CreateMessageSession", ctx, mock.Anything, mock.Anything).Return(session, nil).Once()
|
||||||
client.On("DeleteMessageSession", mock.Anything, session.RunnerScaleSet.Id, session.SessionId).Return(nil).Once()
|
|
||||||
|
|
||||||
config.Client = client
|
config.Client = client
|
||||||
|
|
||||||
l, err := New(config)
|
l, err := New(config)
|
||||||
@@ -429,7 +443,7 @@ func TestListener_Listen(t *testing.T) {
|
|||||||
var called bool
|
var called bool
|
||||||
handler := listenermocks.NewHandler(t)
|
handler := listenermocks.NewHandler(t)
|
||||||
handler.On("HandleDesiredRunnerCount", mock.Anything, mock.Anything).
|
handler.On("HandleDesiredRunnerCount", mock.Anything, mock.Anything).
|
||||||
Return(0, nil).
|
Return(nil).
|
||||||
Run(
|
Run(
|
||||||
func(mock.Arguments) {
|
func(mock.Arguments) {
|
||||||
called = true
|
called = true
|
||||||
@@ -442,64 +456,6 @@ func TestListener_Listen(t *testing.T) {
|
|||||||
assert.True(t, errors.Is(err, context.Canceled))
|
assert.True(t, errors.Is(err, context.Canceled))
|
||||||
assert.True(t, called)
|
assert.True(t, called)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("CancelContextAfterGetMessage", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
|
|
||||||
config := Config{
|
|
||||||
ScaleSetID: 1,
|
|
||||||
Metrics: metrics.Discard,
|
|
||||||
}
|
|
||||||
|
|
||||||
client := listenermocks.NewClient(t)
|
|
||||||
uuid := uuid.New()
|
|
||||||
session := &actions.RunnerScaleSetSession{
|
|
||||||
SessionId: &uuid,
|
|
||||||
OwnerName: "example",
|
|
||||||
RunnerScaleSet: &actions.RunnerScaleSet{},
|
|
||||||
MessageQueueUrl: "https://example.com",
|
|
||||||
MessageQueueAccessToken: "1234567890",
|
|
||||||
Statistics: &actions.RunnerScaleSetStatistic{},
|
|
||||||
}
|
|
||||||
client.On("CreateMessageSession", ctx, mock.Anything, mock.Anything).Return(session, nil).Once()
|
|
||||||
client.On("DeleteMessageSession", mock.Anything, session.RunnerScaleSet.Id, session.SessionId).Return(nil).Once()
|
|
||||||
|
|
||||||
msg := &actions.RunnerScaleSetMessage{
|
|
||||||
MessageId: 1,
|
|
||||||
MessageType: "RunnerScaleSetJobMessages",
|
|
||||||
Statistics: &actions.RunnerScaleSetStatistic{},
|
|
||||||
}
|
|
||||||
client.On("GetMessage", ctx, mock.Anything, mock.Anything, mock.Anything).
|
|
||||||
Return(msg, nil).
|
|
||||||
Run(
|
|
||||||
func(mock.Arguments) {
|
|
||||||
cancel()
|
|
||||||
},
|
|
||||||
).
|
|
||||||
Once()
|
|
||||||
|
|
||||||
// Ensure delete message is called with background context
|
|
||||||
client.On("DeleteMessage", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
|
|
||||||
|
|
||||||
config.Client = client
|
|
||||||
|
|
||||||
handler := listenermocks.NewHandler(t)
|
|
||||||
handler.On("HandleDesiredRunnerCount", mock.Anything, mock.Anything).
|
|
||||||
Return(0, nil).
|
|
||||||
Once()
|
|
||||||
|
|
||||||
handler.On("HandleDesiredRunnerCount", mock.Anything, mock.Anything).
|
|
||||||
Return(0, nil).
|
|
||||||
Once()
|
|
||||||
|
|
||||||
l, err := New(config)
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
err = l.Listen(ctx, handler)
|
|
||||||
assert.ErrorIs(t, context.Canceled, err)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListener_acquireAvailableJobs(t *testing.T) {
|
func TestListener_acquireAvailableJobs(t *testing.T) {
|
||||||
@@ -533,24 +489,7 @@ func TestListener_acquireAvailableJobs(t *testing.T) {
|
|||||||
Statistics: &actions.RunnerScaleSetStatistic{},
|
Statistics: &actions.RunnerScaleSetStatistic{},
|
||||||
}
|
}
|
||||||
|
|
||||||
availableJobs := []*actions.JobAvailable{
|
_, err = l.acquireAvailableJobs(ctx, []int64{1, 2, 3})
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
_, err = l.acquireAvailableJobs(ctx, availableJobs)
|
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -584,26 +523,9 @@ func TestListener_acquireAvailableJobs(t *testing.T) {
|
|||||||
Statistics: &actions.RunnerScaleSetStatistic{},
|
Statistics: &actions.RunnerScaleSetStatistic{},
|
||||||
}
|
}
|
||||||
|
|
||||||
availableJobs := []*actions.JobAvailable{
|
acquiredJobIDs, err := l.acquireAvailableJobs(ctx, []int64{1, 2, 3})
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
acquiredJobIDs, err := l.acquireAvailableJobs(ctx, availableJobs)
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, []int64{1, 2, 3}, acquiredJobIDs)
|
assert.Equal(t, jobIDs, acquiredJobIDs)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("RefreshAndSucceeds", func(t *testing.T) {
|
t.Run("RefreshAndSucceeds", func(t *testing.T) {
|
||||||
@@ -633,23 +555,6 @@ func TestListener_acquireAvailableJobs(t *testing.T) {
|
|||||||
|
|
||||||
// Second call to AcquireJobs will succeed
|
// Second call to AcquireJobs will succeed
|
||||||
want := []int64{1, 2, 3}
|
want := []int64{1, 2, 3}
|
||||||
availableJobs := []*actions.JobAvailable{
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
client.On("AcquireJobs", ctx, mock.Anything, mock.Anything, mock.Anything).Return(want, nil).Once()
|
client.On("AcquireJobs", ctx, mock.Anything, mock.Anything, mock.Anything).Return(want, nil).Once()
|
||||||
|
|
||||||
config.Client = client
|
config.Client = client
|
||||||
@@ -662,7 +567,7 @@ func TestListener_acquireAvailableJobs(t *testing.T) {
|
|||||||
RunnerScaleSet: &actions.RunnerScaleSet{},
|
RunnerScaleSet: &actions.RunnerScaleSet{},
|
||||||
}
|
}
|
||||||
|
|
||||||
got, err := l.acquireAvailableJobs(ctx, availableJobs)
|
got, err := l.acquireAvailableJobs(ctx, want)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, want, got)
|
assert.Equal(t, want, got)
|
||||||
})
|
})
|
||||||
@@ -701,165 +606,8 @@ func TestListener_acquireAvailableJobs(t *testing.T) {
|
|||||||
RunnerScaleSet: &actions.RunnerScaleSet{},
|
RunnerScaleSet: &actions.RunnerScaleSet{},
|
||||||
}
|
}
|
||||||
|
|
||||||
availableJobs := []*actions.JobAvailable{
|
got, err := l.acquireAvailableJobs(ctx, []int64{1, 2, 3})
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
RunnerRequestId: 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
got, err := l.acquireAvailableJobs(ctx, availableJobs)
|
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
assert.Nil(t, got)
|
assert.Nil(t, got)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListener_parseMessage(t *testing.T) {
|
|
||||||
t.Run("FailOnEmptyStatistics", func(t *testing.T) {
|
|
||||||
msg := &actions.RunnerScaleSetMessage{
|
|
||||||
MessageId: 1,
|
|
||||||
MessageType: "RunnerScaleSetJobMessages",
|
|
||||||
Statistics: nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
l := &Listener{}
|
|
||||||
parsedMsg, err := l.parseMessage(context.Background(), msg)
|
|
||||||
assert.Error(t, err)
|
|
||||||
assert.Nil(t, parsedMsg)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("FailOnIncorrectMessageType", func(t *testing.T) {
|
|
||||||
msg := &actions.RunnerScaleSetMessage{
|
|
||||||
MessageId: 1,
|
|
||||||
MessageType: "RunnerMessages", // arbitrary message type
|
|
||||||
Statistics: &actions.RunnerScaleSetStatistic{},
|
|
||||||
}
|
|
||||||
|
|
||||||
l := &Listener{}
|
|
||||||
parsedMsg, err := l.parseMessage(context.Background(), msg)
|
|
||||||
assert.Error(t, err)
|
|
||||||
assert.Nil(t, parsedMsg)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("ParseAll", func(t *testing.T) {
|
|
||||||
msg := &actions.RunnerScaleSetMessage{
|
|
||||||
MessageId: 1,
|
|
||||||
MessageType: "RunnerScaleSetJobMessages",
|
|
||||||
Body: "",
|
|
||||||
Statistics: &actions.RunnerScaleSetStatistic{
|
|
||||||
TotalAvailableJobs: 1,
|
|
||||||
TotalAcquiredJobs: 2,
|
|
||||||
TotalAssignedJobs: 3,
|
|
||||||
TotalRunningJobs: 4,
|
|
||||||
TotalRegisteredRunners: 5,
|
|
||||||
TotalBusyRunners: 6,
|
|
||||||
TotalIdleRunners: 7,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
var batchedMessages []any
|
|
||||||
jobsAvailable := []*actions.JobAvailable{
|
|
||||||
{
|
|
||||||
AcquireJobUrl: "https://github.com/example",
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobAvailable,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AcquireJobUrl: "https://github.com/example",
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobAvailable,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, msg := range jobsAvailable {
|
|
||||||
batchedMessages = append(batchedMessages, msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
jobsAssigned := []*actions.JobAssigned{
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobAssigned,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobAssigned,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 4,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, msg := range jobsAssigned {
|
|
||||||
batchedMessages = append(batchedMessages, msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
jobsStarted := []*actions.JobStarted{
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobStarted,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 5,
|
|
||||||
},
|
|
||||||
RunnerId: 2,
|
|
||||||
RunnerName: "runner2",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, msg := range jobsStarted {
|
|
||||||
batchedMessages = append(batchedMessages, msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
jobsCompleted := []*actions.JobCompleted{
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobCompleted,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 6,
|
|
||||||
},
|
|
||||||
Result: "success",
|
|
||||||
RunnerId: 1,
|
|
||||||
RunnerName: "runner1",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, msg := range jobsCompleted {
|
|
||||||
batchedMessages = append(batchedMessages, msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := json.Marshal(batchedMessages)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
msg.Body = string(b)
|
|
||||||
|
|
||||||
l := &Listener{}
|
|
||||||
parsedMsg, err := l.parseMessage(context.Background(), msg)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
assert.Equal(t, msg.Statistics, parsedMsg.statistics)
|
|
||||||
assert.Equal(t, jobsAvailable, parsedMsg.jobsAvailable)
|
|
||||||
assert.Equal(t, jobsStarted, parsedMsg.jobsStarted)
|
|
||||||
assert.Equal(t, jobsCompleted, parsedMsg.jobsCompleted)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,205 +0,0 @@
|
|||||||
package listener
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
listenermocks "github.com/actions/actions-runner-controller/cmd/ghalistener/listener/mocks"
|
|
||||||
metricsmocks "github.com/actions/actions-runner-controller/cmd/ghalistener/metrics/mocks"
|
|
||||||
"github.com/actions/actions-runner-controller/github/actions"
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/mock"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestInitialMetrics(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
t.Run("SetStaticMetrics", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
metrics := metricsmocks.NewPublisher(t)
|
|
||||||
|
|
||||||
minRunners := 5
|
|
||||||
maxRunners := 10
|
|
||||||
metrics.On("PublishStatic", minRunners, maxRunners).Once()
|
|
||||||
|
|
||||||
config := Config{
|
|
||||||
Client: listenermocks.NewClient(t),
|
|
||||||
ScaleSetID: 1,
|
|
||||||
Metrics: metrics,
|
|
||||||
MinRunners: minRunners,
|
|
||||||
MaxRunners: maxRunners,
|
|
||||||
}
|
|
||||||
l, err := New(config)
|
|
||||||
|
|
||||||
assert.Nil(t, err)
|
|
||||||
assert.NotNil(t, l)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("InitialMessageStatistics", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
|
|
||||||
sessionStatistics := &actions.RunnerScaleSetStatistic{
|
|
||||||
TotalAvailableJobs: 1,
|
|
||||||
TotalAcquiredJobs: 2,
|
|
||||||
TotalAssignedJobs: 3,
|
|
||||||
TotalRunningJobs: 4,
|
|
||||||
TotalRegisteredRunners: 5,
|
|
||||||
TotalBusyRunners: 6,
|
|
||||||
TotalIdleRunners: 7,
|
|
||||||
}
|
|
||||||
|
|
||||||
uuid := uuid.New()
|
|
||||||
session := &actions.RunnerScaleSetSession{
|
|
||||||
SessionId: &uuid,
|
|
||||||
OwnerName: "example",
|
|
||||||
RunnerScaleSet: &actions.RunnerScaleSet{},
|
|
||||||
MessageQueueUrl: "https://example.com",
|
|
||||||
MessageQueueAccessToken: "1234567890",
|
|
||||||
Statistics: sessionStatistics,
|
|
||||||
}
|
|
||||||
|
|
||||||
metrics := metricsmocks.NewPublisher(t)
|
|
||||||
metrics.On("PublishStatic", mock.Anything, mock.Anything).Once()
|
|
||||||
metrics.On("PublishStatistics", sessionStatistics).Once()
|
|
||||||
metrics.On("PublishDesiredRunners", sessionStatistics.TotalAssignedJobs).
|
|
||||||
Run(
|
|
||||||
func(mock.Arguments) {
|
|
||||||
cancel()
|
|
||||||
},
|
|
||||||
).Once()
|
|
||||||
|
|
||||||
config := Config{
|
|
||||||
Client: listenermocks.NewClient(t),
|
|
||||||
ScaleSetID: 1,
|
|
||||||
Metrics: metrics,
|
|
||||||
}
|
|
||||||
|
|
||||||
client := listenermocks.NewClient(t)
|
|
||||||
client.On("CreateMessageSession", mock.Anything, mock.Anything, mock.Anything).Return(session, nil).Once()
|
|
||||||
client.On("DeleteMessageSession", mock.Anything, session.RunnerScaleSet.Id, session.SessionId).Return(nil).Once()
|
|
||||||
config.Client = client
|
|
||||||
|
|
||||||
handler := listenermocks.NewHandler(t)
|
|
||||||
handler.On("HandleDesiredRunnerCount", mock.Anything, sessionStatistics.TotalAssignedJobs).
|
|
||||||
Return(sessionStatistics.TotalAssignedJobs, nil).
|
|
||||||
Once()
|
|
||||||
|
|
||||||
l, err := New(config)
|
|
||||||
assert.Nil(t, err)
|
|
||||||
assert.NotNil(t, l)
|
|
||||||
|
|
||||||
assert.ErrorIs(t, context.Canceled, l.Listen(ctx, handler))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHandleMessageMetrics(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
msg := &actions.RunnerScaleSetMessage{
|
|
||||||
MessageId: 1,
|
|
||||||
MessageType: "RunnerScaleSetJobMessages",
|
|
||||||
Body: "",
|
|
||||||
Statistics: &actions.RunnerScaleSetStatistic{
|
|
||||||
TotalAvailableJobs: 1,
|
|
||||||
TotalAcquiredJobs: 2,
|
|
||||||
TotalAssignedJobs: 3,
|
|
||||||
TotalRunningJobs: 4,
|
|
||||||
TotalRegisteredRunners: 5,
|
|
||||||
TotalBusyRunners: 6,
|
|
||||||
TotalIdleRunners: 7,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
var batchedMessages []any
|
|
||||||
jobsStarted := []*actions.JobStarted{
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobStarted,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 8,
|
|
||||||
},
|
|
||||||
RunnerId: 3,
|
|
||||||
RunnerName: "runner3",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, msg := range jobsStarted {
|
|
||||||
batchedMessages = append(batchedMessages, msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
jobsCompleted := []*actions.JobCompleted{
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobCompleted,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 6,
|
|
||||||
},
|
|
||||||
Result: "success",
|
|
||||||
RunnerId: 1,
|
|
||||||
RunnerName: "runner1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
JobMessageBase: actions.JobMessageBase{
|
|
||||||
JobMessageType: actions.JobMessageType{
|
|
||||||
MessageType: messageTypeJobCompleted,
|
|
||||||
},
|
|
||||||
RunnerRequestId: 7,
|
|
||||||
},
|
|
||||||
Result: "success",
|
|
||||||
RunnerId: 2,
|
|
||||||
RunnerName: "runner2",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, msg := range jobsCompleted {
|
|
||||||
batchedMessages = append(batchedMessages, msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := json.Marshal(batchedMessages)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
msg.Body = string(b)
|
|
||||||
|
|
||||||
desiredResult := 4
|
|
||||||
|
|
||||||
metrics := metricsmocks.NewPublisher(t)
|
|
||||||
metrics.On("PublishStatic", 0, 0).Once()
|
|
||||||
metrics.On("PublishStatistics", msg.Statistics).Once()
|
|
||||||
metrics.On("PublishJobCompleted", jobsCompleted[0]).Once()
|
|
||||||
metrics.On("PublishJobCompleted", jobsCompleted[1]).Once()
|
|
||||||
metrics.On("PublishJobStarted", jobsStarted[0]).Once()
|
|
||||||
metrics.On("PublishDesiredRunners", desiredResult).Once()
|
|
||||||
|
|
||||||
handler := listenermocks.NewHandler(t)
|
|
||||||
handler.On("HandleJobStarted", mock.Anything, jobsStarted[0]).Return(nil).Once()
|
|
||||||
handler.On("HandleDesiredRunnerCount", mock.Anything, mock.Anything).Return(desiredResult, nil).Once()
|
|
||||||
|
|
||||||
client := listenermocks.NewClient(t)
|
|
||||||
client.On("DeleteMessage", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
|
|
||||||
|
|
||||||
config := Config{
|
|
||||||
Client: listenermocks.NewClient(t),
|
|
||||||
ScaleSetID: 1,
|
|
||||||
Metrics: metrics,
|
|
||||||
}
|
|
||||||
|
|
||||||
l, err := New(config)
|
|
||||||
require.NoError(t, err)
|
|
||||||
l.client = client
|
|
||||||
l.session = &actions.RunnerScaleSetSession{
|
|
||||||
OwnerName: "",
|
|
||||||
RunnerScaleSet: &actions.RunnerScaleSet{},
|
|
||||||
MessageQueueUrl: "",
|
|
||||||
MessageQueueAccessToken: "",
|
|
||||||
Statistics: &actions.RunnerScaleSetStatistic{},
|
|
||||||
}
|
|
||||||
|
|
||||||
err = l.handleMessage(context.Background(), handler, msg)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
|
||||||
@@ -83,20 +83,6 @@ func (_m *Client) DeleteMessage(ctx context.Context, messageQueueUrl string, mes
|
|||||||
return r0
|
return r0
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteMessageSession provides a mock function with given fields: ctx, runnerScaleSetId, sessionId
|
|
||||||
func (_m *Client) DeleteMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error {
|
|
||||||
ret := _m.Called(ctx, runnerScaleSetId, sessionId)
|
|
||||||
|
|
||||||
var r0 error
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, int, *uuid.UUID) error); ok {
|
|
||||||
r0 = rf(ctx, runnerScaleSetId, sessionId)
|
|
||||||
} else {
|
|
||||||
r0 = ret.Error(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAcquirableJobs provides a mock function with given fields: ctx, runnerScaleSetId
|
// GetAcquirableJobs provides a mock function with given fields: ctx, runnerScaleSetId
|
||||||
func (_m *Client) GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*actions.AcquirableJobList, error) {
|
func (_m *Client) GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*actions.AcquirableJobList, error) {
|
||||||
ret := _m.Called(ctx, runnerScaleSetId)
|
ret := _m.Called(ctx, runnerScaleSetId)
|
||||||
|
|||||||
@@ -15,28 +15,18 @@ type Handler struct {
|
|||||||
mock.Mock
|
mock.Mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleDesiredRunnerCount provides a mock function with given fields: ctx, count
|
// HandleDesiredRunnerCount provides a mock function with given fields: ctx, desiredRunnerCount
|
||||||
func (_m *Handler) HandleDesiredRunnerCount(ctx context.Context, count int) (int, error) {
|
func (_m *Handler) HandleDesiredRunnerCount(ctx context.Context, desiredRunnerCount int) error {
|
||||||
ret := _m.Called(ctx, count)
|
ret := _m.Called(ctx, desiredRunnerCount)
|
||||||
|
|
||||||
var r0 int
|
var r0 error
|
||||||
var r1 error
|
if rf, ok := ret.Get(0).(func(context.Context, int) error); ok {
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, int) (int, error)); ok {
|
r0 = rf(ctx, desiredRunnerCount)
|
||||||
return rf(ctx, count)
|
|
||||||
}
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, int) int); ok {
|
|
||||||
r0 = rf(ctx, count)
|
|
||||||
} else {
|
} else {
|
||||||
r0 = ret.Get(0).(int)
|
r0 = ret.Error(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(context.Context, int) error); ok {
|
return r0
|
||||||
r1 = rf(ctx, count)
|
|
||||||
} else {
|
|
||||||
r1 = ret.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0, r1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleJobStarted provides a mock function with given fields: ctx, jobInfo
|
// HandleJobStarted provides a mock function with given fields: ctx, jobInfo
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/actions/actions-runner-controller/logging"
|
"github.com/actions/actions-runner-controller/logging"
|
||||||
jsonpatch "github.com/evanphx/json-patch"
|
jsonpatch "github.com/evanphx/json-patch"
|
||||||
"github.com/go-logr/logr"
|
"github.com/go-logr/logr"
|
||||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
@@ -142,10 +141,6 @@ func (w *Worker) HandleJobStarted(ctx context.Context, jobInfo *actions.JobStart
|
|||||||
Do(ctx).
|
Do(ctx).
|
||||||
Into(patchedStatus)
|
Into(patchedStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if kerrors.IsNotFound(err) {
|
|
||||||
w.logger.Info("Ephemeral runner not found, skipping patching of ephemeral runner status", "runnerName", jobInfo.RunnerName)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("could not patch ephemeral runner status, patch JSON: %s, error: %w", string(mergePatch), err)
|
return fmt.Errorf("could not patch ephemeral runner status, patch JSON: %s, error: %w", string(mergePatch), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +156,7 @@ func (w *Worker) HandleJobStarted(ctx context.Context, jobInfo *actions.JobStart
|
|||||||
// The function then scales the ephemeral runner set by applying the merge patch.
|
// The function then scales the ephemeral runner set by applying the merge patch.
|
||||||
// Finally, it logs the scaled ephemeral runner set details and returns nil if successful.
|
// Finally, it logs the scaled ephemeral runner set details and returns nil if successful.
|
||||||
// If any error occurs during the process, it returns an error with a descriptive message.
|
// If any error occurs during the process, it returns an error with a descriptive message.
|
||||||
func (w *Worker) HandleDesiredRunnerCount(ctx context.Context, count int) (int, error) {
|
func (w *Worker) HandleDesiredRunnerCount(ctx context.Context, count int) error {
|
||||||
// Max runners should always be set by the resource builder either to the configured value,
|
// Max runners should always be set by the resource builder either to the configured value,
|
||||||
// or the maximum int32 (resourcebuilder.newAutoScalingListener()).
|
// or the maximum int32 (resourcebuilder.newAutoScalingListener()).
|
||||||
targetRunnerCount := min(w.config.MinRunners+count, w.config.MaxRunners)
|
targetRunnerCount := min(w.config.MinRunners+count, w.config.MaxRunners)
|
||||||
@@ -176,7 +171,7 @@ func (w *Worker) HandleDesiredRunnerCount(ctx context.Context, count int) (int,
|
|||||||
|
|
||||||
if targetRunnerCount == w.lastPatch {
|
if targetRunnerCount == w.lastPatch {
|
||||||
w.logger.Info("Skipping patching of EphemeralRunnerSet as the desired count has not changed", logValues...)
|
w.logger.Info("Skipping patching of EphemeralRunnerSet as the desired count has not changed", logValues...)
|
||||||
return targetRunnerCount, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
original, err := json.Marshal(
|
original, err := json.Marshal(
|
||||||
@@ -187,7 +182,7 @@ func (w *Worker) HandleDesiredRunnerCount(ctx context.Context, count int) (int,
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("failed to marshal empty ephemeral runner set: %w", err)
|
return fmt.Errorf("failed to marshal empty ephemeral runner set: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
patch, err := json.Marshal(
|
patch, err := json.Marshal(
|
||||||
@@ -199,12 +194,12 @@ func (w *Worker) HandleDesiredRunnerCount(ctx context.Context, count int) (int,
|
|||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.logger.Error(err, "could not marshal patch ephemeral runner set")
|
w.logger.Error(err, "could not marshal patch ephemeral runner set")
|
||||||
return 0, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mergePatch, err := jsonpatch.CreateMergePatch(original, patch)
|
mergePatch, err := jsonpatch.CreateMergePatch(original, patch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("failed to create merge patch json for ephemeral runner set: %w", err)
|
return fmt.Errorf("failed to create merge patch json for ephemeral runner set: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.logger.Info("Created merge patch json for EphemeralRunnerSet update", "json", string(mergePatch))
|
w.logger.Info("Created merge patch json for EphemeralRunnerSet update", "json", string(mergePatch))
|
||||||
@@ -222,7 +217,7 @@ func (w *Worker) HandleDesiredRunnerCount(ctx context.Context, count int) (int,
|
|||||||
Do(ctx).
|
Do(ctx).
|
||||||
Into(patchedEphemeralRunnerSet)
|
Into(patchedEphemeralRunnerSet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("could not patch ephemeral runner set , patch JSON: %s, error: %w", string(mergePatch), err)
|
return fmt.Errorf("could not patch ephemeral runner set , patch JSON: %s, error: %w", string(mergePatch), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.logger.Info("Ephemeral runner set scaled.",
|
w.logger.Info("Ephemeral runner set scaled.",
|
||||||
@@ -230,5 +225,5 @@ func (w *Worker) HandleDesiredRunnerCount(ctx context.Context, count int) (int,
|
|||||||
"name", w.config.EphemeralRunnerSetName,
|
"name", w.config.EphemeralRunnerSetName,
|
||||||
"replicas", patchedEphemeralRunnerSet.Spec.Replicas,
|
"replicas", patchedEphemeralRunnerSet.Spec.Replicas,
|
||||||
)
|
)
|
||||||
return targetRunnerCount, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,7 +226,6 @@ func (b *resourceBuilder) newScaleSetListenerPod(autoscalingListener *v1alpha1.A
|
|||||||
ports = append(ports, port)
|
ports = append(ports, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
terminationGracePeriodSeconds := int64(60)
|
|
||||||
podSpec := corev1.PodSpec{
|
podSpec := corev1.PodSpec{
|
||||||
ServiceAccountName: serviceAccount.Name,
|
ServiceAccountName: serviceAccount.Name,
|
||||||
Containers: []corev1.Container{
|
Containers: []corev1.Container{
|
||||||
@@ -257,9 +256,8 @@ func (b *resourceBuilder) newScaleSetListenerPod(autoscalingListener *v1alpha1.A
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ImagePullSecrets: autoscalingListener.Spec.ImagePullSecrets,
|
ImagePullSecrets: autoscalingListener.Spec.ImagePullSecrets,
|
||||||
RestartPolicy: corev1.RestartPolicyNever,
|
RestartPolicy: corev1.RestartPolicyNever,
|
||||||
TerminationGracePeriodSeconds: &terminationGracePeriodSeconds,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
labels := make(map[string]string, len(autoscalingListener.Labels))
|
labels := make(map[string]string, len(autoscalingListener.Labels))
|
||||||
|
|||||||
@@ -43,11 +43,6 @@ You can follow [this troubleshooting guide](https://docs.github.com/en/actions/h
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### v0.8.2
|
|
||||||
1. Add listener graceful termination period and background context after the message is received [#3187](https://github.com/actions/actions-runner-controller/pull/3187)
|
|
||||||
1. Publish metrics in the new ghalistener [#3193](https://github.com/actions/actions-runner-controller/pull/3193)
|
|
||||||
1. Delete message session when listener.Listen returns [#3240](https://github.com/actions/actions-runner-controller/pull/3240)
|
|
||||||
|
|
||||||
### v0.8.1
|
### v0.8.1
|
||||||
1. Fix proxy issue in new listener client [#3181](https://github.com/actions/actions-runner-controller/pull/3181)
|
1. Fix proxy issue in new listener client [#3181](https://github.com/actions/actions-runner-controller/pull/3181)
|
||||||
|
|
||||||
|
|||||||
@@ -12,4 +12,4 @@ We do not intend to provide a supported ARC dashboard. This is simply a referenc
|
|||||||
|
|
||||||
1. Make sure to have [Grafana](https://grafana.com/docs/grafana/latest/installation/) and [Prometheus](https://prometheus.io/docs/prometheus/latest/installation/) running in your cluster.
|
1. Make sure to have [Grafana](https://grafana.com/docs/grafana/latest/installation/) and [Prometheus](https://prometheus.io/docs/prometheus/latest/installation/) running in your cluster.
|
||||||
2. Make sure that Prometheus is properly scraping the metrics endpoints of the controller-manager and listeners.
|
2. Make sure that Prometheus is properly scraping the metrics endpoints of the controller-manager and listeners.
|
||||||
3. Import the [dashboard](ARC-Autoscaling-Runner-Set-Monitoring_1692627561838.json) into Grafana.
|
3. Import the [dashboard](ARC-Autoscaling-Runner-Set-Monitoring_1692627561838.json.json) into Grafana.
|
||||||
|
|||||||
@@ -640,11 +640,8 @@ func (c *Client) doSessionRequest(ctx context.Context, method, path string, requ
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode == expectedResponseStatusCode {
|
if resp.StatusCode == expectedResponseStatusCode && responseUnmarshalTarget != nil {
|
||||||
if responseUnmarshalTarget != nil {
|
return json.NewDecoder(resp.Body).Decode(responseUnmarshalTarget)
|
||||||
return json.NewDecoder(resp.Body).Decode(responseUnmarshalTarget)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode >= 400 && resp.StatusCode < 500 {
|
if resp.StatusCode >= 400 && resp.StatusCode < 500 {
|
||||||
|
|||||||
34
github/actions/testdata/rootCA.crt
vendored
34
github/actions/testdata/rootCA.crt
vendored
@@ -1,20 +1,18 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIIDVTCCAj2gAwIBAgIUOo9VGKll71GYjunZhdMQhS5rP+gwDQYJKoZIhvcNAQEL
|
MIIC6jCCAdICCQCoZFduxPa/eDANBgkqhkiG9w0BAQsFADA2MQswCQYDVQQGEwJV
|
||||||
BQAwOTESMBAGA1UEAwwJbG9jYWxob3N0MQswCQYDVQQGEwJVUzEWMBQGA1UEBwwN
|
UzEnMCUGA1UEAwweYWN0aW9ucy1ydW5uZXItY29udHJvbGxlci10ZXN0MCAXDTIz
|
||||||
U2FuIEZyYW5zaXNjbzAgFw0yNDAxMjIxMjUyNTdaGA8yMDUxMDYwODEyNTI1N1ow
|
MDExOTE2NTAwMVoYDzIwNTAwNjA1MTY1MDAxWjA2MQswCQYDVQQGEwJVUzEnMCUG
|
||||||
OTESMBAGA1UEAwwJbG9jYWxob3N0MQswCQYDVQQGEwJVUzEWMBQGA1UEBwwNU2Fu
|
A1UEAwweYWN0aW9ucy1ydW5uZXItY29udHJvbGxlci10ZXN0MIIBIjANBgkqhkiG
|
||||||
IEZyYW5zaXNjbzCCASIwDQYJK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GyT5S
|
||||||
MAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHZ/Z3CSrPoWb02+iu1cUN8nlQBtAsxI
|
erjpPcJjQnvZyMHLH9DGGWE9UCyqKIqmaEc9bwr2oz1+a0rsaS3ZdIFlQibBHij5
|
||||||
oR3nqhUSEA/9oyyXJt8NIIXauACyYzmNXG87aKQZvVzUEQM0aK4MBq+Pg0Zdnvns
|
tdJcnzXfN4T4GIbYXKMCOYDy/5CiNJ26l/pQNpO9JCzsEmngw0ooS0Bi8EcTCgB6
|
||||||
8QtBvdro7jInHhfn4uS8X21Fa1gYZ0d0C6UHIXUeD9KSEOAX1JT+3VP/7FNIDzns
|
dsHl0w8va3l1kvxWWIlNTGwrAEpRbXmL01hAqx2yCiaFPVZ/eRNWmBWO4LpW4ouK
|
||||||
2ddSxzcji3eVFkDR4/1vRMTng/kiP5vFz1St1op2EYDT+v6PVr9ew3NWUf/w7fgP
|
YOaA+X7geM6XVFlZE3cP58AxYKWHGAThxkZbD5cu
|
||||||
sRRyx3qi7m8SRHc7FwDLk+6/zc1/14YIiX9PrvVmnJj0yULSHiBu4cQccKE2ibos
|
|
||||||
ZeUPfZL8Kl+hs/MtXG/XlYBbApm69eo7EEGHAS/2DIq2yPgsQrGMYkA=
|
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
|||||||
41
github/actions/testdata/server.crt
vendored
41
github/actions/testdata/server.crt
vendored
@@ -1,23 +1,22 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIIDyDCCArCgAwIBAgIUKCU/uCdz/9EcfzL6wd7ubSPrsxIwDQYJKoZIhvcNAQEL
|
MIIDnTCCAoWgAwIBAgIJAJskDVhiEY6fMA0GCSqGSIb3DQEBCwUAMDYxCzAJBgNV
|
||||||
BQAwOTESMBAGA1UEAwwJbG9jYWxob3N0MQswCQYDVQQGEwJVUzEWMBQGA1UEBwwN
|
BAYTAlVTMScwJQYDV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KM3t9fsff8KDaRQ2sdSUEjqtAlfg6bbBwO66CICXLU+VUH7hOVghT23UJVvwNY
|
MZhhSqjxM+Nnmhpy4My6oHVrdYWHcuVhzlEmNaMtmJCYuihIyD2Usn32xJK1k89d
|
||||||
Dvkha9TYR+aawRypLoTfT5ZtLp/0A9P+liqo6F5Xm0M89bYLXNPl1fPzY3Ihi5Jd
|
WgEOPCk+ZDAligPlGZS201fsznJk5uIjmxPjjFlJLXotBs8H7j0cQ2JkV5YHsHCk
|
||||||
b6/mttpY9gxTfbw67m2Epfmt1NdOHkY7ac/Hr6pt/YyMBrPz9Z3eZxIXUIVDo/Nh
|
EYf5EJ0ZKtZbwRFeRC1Ajxg=
|
||||||
4O2g9RoFFN4m3A+d
|
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
|||||||
55
github/actions/testdata/server.key
vendored
55
github/actions/testdata/server.key
vendored
@@ -1,28 +1,27 @@
|
|||||||
-----BEGIN PRIVATE KEY-----
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCtVDvIccDF6Fyw
|
MIIEowIBAAKCAQEAzOTt1/VjuaHzn+b7jLeufW3rxLHFKQV+LiUiT389rbFGY+DN
|
||||||
5bw00SmWsQX/jyf35cJzhla7Qt090oCNzAxIB10e8tlWnk5Q1FNQqDBZ8vkPIYWc
|
CC+Nzx+DbFBpKcX/scseVhFzlXlrESWWZ4h7LGMXRsTDKs91F1RMuFCd8eIEwbuV
|
||||||
CFJnfUCDcUfKg4ELkFBIER37Gw7UZ+W3w+bQDtM3aPOVXHuurWPuRnbkBlj2gnqK
|
civR44IqT5r/0hlMOWemd3Fh/c8KF+9dWQ0q0T3tvlVzEbWNRTVAXTT4JzizqNd1
|
||||||
krgd/iZht9JHlyUzZYoE8aT0ltiYjuXS3chgub3njHF820/GvW0QDCTvlQAo1ZcH
|
1hhnuV/KjhiptPC/8jQ4D9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V4IWj669Sa7BJsBjiS9nC6F1pHiVAoGBALBT
|
HLZYvqT+FF6g+QuvrPwmWQKBgAQspVvReQqU1EUie3feAzcGbtOLKUNXvuI04orq
|
||||||
fFxPZFBuAFvHlTIJXUa3I5A+zdckSCVnerVjKFiO+tb+VvttSK4qo6gnEzzcp4+3
|
1oC3qU5VN6SUgb7Aj87z7zoc4qNN5kCSXMsVbuHWEQ5thL3wKMcXoQoo9Xpgewjy
|
||||||
PP6OyNAfyee2xHMZPhZB3WrVWjaYznylTJ6Q6bsn4+DOpm0Sh2dlXEB6fylj2qE7
|
h9Herw9R9/5kUpY7xfsFL4dW7vUga82tH14iQrVtyBz+t+I5cgdhoxJd2EM5hjCE
|
||||||
gCAVxrZchH6Kgu0h6H2QTsuKwS2ZNHr49HbSWpNZAoGBAMrEMiyKYWKgiejs69pj
|
PNnNAoGBALPjmvEZ1HJdCOxY/AisziVtOFc6Glk/KhpSIT7WE1me4qLQFmrsHIDQ
|
||||||
idKifoCDI+Hu1WD/eViUm2OuOfdW9fIBHoeuKmOBKGYIqx5yEbFhXoJmTtJ1aSa1
|
kZ8Sb1f3PQ4T4vHGrtl8qh144MJPI1Nb8klzdlD1xeypGpgXoQb5fsC17g1fgczp
|
||||||
+N+0NBzv9+1W5EII0voELevxLvjeaejcUgLNabGIj1xIcPzaEKTS+Vv2Hn6nffWR
|
TGzq3pvnlGnrgVmnfrWQCHXDLzXtLqM/Pu84guPFftJQ+++yy0np
|
||||||
yKlIixoSTJ+oJShyT9DZyZAd
|
-----END RSA PRIVATE KEY-----
|
||||||
-----END PRIVATE KEY-----
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ DIND_ROOTLESS_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind-rootless
|
|||||||
OS_IMAGE ?= ubuntu-22.04
|
OS_IMAGE ?= ubuntu-22.04
|
||||||
TARGETPLATFORM ?= $(shell arch)
|
TARGETPLATFORM ?= $(shell arch)
|
||||||
|
|
||||||
RUNNER_VERSION ?= 2.312.0
|
RUNNER_VERSION ?= 2.311.0
|
||||||
RUNNER_CONTAINER_HOOKS_VERSION ?= 0.5.1
|
RUNNER_CONTAINER_HOOKS_VERSION ?= 0.5.0
|
||||||
DOCKER_VERSION ?= 24.0.7
|
DOCKER_VERSION ?= 24.0.7
|
||||||
|
|
||||||
# default list of platforms for which multiarch image is built
|
# default list of platforms for which multiarch image is built
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
RUNNER_VERSION=2.312.0
|
RUNNER_VERSION=2.311.0
|
||||||
RUNNER_CONTAINER_HOOKS_VERSION=0.5.1
|
RUNNER_CONTAINER_HOOKS_VERSION=0.5.0
|
||||||
@@ -36,8 +36,8 @@ var (
|
|||||||
|
|
||||||
testResultCMNamePrefix = "test-result-"
|
testResultCMNamePrefix = "test-result-"
|
||||||
|
|
||||||
RunnerVersion = "2.312.0"
|
RunnerVersion = "2.311.0"
|
||||||
RunnerContainerHooksVersion = "0.5.1"
|
RunnerContainerHooksVersion = "0.5.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
// If you're willing to run this test via VS Code "run test" or "debug test",
|
// If you're willing to run this test via VS Code "run test" or "debug test",
|
||||||
|
|||||||
Reference in New Issue
Block a user