...
 
Commits (4)
......@@ -11,7 +11,7 @@ ruby_lint:
stage: testing
image: ruby:2.5
script:
- gem install rubocop --no-ri --no-rdoc
- gem install rubocop --no-document
- rubocop -P -f s
yaml_lint:
stage: testing
......@@ -24,5 +24,5 @@ ruby_bundler:
stage: testing
image: ruby:2.5
script:
- gem install bundler -no-ri --no-rdoc
- gem install bundler --no-document
- bundle install
......@@ -22,9 +22,9 @@ class Manager2Api < Sinatra::Base
# CPU limits
def limit_cpu_get(username)
data = git_get
return 'No process limit set, defaults apply' unless data[username]['properties'].key? 'cgroups'
return 'No CPU cap set' unless data[username]['properties'].key? 'cgroups'
return 'No process limit set, defaults apply' unless data[username]['properties']['cgroups'].key? 'cpu'
return 'No CPU cap set' unless data[username]['properties']['cgroups'].key? 'cpu'
data[username]['properties']['cgroups']['cpu']
end
......@@ -34,7 +34,7 @@ class Manager2Api < Sinatra::Base
data[username]['properties']['cgroups'] = {} unless data[username]['properties'].key? 'cgroups'
data[username]['properties']['cgroups']['cpu'] = limit
git_put data, "Set cpu shares; user: #{username}, limit: #{limit}"
git_put data, "Set CPU cap; user: #{username}, cap: #{limit}%"
end
# Memory usage limits
......
......@@ -25,18 +25,21 @@ class Manager2Api < Sinatra::Base
halt erb :error, locals: { code: 400, message: 'Illegal character in database name' }
end
# Make sure the non-prefix database name is used
dbname = params['dbname'].gsub(/^#{user}_/, '')
data = git_get
user = git_user_from_key(params['key'])
comment = params.key?('comment') ? params['comment'] : ''
# Check if db does not already exist
if data[user]['properties'].key? 'mysql_dbs'
if data[user]['properties']['mysql_dbs'].key? params['dbname']
if data[user]['properties']['mysql_dbs'].key? dbname
halt erb :error, locals: { code: 409, message: 'MySQL database with the requested dbname already exists' }
end
end
request_submit(user, 'dbname' => params['dbname'], 'comment' => comment)
request_submit(user, 'dbname' => dbname, 'comment' => comment)
erb :result, locals: { message: 'MySQL database request received' }
end
......