As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

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
No related merge requests found
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."
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