summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-01-06 13:51:06 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-01-06 13:51:06 +0000
commita7a7f8b15968418bf52d91341588f1c573f412c3 (patch)
tree787f81c62ca03677798cd1fa9adf037b326f5c91 /app
parent6d972724d426938a0bfd6744dc6464ec5f7e17f9 (diff)
parentff5124ed6ecb2f20841e535b3aaa3b0d230f920f (diff)
downloadgitlab-ce-a7a7f8b15968418bf52d91341588f1c573f412c3.tar.gz
Merge branch '41249-clearing-the-cache' into 'master'
Resolve "Clearing the cache" Closes #41249 See merge request gitlab-org/gitlab-ce!16067
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/pipelines/components/nav_controls.vue13
-rw-r--r--app/assets/javascripts/pipelines/components/pipelines.vue2
-rw-r--r--app/controllers/projects/settings/ci_cd_controller.rb10
-rw-r--r--app/models/ci/build.rb9
-rw-r--r--app/services/reset_project_cache_service.rb5
-rw-r--r--app/views/projects/pipelines/index.html.haml3
6 files changed, 40 insertions, 2 deletions
diff --git a/app/assets/javascripts/pipelines/components/nav_controls.vue b/app/assets/javascripts/pipelines/components/nav_controls.vue
index 632fc167f2b..f31a91c3403 100644
--- a/app/assets/javascripts/pipelines/components/nav_controls.vue
+++ b/app/assets/javascripts/pipelines/components/nav_controls.vue
@@ -17,6 +17,11 @@ export default {
required: true,
},
+ resetCachePath: {
+ type: String,
+ required: true,
+ },
+
ciLintPath: {
type: String,
required: true,
@@ -46,6 +51,14 @@ export default {
</a>
<a
+ data-method="post"
+ rel="nofollow"
+ :href="resetCachePath"
+ class="btn btn-default">
+ Clear runner caches
+ </a>
+
+ <a
:href="ciLintPath"
class="btn btn-default">
CI Lint
diff --git a/app/assets/javascripts/pipelines/components/pipelines.vue b/app/assets/javascripts/pipelines/components/pipelines.vue
index fe1f3b4246a..8fa416168e7 100644
--- a/app/assets/javascripts/pipelines/components/pipelines.vue
+++ b/app/assets/javascripts/pipelines/components/pipelines.vue
@@ -50,6 +50,7 @@
canCreatePipeline: pipelinesData.canCreatePipeline,
hasCi: pipelinesData.hasCi,
ciLintPath: pipelinesData.ciLintPath,
+ resetCachePath: pipelinesData.resetCachePath,
state: this.store.state,
scope: getParameterByName('scope') || 'all',
page: getParameterByName('page') || '1',
@@ -220,6 +221,7 @@
:new-pipeline-path="newPipelinePath"
:has-ci-enabled="hasCiEnabled"
:help-page-path="helpPagePath"
+ :resetCachePath="resetCachePath"
:ci-lint-path="ciLintPath"
:can-create-pipeline="canCreatePipelineParsed "
/>
diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb
index b029b31f9af..86717bb7242 100644
--- a/app/controllers/projects/settings/ci_cd_controller.rb
+++ b/app/controllers/projects/settings/ci_cd_controller.rb
@@ -11,6 +11,16 @@ module Projects
define_auto_devops_variables
end
+ def reset_cache
+ if ResetProjectCacheService.new(@project, current_user).execute
+ flash[:notice] = _("Project cache successfully reset.")
+ else
+ flash[:error] = _("Unable to reset project cache.")
+ end
+
+ redirect_to project_pipelines_path(@project)
+ end
+
private
def define_runners_variables
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 83fe23606d1..d0ee08ab086 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -461,7 +461,14 @@ module Ci
end
def cache
- [options[:cache]]
+ cache = options[:cache]
+
+ if cache && project.jobs_cache_index
+ cache = cache.merge(
+ key: "#{cache[:key]}:#{project.jobs_cache_index}")
+ end
+
+ [cache]
end
def credentials
diff --git a/app/services/reset_project_cache_service.rb b/app/services/reset_project_cache_service.rb
new file mode 100644
index 00000000000..a162a6eedb9
--- /dev/null
+++ b/app/services/reset_project_cache_service.rb
@@ -0,0 +1,5 @@
+class ResetProjectCacheService < BaseService
+ def execute
+ @project.increment!(:jobs_cache_index)
+ end
+end
diff --git a/app/views/projects/pipelines/index.html.haml b/app/views/projects/pipelines/index.html.haml
index b2e71cff6ce..f8555f11aab 100644
--- a/app/views/projects/pipelines/index.html.haml
+++ b/app/views/projects/pipelines/index.html.haml
@@ -10,7 +10,8 @@
"new-pipeline-path" => new_project_pipeline_path(@project),
"can-create-pipeline" => can?(current_user, :create_pipeline, @project).to_s,
"has-ci" => @repository.gitlab_ci_yml,
- "ci-lint-path" => ci_lint_path } }
+ "ci-lint-path" => ci_lint_path,
+ "reset-cache-path" => reset_cache_project_settings_ci_cd_path(@project) } }
= page_specific_javascript_bundle_tag('common_vue')
= page_specific_javascript_bundle_tag('pipelines')