Skip to content
Snippets Groups Projects
Commit 4e9b7dbc authored by tiagonbotelho's avatar tiagonbotelho
Browse files

sends message if the project is above the memory limit

parent 3043b31c
No related branches found
No related tags found
1 merge request!87WIP: sends message if the project is above the memory limit
Pipeline #
Loading
Loading
@@ -6,6 +6,7 @@ require 'json'
 
class GitlabAccess
class AccessDeniedError < StandardError; end
class MemoryLimitReachedError < StandardError; end
 
include NamesHelper
 
Loading
Loading
@@ -24,6 +25,7 @@ class GitlabAccess
status = api.check_access('git-receive-pack', @repo_name, @actor, @changes, @protocol)
 
raise AccessDeniedError, status.message unless status.allowed?
raise MemoryLimitReachedError, status.memory_message if status.memory_limit?
 
true
rescue GitlabNet::ApiUnreachableError
Loading
Loading
@@ -32,6 +34,9 @@ class GitlabAccess
rescue AccessDeniedError => ex
$stderr.puts "GitLab: #{ex.message}"
false
rescue MemoryLimitReachedError => ex
$stderr.puts "Gitlab: Project has reached the memory limit by: #{ex.message}MB please free some memory in Gitlab's UI to be able to push."
  • Let's take what Yorick suggested:

    This project exceeds the limit of XXX and as a result you are unable to push to this repository. Please contact your GitLab administrators for more information.

    @axil can you help us with this message? It's linked to https://gitlab.com/gitlab-org/gitlab-ee/issues/559

  • Please register or sign in to reply
false
end
 
protected
Loading
Loading
require 'json'
 
class GitAccessStatus
attr_reader :message, :repository_path
attr_reader :message, :repository_path, :memory_status, :memory_message
 
def initialize(status, message, repository_path)
def initialize(status, message, repository_path, memory = nil)
@status = status
@message = message
@repository_path = repository_path
if memory
@memory_status = memory["status"]
@memory_message = memory["message"]
end
end
 
def self.create_from_json(json)
values = JSON.parse(json)
self.new(values["status"], values["message"], values["repository_path"])
self.new(values["status"], values["message"],
values["repository_path"], values["memory"])
end
 
def allowed?
@status
end
def memory_limit?
@memory_status
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment