Skip to content

Dt e3 0 update #304

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

Open
wants to merge 105 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
fab7c08
pass :keep_netrc preference to the worker
svenfuchs Mar 13, 2019
f2e72af
Merge pull request #3 from travis-pro/sf-keep_netrc
svenfuchs Mar 15, 2019
4a382f9
Added preferences method
cotsog Mar 15, 2019
248945a
Added preferences method to User class too.
cotsog Mar 15, 2019
dc4a2be
Merge pull request #4 from travis-pro/dj-netrc-fix
cotsog Mar 15, 2019
455b3f0
use config import for db setup
svenfuchs May 23, 2019
e8f725d
Update .travis.yml
svenfuchs May 23, 2019
f106d61
Don't include migrated jobs when calculating concurrency
drogus May 29, 2019
f88746a
Don't enqueue jobs that are migrated from .org
drogus May 29, 2019
6d765e0
Put workspace_settings on payload
BanzaiMan Jun 19, 2019
ed7692e
Fix workspace_settings
BanzaiMan Jun 19, 2019
4a1c644
Environment variables can be restricted to specified branch
piotr-travisci Jun 28, 2019
e9ffa09
Env model extended
piotr-travisci Jun 28, 2019
c2c73c8
Tests fixes
piotr-travisci Jun 28, 2019
88f4609
Return type improvement
piotr-travisci Jun 28, 2019
2936ca8
Test fixed
piotr-travisci Jun 28, 2019
0b795d7
Test fix
piotr-travisci Jun 28, 2019
e51a0b0
Rename workspace_settings to workspace
BanzaiMan Jul 1, 2019
f64bddc
Don't count migrated jobs towards concurrency and don't enqueue them …
drogus Jul 2, 2019
f071b95
allow env vars to be hashes
svenfuchs Sep 18, 2019
6f0b2a1
do not decrypt values that are not a String or Hash
svenfuchs Sep 19, 2019
b5baad3
Merge pull request #5 from travis-pro/sf-private
svenfuchs Sep 20, 2019
4e2bad2
Revert "use config import for db setup"
svenfuchs Sep 20, 2019
059fc53
Revert "Update .travis.yml"
svenfuchs Sep 20, 2019
219e895
Merge pull request #196 from travis-ci/pd-oss-only-arm
pavel-d Oct 1, 2019
41f93e4
Merge pull request #197 from travis-ci/pd-ibm-oss-only
pavel-d Oct 8, 2019
899bd02
Allow IBM z builds for Open Source only
pavel-d Oct 31, 2019
b879509
Merge pull request #8 from travis-pro/pd-limit-z-queues
pavel-d Nov 4, 2019
5f0a570
Revert "Allow IBM z builds for Open Source only"
pavel-d Nov 6, 2019
11b9b24
Merge pull request #9 from travis-pro/revert-8-pd-limit-z-queues
pavel-d Nov 6, 2019
8768efb
Merge pull request #199 from travis-ci/pd-limit-z-queues-public
pavel-d Nov 6, 2019
e5af52e
output a more useful message when decryption failed
svenfuchs Nov 7, 2019
afde6c8
remove all scheduler/limit codepath
svenfuchs Nov 18, 2019
83cb0b0
Merge pull request #201 from travis-ci/default-cache
DamianSzymanski Nov 27, 2019
d2f4ff9
Merge branch 'master' of https://github.com/travis-pro/travis-scheduler
BanzaiMan Nov 27, 2019
72b0fb6
Revert "Use OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING when encrypting"
svenfuchs Nov 29, 2019
3854893
Merge remote-tracking branch 'origin/master'
svenfuchs Jan 24, 2020
7b7b75c
Merge remote-tracking branch 'origin/master'
svenfuchs Jan 24, 2020
d82809f
Merge remote-tracking branch 'origin/master'
svenfuchs Jan 24, 2020
7a52acc
add warning
svenfuchs Feb 7, 2020
e0a5134
allow setting queue size as env var
svenfuchs Feb 7, 2020
3772b1d
fix msg key
svenfuchs Feb 14, 2020
702876c
pass secrets to build
svenfuchs Feb 17, 2020
901291f
do not try to decrypt non-string values
svenfuchs Mar 3, 2020
1c0902c
Merge branch 'master' of https://github.com/travis-pro/travis-scheduler
piotr-travisci Mar 11, 2020
2d0c097
incomming change
piotr-travisci Mar 11, 2020
452ebcd
Merge branch 'master' of https://github.com/travis-ci/travis-scheduler
piotr-travisci Mar 13, 2020
3c39d86
Merge branch 'master' of https://github.com/travis-ci/travis-scheduler
piotr-travisci Mar 13, 2020
5534a6b
Merge branch 'master' of https://github.com/travis-ci/travis-scheduler
piotr-travisci Mar 16, 2020
027b7b1
bump rake
svenfuchs Mar 17, 2020
7816288
let capacities add up, no matter their type
svenfuchs Mar 17, 2020
e64b55d
Merge branch 'master' of https://github.com/travis-pro/travis-scheduler
BanzaiMan Mar 31, 2020
ed06036
unconditional build accept for enterprise
GbArc Apr 2, 2020
86d81ac
Merge pull request #11 from travis-pro/ga-enterprise_cap
GbArc Apr 16, 2020
4deb250
Merge remote-tracking branch 'pro/master'
eugene-travis Apr 17, 2020
63814d7
empty commit to trigger a build
eugene-travis Apr 17, 2020
28a5cb4
ruby encoder added (#13)
Tahsin-travis-ci Apr 17, 2020
a98610a
Revert "ruby encoder added (#13)" (#15)
Tahsin-travis-ci Apr 20, 2020
7f5dfdc
Merge branch 'master' of https://github.com/travis-pro/travis-scheduler
Tahsin-travis-ci May 18, 2020
bea2d70
deploy on master
eugene-travis May 20, 2020
b0c526c
Merge pull request #16 from travis-pro/deploy
eugene-travis May 20, 2020
817fc5e
newer docker
eugene-travis May 20, 2020
388a525
Merge pull request #17 from travis-pro/deploy
eugene-travis May 20, 2020
0da2b02
simplify deploy
eugene-travis May 21, 2020
24c9756
type attribute
eugene-travis May 21, 2020
5bbfc9c
Merge pull request #18 from travis-pro/deploy
eugene-travis May 21, 2020
799ea4f
resolved conflicts
tahsin352 Jun 9, 2020
700c08c
Empty commit for allowing deployment
BanzaiMan Aug 12, 2020
120b868
Merge branch 'master' of https://github.com/travis-pro/travis-scheduler
BanzaiMan Aug 12, 2020
18c1c62
Empty commit for allowing deployment
BanzaiMan Aug 12, 2020
1f132d0
Merge branch 'master' of https://github.com/travis-ci/travis-scheduler
BanzaiMan Aug 13, 2020
5156cf6
Update OS for enterprise ship:docker
DamianSzymanski Mar 24, 2021
2e89e78
security updates (#255)
GbArc Apr 21, 2021
d9f80dc
docker fix+trivy
GbArc Jul 7, 2021
fea81a6
trivy fix
GbArc Jul 7, 2021
0ddc5e6
gh update
GbArc Aug 2, 2021
f01527f
added amqp queue check (flag AMQP_QUEUE_VALIDATION)
GbArc Aug 19, 2021
b9b568c
update to use latest docker
GbArc Oct 21, 2021
b8ad401
addressable -> 2.8.0
GbArc Oct 21, 2021
3762a4f
hard limit (#266)
GbArc Dec 27, 2021
61783a5
sharing envs to forks (#272)
GbArc Mar 10, 2022
bafcd03
slow scheduler fix (#273)
GbArc Mar 16, 2022
00d8750
upgrade gems (#271)
makemp May 17, 2022
8d1299b
using base repo key in forks if no custom key is available in base
GbArc May 19, 2022
b5ff0df
removed trivy
GbArc May 19, 2022
31ac5ba
fixed ssh key specs
GbArc May 19, 2022
58dbb78
rack update -> 2.2.3.1
GbArc Jun 8, 2022
f31e9a3
activerecord bump to 6.1.6.1
GbArc Aug 22, 2022
0152ef2
image size reduction (#283)
GbArc Oct 5, 2022
022eff3
merge from master (#288)
GbArc Dec 14, 2022
ae102f5
activerecord up to 6.1.7.2
GbArc Feb 2, 2023
6bed9d0
updated matcher to allow priv repos for arm64,s390x in enterprise [sh…
gbarc-dt May 11, 2023
ec52f0a
Using proper key for forked secrets (#296)
GbArc May 26, 2023
79d54c1
Stop jobs from being queued if the build has been cancelled (#298)
piccadilly-circus Aug 28, 2023
7c7c654
Stages are not always used ship:docker (#299)
piccadilly-circus Aug 31, 2023
da76215
Stop build from not getting queued (#300)
piccadilly-circus Oct 12, 2023
d16a4b4
Restrict ruby gem-update version (#302)
piccadilly-circus Jan 3, 2024
ba23d18
Scheduler merge. Enterprise to master.
Mar 15, 2024
1d6f840
TravisCI Scheduler merge. Enterprise to master.
Mar 25, 2024
1044296
TravisCI Scheduler merge. Enterprise to master.
Mar 26, 2024
846ae7f
TravisCI Scheduler. New line issue.
Apr 2, 2024
cd7bd69
billing get corrected, job save removed
gbarc-dt Apr 2, 2024
353bc62
dist updated to focal / ship:docker
gbarc-dt Apr 2, 2024
d3ce4e9
removed duplicates from dockerfile, moved exec-hooks / ship:docker
gbarc-dt Apr 2, 2024
8cc1bfd
dockerfile split ship:docker
gbarc-dt Apr 12, 2024
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
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ env:
matrix:
- RAKE_TASK=spec
global:
secure: BdVC3OHqYcgePLrkKIk28Ewn/dxCYFf3Cx+Q8P+BCDj6UPJyRSbKmILBzuX96H5xhKmUFo0A/upUhJI9UUP9aXHO7MzRe04/c88QdO4wGacVUaIyB20S0pr262zbc/nA50K9cVgpmWc64n6uQR1tgM6ZyyBnBeXkLzCAOHPq99I=
- secure: BdVC3OHqYcgePLrkKIk28Ewn/dxCYFf3Cx+Q8P+BCDj6UPJyRSbKmILBzuX96H5xhKmUFo0A/upUhJI9UUP9aXHO7MzRe04/c88QdO4wGacVUaIyB20S0pr262zbc/nA50K9cVgpmWc64n6uQR1tgM6ZyyBnBeXkLzCAOHPq99I=
- PATH=/snap/bin:$PATH

before_install:
- gem uninstall -v '>=2' -i $(rvm gemdir)@global -ax bundler || true
- gem install bundler -v '2.3.7'
- gem install rubygems-update -v 3.4.22

addons:
apt:
- apt:
packages:
- rabbitmq-server

Expand All @@ -27,12 +33,13 @@ jobs:
- stage: "testing time"
script: bundle exec rspec spec
- stage: ":ship: it to quay.io"
dist: bionic
dist: focal
group: edge
ruby:
services:
addons:
before_install: skip
before_script: skip
install: skip
script: make ship
if: commit_message =~ /ship:docker/ OR env(SHIP_DOCKER) = true
if: (branch = master and type = push ) OR commit_message =~ /ship:docker/ OR env(SHIP_DOCKER) = true
36 changes: 36 additions & 0 deletions Dockerfile.tcie
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ruby:3.2.2-slim

LABEL maintainer Travis CI GmbH <[email protected]>

RUN ( \
bundle config set no-cache 'true'; \
bundle config --global frozen 1; \
bundle config set deployment 'true'; \
mkdir -p /app; \
)
WORKDIR /app
COPY Gemfile* /app/
ARG bundle_gems__contribsys__com
RUN ( \
apt-get update ; \
apt-get upgrade -y ; \
apt-get install -y --no-install-recommends git make gcc g++ libpq-dev libjemalloc-dev libcurl4 \
&& rm -rf /var/lib/apt/lists/*; \
gem update --system; \
gem install bundler -v '2.3.24'; \
bundle config https://gems.contribsys.com/ $bundle_gems__contribsys__com; \
bundle config set without 'development test'; \
bundle install; \
bundle config --delete https://gems.contribsys.com; \
gem install --user-install executable-hooks \
apt-get remove -y gcc g++ make git perl && apt-get -y autoremove; \
bundle clean && rm -rf /app/vendor/bundle/ruby/2.7.0/cache/*; \
for i in `find /app/vendor/ -name \*.o -o -name \*.c -o -name \*.h`; do rm -f $i; done; \
)

ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

# throw errors if Gemfile has been modified since Gemfile.lock
COPY . /app

CMD ["bundle", "exec", "bin/sidekiq-pgbouncer", "${SIDEKIQ_CONCURRENCY:-5}", "${SIDEKIQ_QUEUE:-scheduler}"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DOCKER ?= docker

.PHONY: docker-build
docker-build:
$(DOCKER) build --build-arg bundle_gems__contribsys__com=$(BUNDLE_GEMS__CONTRIBSYS__COM) -t $(DOCKER_DEST) .
$(DOCKER) build --no-cache --pull --build-arg bundle_gems__contribsys__com=$(BUNDLE_GEMS__CONTRIBSYS__COM) -t $(DOCKER_DEST) . -f Dockerfile.tcie

.PHONY: docker-login
docker-login:
Expand All @@ -52,7 +52,7 @@ docker-push-branch:
.PHONY: ship
ship: docker-build docker-login

ifeq ($(BRANCH),master)
ifeq ($(TRAVIS_BRANCH),master)
ifeq ($(TRAVIS_PULL_REQUEST),false)
ship: docker-push-latest-master
endif
Expand Down
1 change: 0 additions & 1 deletion bin/sidekiq
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

threads=${SIDEKIQ_THREADS:-8}
index=$(echo ${DYNO:-1} | sed 's/.*\.//')
queues=$@

export RUBYOPT="-Ilib $RUBYOPT"
Expand Down
1 change: 1 addition & 0 deletions lib/travis/amqp/publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def initialize(routing_key, options = {})
def publish(data, options = {})
return unless data

Amqp.logger.warn "Queue #{routing_key} doesn't exist!" if ENV['AMQP_QUEUE_VALIDATION'] && !Amqp.connection.queue_exists?(routing_key)
data = MultiJson.encode(data)
exchange.publish(data, deep_merge(default_data, options))
debug "Published AMQP message to #{routing_key}."
Expand Down
10 changes: 7 additions & 3 deletions lib/travis/queue/matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def paid
job.paid?
end

def repo_private
def repo_private
job.private?
end

Expand Down Expand Up @@ -90,7 +90,7 @@ def resources
end

def arch
return nil if job.private? && OSS_ONLY_ARCH.include?(job.config[:arch])
return nil if job.private? && OSS_ONLY_ARCH.include?(job.config[:arch]) && !enterprise?

job.config[:arch]
end
Expand All @@ -99,7 +99,7 @@ def virt
job.config[:virt]
end

def vm_size
def vm_size
job.config[:vm][:size] if job.config[:vm]
end

Expand All @@ -115,6 +115,10 @@ def check_unknown_matchers(used)
unknown = used - KEYS
logger.warn format(MSGS[:unknown_matchers], used, unknown, repo.slug) if logger && unknown.any?
end

def enterprise?
!!Travis::Scheduler.context.config[:enterprise]
end
end
end
end
5 changes: 4 additions & 1 deletion lib/travis/scheduler/billing/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ def request(method, path, params)

def get(path, params = {})
body = request(:get, path, params).body
body&.length&.to_i > 0 && body.is_a?(String) ? JSON.parse(body) : body
return {} unless body&.length&.to_i > 0

body.is_a?(String) ? JSON.parse(body) : body
end

def post(path, params = {})
body = request(:post, path, params).body

body&.length&.to_i > 0 && body.is_a?(String) ? JSON.parse(body) : body
end

Expand Down
2 changes: 1 addition & 1 deletion lib/travis/scheduler/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Config < Travis::Config
enterprise: false,
github: { api_url: 'https://api.github.com', source_host: 'github.com' },
billing: { url: 'http://localhost:9292/', auth_key: 'auth_keys' },
host: 'https://travis-ci.com',
billing: { url: 'http://localhost:9292/', auth_key: 'auth_keys' },host: 'https://travis-ci.com',
interval: 2,
limit: { public: 5, education: 1, default: 5, by_owner: {}, delegate: {} },
lock: { strategy: :redis, ttl: 150 },
Expand Down
1 change: 0 additions & 1 deletion lib/travis/scheduler/jobs/capacity/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def applicable?
def report(status, job)
super.merge(max:)
end

def accept?(job)
Copy link
Contributor

Choose a reason for hiding this comment

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

double accept?

Choose a reason for hiding this comment

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

Done.

super if !on_metered_plan? || billing_allowed?(job)
end
Expand Down
7 changes: 7 additions & 0 deletions lib/travis/scheduler/record/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def public?

def config
record = super
record = JSON.parse(record) if record.is_a?(String)
config = record&.config_json if record.respond_to?(:config_json) # TODO: remove once we've rolled over
config ||= record&.config
config ||= read_attribute(:config) if has_attribute?(:config)
Expand All @@ -112,4 +113,10 @@ def config
def name
config[:name]
end

def new_queueable
return if repository_id.blank? # to avoid trying save objects without repository_id
saved = new_record? ? save : true # saves if it is a new record
create_queueable if saved # it is allowed to create queueable records only for jobs which are persisting in the database
end
end
2 changes: 1 addition & 1 deletion lib/travis/scheduler/record/repository/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def custom_timeouts?(settings)

validates_with TimeoutsValidator

def update_attributes!(attrs)
def update!(attrs)
attrs.each { |key, value| send(:"#{key}=", value) }
save
end
Expand Down
11 changes: 7 additions & 4 deletions lib/travis/scheduler/record/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ def paid?
end

def paid_new_plan?
redis_key = "user:#{id}:plan"
redis_key = "user:#{self.id}:plan"
plan = if redis.exists?(redis_key)
JSON.parse(redis.get(redis_key))
else
p = billing_client.get_plan(self)
p.length > 0 ? p.to_h : {}
billing_client.get_plan(self).to_h
end
return false if plan[:error] || plan['plan_name'].nil?

plan['hybrid'] || !plan['plan_name'].include?('free')
end

def enterprise?
!!context.config[:enterprise]
end

def default_worker_timeout
# When the user is a paid user ("subscribed") or has an active trial, they
# are granted a different default timeout on their jobs.
Expand All @@ -60,7 +63,7 @@ def default_worker_timeout
# those enforced by workers themselves, but we plan to sometime in the
# following weeks/months.
#
if paid? || educational?
if enterprise? || paid? || educational?
Travis.logger.info "Default Timeout: DEFAULT_SUBSCRIBED_TIMEOUT for owner=#{id}"
DEFAULT_SUBSCRIBED_TIMEOUT
else
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/scheduler/serialize/worker/config/decrypt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def apply

private

def force_vault_to_be_secure!(config)
def force_vault_to_be_secure!(config)
config[:vault].delete(:token) if config.dig(:vault, :token).is_a?(String)
end

Expand Down
4 changes: 3 additions & 1 deletion lib/travis/scheduler/serialize/worker/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ def vm_configs
def job_repository
return job.repository if job.source.event_type != 'pull_request' || job.source.request.pull_request.head_repo_slug == job.source.request.pull_request.base_repo_slug

return repository if repository.settings.share_encrypted_env_with_forks

owner_name, repo_name = job.source.request.pull_request.head_repo_slug.split('/')
return if owner_name.nil? || owner_name.empty? || repo_name.nil? || repo_name.empty?

::Repository.find_by(owner_name:, name: repo_name)
::Repository.find_by(owner_name: owner_name, name: repo_name)
end

def repository_key
Expand Down
7 changes: 6 additions & 1 deletion lib/travis/scheduler/serialize/worker/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ def hard_limit_timeout
end

def timeout(type)
return unless timeout = repo.settings.send(:"timeout_#{type}")
timeout = repo.settings.send(:"timeout_#{type}")
if timeout == nil
config = Travis.config.settings&.timeouts&.defaults
timeout = config[type] if config
end
return unless timeout

timeout = Integer(timeout)
timeout * 60 # worker handles timeouts in seconds
Expand Down
5 changes: 3 additions & 2 deletions lib/travis/scheduler/service/notify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def notify_job_board

def notify_rabbitmq
info :publish, job.id, job.queue, 'rabbitmq'
amqp.publish(worker_payload, properties: { type: 'test', persistent: true })
w = worker_payload
amqp.publish(w, properties: { type: 'test', persistent: true })
end

def notify_live
Expand Down Expand Up @@ -101,7 +102,7 @@ def amqp
def redirect_queue
queue = redirections[job.queue] or return
info format(MSGS[:redirect], job.queue, queue)
job.update_attributes!(queue:)
job.update!(queue:)
end

def redirections
Expand Down
16 changes: 14 additions & 2 deletions lib/travis/scheduler/service/set_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class SetQueue < Struct.new(:context, :job, :opts)

MSGS = {
redirect: 'Found job.queue: %s. Redirecting to: %s',
queue: 'Setting queue to %s for job=%s'
queue: 'Setting queue to %s for job=%s',
canceled: 'Build %s has been canceled, job %s being canceled'
}.freeze

def run
Expand All @@ -23,7 +24,18 @@ def run
private

def queue
@queue ||= redirect(Queue.new(job, config, logger).select)
if job.stage.present? && job.stage.state == "canceled"
info MSGS[:canceled] % [job.source.id, job.id]
payload = { id: job.id, source: 'scheduler' }
Hub.push('job:cancel', payload)
else
@queue ||= redirect(Queue.new(job, config, logger).select)
end
rescue => e
puts "ERROR while trying to queue: #{e.message}"
puts "Backtrace:"
puts e.backtrace.join("\n")
@queue ||= redirect(Queue.new(job, config, logger).select)
end

# TODO: confirm we don't need queue redirection any more
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.push(*args)
'queue' => ENV['SIDEKIQ_QUEUE'] || 'scheduler',
'class' => 'Travis::Scheduler::Worker',
'args' => args.map! { |arg| arg.to_json },
'at' => args.last.is_a?(Hash) ? args.last.delete(:at) : Time.now.to_f
'at' => args.last.is_a?(Hash) ? (args.last.delete(:at) || Time.now.to_i) : Time.now.to_i
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/service/job_board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class JobBoard < Struct.new(:job_id, :data, :config, :logger)
def post
response = http.post(PATH, JSON.dump(payload))
log response.status
rescue Faraday::ClientError => e
rescue Faraday::ClientError, Faraday::ServerError => e
log e.response[:status], e.response[:body]
raise
rescue Faraday::ServerError => e
Expand Down
4 changes: 2 additions & 2 deletions spec/travis/scheduler/jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def subscribe(plan, owner = user)
describe 'with a boost of 5 and a repo settings limit 3' do
before do
redis.set("scheduler.owner.limit.#{user.login}", 5)
repo.settings.update_attributes!(maximum_number_of_builds: 3)
repo.settings.update!(maximum_number_of_builds: 3)
end

describe 'with private jobs only' do
Expand Down Expand Up @@ -569,7 +569,7 @@ def subscribe(plan, owner = user)
before do
subscribe(:two)
redis.set("scheduler.owner.limit.#{user.login}", 4)
repo.settings.update_attributes!(maximum_number_of_builds: 3)
repo.settings.update!(maximum_number_of_builds: 3)
end

describe 'with private jobs only' do
Expand Down
15 changes: 15 additions & 0 deletions spec/travis/scheduler/record/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
let(:user) { FactoryBot.create(:user) }
let(:repo) { FactoryBot.create(:repository) }
let(:authorize_build_url) { "http://localhost:9292/users/#{user.id}/plan" }
let(:repo) { FactoryBot.create(:repository) }
let(:authorize_build_url) { "http://localhost:9292/users/#{user.id}/plan" }

describe 'constants' do
# It isn't often that we see tests for constants, but these are special.
Expand Down Expand Up @@ -82,6 +84,19 @@
end
end

context "paid_new_plan? == true" do
before do
user.stubs(:paid_new_plan?).returns(true)
stub_request(:get, authorize_build_url).to_return(
body: MultiJson.dump(plan_name: 'two_concurrent_plan', hybrid: true, free: false, status: 'subscribed', metered: false)
)
end

it "returns the DEFAULT_SUBSCRIBED_TIMEOUT" do
expect(user.default_worker_timeout).to eq Organization::DEFAULT_SUBSCRIBED_TIMEOUT
end
end

context 'paid_new_plan? == true' do
before do
user.stubs(:paid_new_plan?).returns(true)
Expand Down
Loading