diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-14 18:13:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-14 18:13:32 +0300 |
commit | 1123408ec8922d4a6908ef4b85aa0ff4fbea08fe (patch) | |
tree | dfd95769ede53024da1b348176b589ba1fc4c801 /lib | |
parent | 2896c7471aa75a7842fe6318a122f83ca6c211bb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/reports/security/finding.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/reports/security/finding_key.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml | 8 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/git_access.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/repository_service.rb | 5 | ||||
-rw-r--r-- | lib/gitlab_edition.rb | 10 |
7 files changed, 18 insertions, 31 deletions
diff --git a/lib/gitlab/ci/reports/security/finding.rb b/lib/gitlab/ci/reports/security/finding.rb index 990250735ba..69fb8474cde 100644 --- a/lib/gitlab/ci/reports/security/finding.rb +++ b/lib/gitlab/ci/reports/security/finding.rb @@ -126,7 +126,7 @@ module Gitlab location_fingerprints.map do |location_fingerprint| FindingKey.new(location_fingerprint: location_fingerprint, identifier_fingerprint: identifier.fingerprint) end - end + end.push(uuid) end def primary_identifier_fingerprint diff --git a/lib/gitlab/ci/reports/security/finding_key.rb b/lib/gitlab/ci/reports/security/finding_key.rb index 0acd923a60f..ad047fbf904 100644 --- a/lib/gitlab/ci/reports/security/finding_key.rb +++ b/lib/gitlab/ci/reports/security/finding_key.rb @@ -11,6 +11,8 @@ module Gitlab end def ==(other) + return false unless other.is_a?(self.class) + has_fingerprints? && other.has_fingerprints? && location_fingerprint == other.location_fingerprint && identifier_fingerprint == other.identifier_fingerprint diff --git a/lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml b/lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml index f1b1c20b4e0..61ed48836ea 100644 --- a/lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml @@ -11,6 +11,7 @@ kaniko-build: # Additional options for Kaniko executor. # For more details see https://github.com/GoogleContainerTools/kaniko/blob/master/README.md#additional-flags KANIKO_ARGS: "" + KANIKO_BUILD_CONTEXT: $CI_PROJECT_DIR stage: build image: # For latest releases see https://github.com/GoogleContainerTools/kaniko/releases @@ -40,8 +41,13 @@ kaniko-build: # Write credentials to access Gitlab Container Registry within the runner/ci - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json # Build and push the container. To disable push add --no-push - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$VERSION $KANIKO_ARGS + - DOCKERFILE_PATH=${DOCKERFILE_PATH:-"$KANIKO_BUILD_CONTEXT/Dockerfile"} + - /kaniko/executor --context $KANIKO_BUILD_CONTEXT --dockerfile $DOCKERFILE_PATH --destination $CI_REGISTRY_IMAGE:$VERSION $KANIKO_ARGS # Run this job in a branch/tag where a Dockerfile exists rules: - exists: - Dockerfile + # custom Dockerfile path + - if: $DOCKERFILE_PATH + # custom build context without an explicit Dockerfile path + - if: $KANIKO_BUILD_CONTEXT != $CI_PROJECT_DIR diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 240a701aba9..c3ee5b97379 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -972,18 +972,6 @@ module Gitlab @praefect_info_client ||= Gitlab::GitalyClient::PraefectInfoService.new(self) end - def clean_stale_repository_files - wrapped_gitaly_errors do - gitaly_repository_client.cleanup if exists? - end - rescue Gitlab::Git::CommandError => e # Don't fail if we can't cleanup - Gitlab::AppLogger.error("Unable to clean repository on storage #{storage} with relative path #{relative_path}: #{e.message}") - Gitlab::Metrics.counter( - :failed_repository_cleanup_total, - 'Number of failed repository cleanup events' - ).increment - end - def branch_names_contains_sha(sha) gitaly_ref_client.branch_names_contains_sha(sha) end diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 759c6b93d9a..f98fb66ad21 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -328,11 +328,6 @@ module Gitlab raise ForbiddenError, error_message(:push_code) end else - # If there are worktrees with a HEAD pointing to a non-existent object, - # calls to `git rev-list --all` will fail in git 2.15+. This should also - # clear stale lock files. - project.repository.clean_stale_repository_files if project.present? - check_access! end end @@ -467,11 +462,6 @@ module Gitlab def check_push_size! return unless check_size_limit? - # If there are worktrees with a HEAD pointing to a non-existent object, - # calls to `git rev-list --all` will fail in git 2.15+. This should also - # clear stale lock files. - repository.clean_stale_repository_files - # Use #check_repository_disk_size to get correct push size whenever a lot of changes # gets pushed at the same time containing the same blobs. This is only # doable if GIT_OBJECT_DIRECTORY_RELATIVE env var is set and happens diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index 7e7d543d0a5..73848dfff5d 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -21,11 +21,6 @@ module Gitlab response.exists end - def cleanup - request = Gitaly::CleanupRequest.new(repository: @gitaly_repo) - GitalyClient.call(@storage, :repository_service, :cleanup, request, timeout: GitalyClient.fast_timeout) - end - def garbage_collect(create_bitmap, prune:) request = Gitaly::GarbageCollectRequest.new(repository: @gitaly_repo, create_bitmap: create_bitmap, prune: prune) GitalyClient.call(@storage, :repository_service, :garbage_collect, request, timeout: GitalyClient.long_timeout) diff --git a/lib/gitlab_edition.rb b/lib/gitlab_edition.rb index 6eb6b52c357..02006148a34 100644 --- a/lib/gitlab_edition.rb +++ b/lib/gitlab_edition.rb @@ -18,7 +18,11 @@ module GitlabEdition end def self.ee? - @is_ee ||= + # To reduce dependencies in QA image we are not using + # `Gitlab::Utils::StrongMemoize` but reimplementing its functionality. + return @is_ee if defined?(@is_ee) + + @is_ee = # We use this method when the Rails environment is not loaded. This # means that checking the presence of the License class could result in # this method returning `false`, even for an EE installation. @@ -34,7 +38,9 @@ module GitlabEdition end def self.jh? - @is_jh ||= + return @is_jh if defined?(@is_jh) + + @is_jh = ee? && root.join('jh').exist? && !%w[true 1].include?(ENV['EE_ONLY'].to_s) |