Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-12 12:11:48 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-12 12:11:48 +0300
commit94a5041917eb74f9636a4c2a73b055cf2928a585 (patch)
tree25d999c0620ba1a733b94dba848047a8501aac3f /app
parentea44b3870dbb591f737877a288067ce60248acf6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/packages_and_registries/package_registry/components/details/package_title.vue3
-rw-r--r--app/assets/javascripts/work_items/components/work_item_links/index.js10
-rw-r--r--app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue62
-rw-r--r--app/models/ci/build.rb13
-rw-r--r--app/models/concerns/counter_attribute.rb47
-rw-r--r--app/services/ci/job_artifacts/create_service.rb2
-rw-r--r--app/services/ci/job_artifacts/destroy_batch_service.rb2
7 files changed, 106 insertions, 33 deletions
diff --git a/app/assets/javascripts/packages_and_registries/package_registry/components/details/package_title.vue b/app/assets/javascripts/packages_and_registries/package_registry/components/details/package_title.vue
index 36e1b883400..11fd0db3106 100644
--- a/app/assets/javascripts/packages_and_registries/package_registry/components/details/package_title.vue
+++ b/app/assets/javascripts/packages_and_registries/package_registry/components/details/package_title.vue
@@ -23,6 +23,7 @@ export default {
directives: {
GlResizeObserver: GlResizeObserverDirective,
},
+ inject: ['isGroupPage'],
i18n: {
packageInfo: __('v%{version} published %{timeAgo}'),
},
@@ -122,7 +123,7 @@ export default {
<metadata-item data-testid="package-size" icon="disk" :text="totalSize" />
</template>
- <template v-if="packagePipeline" #metadata-pipeline>
+ <template v-if="isGroupPage && packagePipeline" #metadata-pipeline>
<metadata-item
data-testid="pipeline-project"
icon="review-list"
diff --git a/app/assets/javascripts/work_items/components/work_item_links/index.js b/app/assets/javascripts/work_items/components/work_item_links/index.js
index 6c8af8dc74c..86f03583ea3 100644
--- a/app/assets/javascripts/work_items/components/work_item_links/index.js
+++ b/app/assets/javascripts/work_items/components/work_item_links/index.js
@@ -1,16 +1,10 @@
import Vue from 'vue';
-import VueApollo from 'vue-apollo';
import { GlToast } from '@gitlab/ui';
-import createDefaultClient from '~/lib/graphql';
+import { createApolloProvider } from '../../graphql/provider';
import WorkItemLinks from './work_item_links.vue';
-Vue.use(VueApollo);
Vue.use(GlToast);
-const apolloProvider = new VueApollo({
- defaultClient: createDefaultClient(),
-});
-
export default function initWorkItemLinks() {
if (!window.gon.features.workItemsHierarchy) {
return;
@@ -28,7 +22,7 @@ export default function initWorkItemLinks() {
new Vue({
el: workItemLinksRoot,
name: 'WorkItemLinksRoot',
- apolloProvider,
+ apolloProvider: createApolloProvider(),
components: {
workItemLinks: WorkItemLinks,
},
diff --git a/app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue b/app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue
index 23264a12465..7483bef6e23 100644
--- a/app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue
+++ b/app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue
@@ -3,6 +3,7 @@ import { GlButton, GlBadge, GlIcon, GlLoadingIcon } from '@gitlab/ui';
import { produce } from 'immer';
import { s__ } from '~/locale';
import { convertToGraphQLId, getIdFromGraphQLId } from '~/graphql_shared/utils';
+import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import { TYPE_WORK_ITEM } from '~/graphql_shared/constants';
import { isMetaKey } from '~/lib/utils/common_utils';
import { setUrlParams, updateHistory } from '~/lib/utils/url_utility';
@@ -13,7 +14,8 @@ import {
WIDGET_TYPE_HIERARCHY,
} from '../../constants';
import getWorkItemLinksQuery from '../../graphql/work_item_links.query.graphql';
-import updateWorkItem from '../../graphql/update_work_item.mutation.graphql';
+import updateWorkItemMutation from '../../graphql/update_work_item.mutation.graphql';
+import workItemQuery from '../../graphql/work_item.query.graphql';
import WorkItemDetailModal from '../work_item_detail_modal.vue';
import WorkItemLinksForm from './work_item_links_form.vue';
import WorkItemLinksMenu from './work_item_links_menu.vue';
@@ -42,40 +44,40 @@ export default {
},
},
apollo: {
- children: {
+ workItem: {
query: getWorkItemLinksQuery,
variables() {
return {
id: this.issuableGid,
};
},
- update(data) {
- return (
- data.workItem.widgets.find((widget) => widget.type === WIDGET_TYPE_HIERARCHY)?.children
- .nodes ?? []
- );
- },
skip() {
return !this.issuableId;
},
- result({ data }) {
- this.canUpdate = data.workItem.userPermissions.updateWorkItem;
- this.confidential = data.workItem.confidential;
- },
},
},
data() {
return {
isShownAddForm: false,
isOpen: true,
- children: [],
- canUpdate: false,
- confidential: false,
activeChildId: null,
activeToast: null,
+ prefetchedWorkItem: null,
};
},
computed: {
+ children() {
+ return (
+ this.workItem?.widgets.find((widget) => widget.type === WIDGET_TYPE_HIERARCHY)?.children
+ .nodes ?? []
+ );
+ },
+ canUpdate() {
+ return this.workItem?.userPermissions.updateWorkItem || false;
+ },
+ confidential() {
+ return this.workItem?.confidential || false;
+ },
// Only used for children for now but should be extended later to support parents and siblings
isChildrenEmpty() {
return this.children?.length === 0;
@@ -92,7 +94,7 @@ export default {
return this.issuableId ? convertToGraphQLId(TYPE_WORK_ITEM, this.issuableId) : null;
},
isLoading() {
- return this.$apollo.queries.children.loading;
+ return this.$apollo.queries.workItem.loading;
},
childrenIds() {
return this.children.map((c) => c.id);
@@ -171,22 +173,22 @@ export default {
data: newData,
});
},
- async updateWorkItemMutation(workItem, childId, parentId) {
+ async updateWorkItem(workItem, childId, parentId) {
return this.$apollo.mutate({
- mutation: updateWorkItem,
+ mutation: updateWorkItemMutation,
variables: { input: { id: childId, hierarchyWidget: { parentId } } },
- update: this.toggleChildFromCache.bind(this, workItem, childId),
+ update: (store) => this.toggleChildFromCache(workItem, childId, store),
});
},
async undoChildRemoval(workItem, childId) {
- const { data } = await this.updateWorkItemMutation(workItem, childId, this.issuableGid);
+ const { data } = await this.updateWorkItem(workItem, childId, this.issuableGid);
if (data.workItemUpdate.errors.length === 0) {
this.activeToast?.hide();
}
},
async removeChild(childId) {
- const { data } = await this.updateWorkItemMutation(null, childId, null);
+ const { data } = await this.updateWorkItem(null, childId, null);
if (data.workItemUpdate.errors.length === 0) {
this.activeToast = this.$toast.show(s__('WorkItem|Child removed'), {
@@ -197,6 +199,22 @@ export default {
});
}
},
+ prefetchWorkItem(id) {
+ this.prefetch = setTimeout(
+ () =>
+ this.$apollo.addSmartQuery('prefetchedWorkItem', {
+ query: workItemQuery,
+ variables: {
+ id,
+ },
+ update: (data) => data.workItem,
+ }),
+ DEFAULT_DEBOUNCE_AND_THROTTLE_MS,
+ );
+ },
+ clearPrefetching() {
+ clearTimeout(this.prefetch);
+ },
},
i18n: {
title: s__('WorkItem|Child items'),
@@ -274,6 +292,8 @@ export default {
variant="link"
class="gl-text-truncate gl-max-w-80 gl-text-black-normal!"
@click="openChild(child.id, $event)"
+ @mouseover="prefetchWorkItem(child.id)"
+ @mouseout="clearPrefetching"
>
{{ child.title }}
</gl-button>
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 2b72a4c4c89..b267ea8f93f 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -821,7 +821,11 @@ module Ci
)
end
- job_artifacts.erasable.destroy_all # rubocop: disable Cop/DestroyAll
+ destroyed_artifacts = job_artifacts.erasable.destroy_all # rubocop: disable Cop/DestroyAll
+
+ Gitlab::Ci::Artifacts::Logger.log_deleted(destroyed_artifacts, 'Ci::Build#erase_erasable_artifacts!')
+
+ destroyed_artifacts
end
def erase(opts = {})
@@ -834,7 +838,12 @@ module Ci
)
end
- job_artifacts.destroy_all # rubocop: disable Cop/DestroyAll
+ # TODO: We should use DestroyBatchService here
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/369132
+ destroyed_artifacts = job_artifacts.destroy_all # rubocop: disable Cop/DestroyAll
+
+ Gitlab::Ci::Artifacts::Logger.log_deleted(destroyed_artifacts, 'Ci::Build#erase')
+
erase_trace!
update_erased!(opts[:erased_by])
end
diff --git a/app/models/concerns/counter_attribute.rb b/app/models/concerns/counter_attribute.rb
index b41b1ba6008..65cf3246d11 100644
--- a/app/models/concerns/counter_attribute.rb
+++ b/app/models/concerns/counter_attribute.rb
@@ -82,18 +82,23 @@ module CounterAttribute
lock_key = counter_lock_key(attribute)
with_exclusive_lease(lock_key) do
+ previous_db_value = read_attribute(attribute)
increment_key = counter_key(attribute)
flushed_key = counter_flushed_key(attribute)
increment_value = steal_increments(increment_key, flushed_key)
+ new_db_value = nil
next if increment_value == 0
transaction do
unsafe_update_counters(id, attribute => increment_value)
redis_state { |redis| redis.del(flushed_key) }
+ new_db_value = reset.read_attribute(attribute)
end
execute_after_flush_callbacks
+
+ log_flush_counter(attribute, increment_value, previous_db_value, new_db_value)
end
end
@@ -115,15 +120,19 @@ module CounterAttribute
def increment_counter(attribute, increment)
if counter_attribute_enabled?(attribute)
- redis_state do |redis|
+ new_value = redis_state do |redis|
redis.incrby(counter_key(attribute), increment)
end
+
+ log_increment_counter(attribute, increment, new_value)
end
end
def clear_counter!(attribute)
if counter_attribute_enabled?(attribute)
redis_state { |redis| redis.del(counter_key(attribute)) }
+
+ log_clear_counter(attribute)
end
end
@@ -184,4 +193,40 @@ module CounterAttribute
rescue Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError
# a worker is already updating the counters
end
+
+ def log_increment_counter(attribute, increment, new_value)
+ payload = Gitlab::ApplicationContext.current.merge(
+ message: 'Increment counter attribute',
+ attribute: attribute,
+ project_id: project_id,
+ increment: increment,
+ new_counter_value: new_value,
+ current_db_value: read_attribute(attribute)
+ )
+
+ Gitlab::AppLogger.info(payload)
+ end
+
+ def log_flush_counter(attribute, increment, previous_db_value, new_db_value)
+ payload = Gitlab::ApplicationContext.current.merge(
+ message: 'Flush counter attribute to database',
+ attribute: attribute,
+ project_id: project_id,
+ increment: increment,
+ previous_db_value: previous_db_value,
+ new_db_value: new_db_value
+ )
+
+ Gitlab::AppLogger.info(payload)
+ end
+
+ def log_clear_counter(attribute)
+ payload = Gitlab::ApplicationContext.current.merge(
+ message: 'Clear counter attribute',
+ attribute: attribute,
+ project_id: project_id
+ )
+
+ Gitlab::AppLogger.info(payload)
+ end
end
diff --git a/app/services/ci/job_artifacts/create_service.rb b/app/services/ci/job_artifacts/create_service.rb
index 05f8e804c67..af56eb221d5 100644
--- a/app/services/ci/job_artifacts/create_service.rb
+++ b/app/services/ci/job_artifacts/create_service.rb
@@ -126,6 +126,8 @@ module Ci
job.update_column(:artifacts_expire_at, artifact.expire_at)
end
+ Gitlab::Ci::Artifacts::Logger.log_created(artifact)
+
success(artifact: artifact)
rescue ActiveRecord::RecordNotUnique => error
track_exception(error, params)
diff --git a/app/services/ci/job_artifacts/destroy_batch_service.rb b/app/services/ci/job_artifacts/destroy_batch_service.rb
index c85082174cc..54ec2c671c6 100644
--- a/app/services/ci/job_artifacts/destroy_batch_service.rb
+++ b/app/services/ci/job_artifacts/destroy_batch_service.rb
@@ -53,6 +53,8 @@ module Ci
update_project_statistics! if update_stats
increment_monitoring_statistics(artifacts_count, artifacts_bytes)
+ Gitlab::Ci::Artifacts::Logger.log_deleted(@job_artifacts, 'Ci::JobArtifacts::DestroyBatchService#execute')
+
success(destroyed_artifacts_count: artifacts_count,
statistics_updates: affected_project_statistics)
end