Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Upgrade warden to use ruby 2.1.4
Browse files Browse the repository at this point in the history
[#89148118]
  • Loading branch information
jfmyers9 authored and Dan Lavine and James Myers committed Feb 27, 2015
1 parent dbde594 commit ad18bff
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
@@ -1 +1 @@
1.9.3-p547
2.1.4
2 changes: 1 addition & 1 deletion bin/test
Expand Up @@ -6,7 +6,7 @@ set -x
# Assumes the rootfs is already installed to /var/warden/rootfs
# The warden test suite currently uses /tmp/warden/rootfs instead
mkdir -p /tmp/warden
sudo ln -sf /var/warden/rootfs /tmp/warden/rootfs
sudo ln -sf /var/warden/rootfs_lucid /tmp/warden/rootfs

# Close stdin
exec 0>&-
Expand Down
2 changes: 1 addition & 1 deletion warden-protocol/lib/warden/protocol/message.rb
Expand Up @@ -12,7 +12,7 @@ def self.generate_klass_map(suffix)
if Protocol.const_defined?(klass_name)
[const_get(name), Protocol.const_get(klass_name)]
end
end]
end.compact]

if map.respond_to?(:default_proc=)
map.default_proc = lambda do |h, k|
Expand Down
2 changes: 1 addition & 1 deletion warden/Gemfile
Expand Up @@ -3,7 +3,7 @@ source "http://rubygems.org"
gem "rake"
gem "steno", "~> 0.0.15", :git => 'https://github.com/cloudfoundry/steno.git'
gem "membrane", :git => 'https://github.com/cloudfoundry/membrane.git'
gem "eventmachine", "~> 1.0.0"
gem "eventmachine", "1.0.3"
gem "em-posix-spawn", :git => 'https://github.com/cloudfoundry/common.git'
gem "yajl-ruby"
gem "pidfile"
Expand Down
4 changes: 2 additions & 2 deletions warden/Gemfile.lock
Expand Up @@ -37,7 +37,7 @@ GEM
specs:
beefcake (0.3.7)
diff-lcs (1.1.3)
eventmachine (1.0.0)
eventmachine (1.0.3)
grape (0.2.1)
hashie (~> 1.2)
multi_json
Expand Down Expand Up @@ -68,7 +68,7 @@ PLATFORMS

DEPENDENCIES
em-posix-spawn!
eventmachine (~> 1.0.0)
eventmachine (= 1.0.3)
membrane!
pidfile
rake
Expand Down
17 changes: 12 additions & 5 deletions warden/lib/warden/container/features/mem_limit.rb
Expand Up @@ -104,11 +104,18 @@ def limit_memory(limit_in_bytes)
# and memory.memsw.limit_in_bytes is set first, the invariant may not
# hold. However, one of the two fields will always be set
# successfully. To mitigate this, both limits are written twice.
2.times do
["memory.limit_in_bytes", "memory.memsw.limit_in_bytes"].each do |path|
File.open(File.join(cgroup_path(:memory), path), 'w') do |f|
f.write(limit_in_bytes.to_s)
end
memory_limit_path = "memory.limit_in_bytes"
memorysw_limit_path = "memory.memsw.limit_in_bytes"
current_memory_limit = File.read(File.open(File.join(cgroup_path(:memory), memory_limit_path), 'r')).to_i

increasing = current_memory_limit < limit_in_bytes

paths = [memory_limit_path, memorysw_limit_path]
paths.reverse! if increasing

paths.each do |path|
File.open(File.join(cgroup_path(:memory), path), 'w') do |f|
f.write(limit_in_bytes.to_s)
end
end
end
Expand Down

0 comments on commit ad18bff

Please sign in to comment.