Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-04-04 18:08:38 +00:00
parent cad0cc3395
commit 6d05fbc478
86 changed files with 603 additions and 386 deletions

View File

@ -135,6 +135,7 @@ Naming/FileName:
- 'qa/qa/specs/**/*'
- 'qa/tasks/**/*.rake'
- '**/*.ru'
- 'app/graphql/types/issue_connection.rb'
IgnoreExecutableScripts: true
AllowedAcronyms:

View File

@ -256,7 +256,6 @@ Layout/FirstHashElementIndentation:
- 'lib/banzai/filter/commit_trailers_filter.rb'
- 'lib/banzai/filter/playable_link_filter.rb'
- 'lib/banzai/reference_parser/user_parser.rb'
- 'lib/error_tracking/sentry_client/issue.rb'
- 'lib/gitlab/analytics/cycle_analytics/aggregated/records_fetcher.rb'
- 'lib/gitlab/analytics/cycle_analytics/records_fetcher.rb'
- 'lib/gitlab/asciidoc.rb'

View File

@ -437,7 +437,6 @@ RSpec/VerifiedDoubles:
- spec/lib/error_tracking/collector/dsn_spec.rb
- spec/lib/error_tracking/collector/sentry_auth_parser_spec.rb
- spec/lib/error_tracking/collector/sentry_request_parser_spec.rb
- spec/lib/error_tracking/sentry_client/issue_spec.rb
- spec/lib/extracts_path_spec.rb
- spec/lib/feature_spec.rb
- spec/lib/gitaly/server_spec.rb

View File

@ -1,6 +1,6 @@
import Mousetrap from 'mousetrap';
import { visitUrl, constructWebIDEPath } from '~/lib/utils/url_utility';
import findAndFollowLink from '../../lib/utils/navigation_utility';
import findAndFollowLink from '~/lib/utils/navigation_utility';
import {
keysFor,
GO_TO_PROJECT_OVERVIEW,

View File

@ -1,5 +1,5 @@
import Mousetrap from 'mousetrap';
import findAndFollowLink from '../../lib/utils/navigation_utility';
import findAndFollowLink from '~/lib/utils/navigation_utility';
import { keysFor, EDIT_WIKI_PAGE } from './keybindings';
import ShortcutsNavigation from './shortcuts_navigation';

View File

@ -11,9 +11,9 @@ import {
} from '~/performance/constants';
import { performanceMarkAndMeasure } from '~/performance/utils';
import { fixTitle } from '~/tooltips';
import axios from '../../lib/utils/axios_utils';
import { handleLocationHash } from '../../lib/utils/common_utils';
import eventHub from '../../notes/event_hub';
import axios from '~/lib/utils/axios_utils';
import { handleLocationHash } from '~/lib/utils/common_utils';
import eventHub from '~/notes/event_hub';
const loadRichBlobViewer = (type) => {
switch (type) {

View File

@ -18,7 +18,7 @@ import Tracking from '~/tracking';
import { formatDate } from '~/lib/utils/datetime_utility';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import listQuery from 'ee_else_ce/boards/graphql/board_lists_deferred.query.graphql';
import AccessorUtilities from '../../lib/utils/accessor';
import AccessorUtilities from '~/lib/utils/accessor';
import { inactiveId, LIST, ListType, toggleFormEventPrefix } from '../constants';
import eventHub from '../eventhub';
import ItemCount from './item_count.vue';

View File

@ -1,4 +1,4 @@
import { parseBoolean } from '../../../lib/utils/common_utils';
import { parseBoolean } from '~/lib/utils/common_utils';
export default (initialState = {}) => {
return {

View File

@ -1,4 +1,4 @@
import axios from '../../lib/utils/axios_utils';
import axios from '~/lib/utils/axios_utils';
export default class ClusterService {
constructor(options = {}) {

View File

@ -1,4 +1,4 @@
import { parseBoolean } from '../../lib/utils/common_utils';
import { parseBoolean } from '~/lib/utils/common_utils';
export default class ClusterStore {
constructor() {

View File

@ -2,7 +2,7 @@
import { GlTooltipDirective, GlIcon, GlLink, GlButtonGroup, GlButton, GlSprintf } from '@gitlab/ui';
import { mapActions, mapGetters, mapState } from 'vuex';
import { __ } from '~/locale';
import { setUrlParams } from '../../lib/utils/url_utility';
import { setUrlParams } from '~/lib/utils/url_utility';
import { EVT_EXPAND_ALL_FILES } from '../constants';
import eventHub from '../event_hub';
import CompareDropdownLayout from './compare_dropdown_layout.vue';

View File

@ -1,4 +1,4 @@
import AccessorUtilities from '../../lib/utils/accessor';
import AccessorUtilities from '~/lib/utils/accessor';
const GL_EMOJI_VERSION = '0.2.0';

View File

@ -4,7 +4,7 @@
* Components need to have `scope`, `page` and `requestData`
*/
import { validateParams } from '~/pipelines/utils';
import { historyPushState, buildUrlWithCurrentLocation } from '../../lib/utils/common_utils';
import { historyPushState, buildUrlWithCurrentLocation } from '~/lib/utils/common_utils';
export default {
methods: {

View File

@ -1,4 +1,4 @@
import AccessorUtilities from '../../lib/utils/accessor';
import AccessorUtilities from '~/lib/utils/accessor';
import RecentSearchesServiceError from './recent_searches_service_error';
class RecentSearchesService {

View File

@ -1,6 +1,6 @@
<script>
import PaginationLinks from '~/vue_shared/components/pagination_links.vue';
import { getParameterByName } from '../../lib/utils/url_utility';
import { getParameterByName } from '~/lib/utils/url_utility';
import eventHub from '../event_hub';
export default {

View File

@ -1,4 +1,4 @@
import { parseBoolean } from '../../lib/utils/common_utils';
import { parseBoolean } from '~/lib/utils/common_utils';
/**
* Adds the line number property

View File

@ -1,7 +1,7 @@
<script>
import { GlDropdown, GlDropdownItem, GlDropdownDivider } from '@gitlab/ui';
import { mapGetters, mapActions } from 'vuex';
import { getLocationHash, doesHashExistInUrl } from '../../lib/utils/url_utility';
import { getLocationHash, doesHashExistInUrl } from '~/lib/utils/url_utility';
import {
DISCUSSION_FILTERS_DEFAULT_VALUE,
HISTORY_ONLY_FILTER_VALUE,

View File

@ -9,7 +9,7 @@ import { __, sprintf } from '~/locale';
import eventHub from '~/sidebar/event_hub';
import UserAccessRoleBadge from '~/vue_shared/components/user_access_role_badge.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { splitCamelCase } from '../../lib/utils/text_utility';
import { splitCamelCase } from '~/lib/utils/text_utility';
import ReplyButton from './note_actions/reply_button.vue';
export default {

View File

@ -6,12 +6,12 @@ import { __ } from '~/locale';
import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue';
import OrderedLayout from '~/vue_shared/components/ordered_layout.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import draftNote from '../../batch_comments/components/draft_note.vue';
import { getLocationHash, doesHashExistInUrl } from '../../lib/utils/url_utility';
import placeholderNote from '../../vue_shared/components/notes/placeholder_note.vue';
import placeholderSystemNote from '../../vue_shared/components/notes/placeholder_system_note.vue';
import skeletonLoadingContainer from '../../vue_shared/components/notes/skeleton_note.vue';
import systemNote from '../../vue_shared/components/notes/system_note.vue';
import draftNote from '~/batch_comments/components/draft_note.vue';
import { getLocationHash, doesHashExistInUrl } from '~/lib/utils/url_utility';
import placeholderNote from '~/vue_shared/components/notes/placeholder_note.vue';
import placeholderSystemNote from '~/vue_shared/components/notes/placeholder_system_note.vue';
import skeletonLoadingContainer from '~/vue_shared/components/notes/skeleton_note.vue';
import systemNote from '~/vue_shared/components/notes/system_note.vue';
import * as constants from '../constants';
import eventHub from '../event_hub';
import commentForm from './comment_form.vue';

View File

@ -1,7 +1,7 @@
import $ from 'jquery';
import { s__ } from '~/locale';
import Autosave from '../../autosave';
import { capitalizeFirstCharacter } from '../../lib/utils/text_utility';
import Autosave from '~/autosave';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
export default {
methods: {

View File

@ -1,6 +1,6 @@
import { mapGetters, mapActions, mapState } from 'vuex';
import { scrollToElementWithContext, scrollToElement } from '~/lib/utils/common_utils';
import { updateHistory } from '../../lib/utils/url_utility';
import { updateHistory } from '~/lib/utils/url_utility';
import eventHub from '../event_hub';
/**

View File

@ -9,14 +9,14 @@ import { __, sprintf } from '~/locale';
import { confidentialWidget } from '~/sidebar/components/confidential/sidebar_confidentiality_widget.vue';
import updateIssueLockMutation from '~/sidebar/components/lock/mutations/update_issue_lock.mutation.graphql';
import updateMergeRequestLockMutation from '~/sidebar/components/lock/mutations/update_merge_request_lock.mutation.graphql';
import loadAwardsHandler from '../../awards_handler';
import { isInViewport, scrollToElement, isInMRPage } from '../../lib/utils/common_utils';
import Poll from '../../lib/utils/poll';
import { create } from '../../lib/utils/recurrence';
import { mergeUrlParams } from '../../lib/utils/url_utility';
import sidebarTimeTrackingEventHub from '../../sidebar/event_hub';
import TaskList from '../../task_list';
import mrWidgetEventHub from '../../vue_merge_request_widget/event_hub';
import loadAwardsHandler from '~/awards_handler';
import { isInViewport, scrollToElement, isInMRPage } from '~/lib/utils/common_utils';
import Poll from '~/lib/utils/poll';
import { create } from '~/lib/utils/recurrence';
import { mergeUrlParams } from '~/lib/utils/url_utility';
import sidebarTimeTrackingEventHub from '~/sidebar/event_hub';
import TaskList from '~/task_list';
import mrWidgetEventHub from '~/vue_merge_request_widget/event_hub';
import * as constants from '../constants';
import eventHub from '../event_hub';
import * as types from './mutation_types';

View File

@ -1,5 +1,5 @@
import { isEqual } from 'lodash';
import { isInMRPage } from '../../lib/utils/common_utils';
import { isInMRPage } from '~/lib/utils/common_utils';
import * as constants from '../constants';
import * as types from './mutation_types';
import * as utils from './utils';

View File

@ -1,6 +1,6 @@
import $ from 'jquery';
import { parseBoolean } from '~/lib/utils/common_utils';
import { truncate } from '../../../lib/utils/text_utility';
import { truncate } from '~/lib/utils/text_utility';
const MAX_MESSAGE_LENGTH = 500;
const MESSAGE_CELL_SELECTOR = '.abuse-reports .message';

View File

@ -1,5 +1,5 @@
import $ from 'jquery';
import { refreshCurrentPage } from '../../lib/utils/url_utility';
import { refreshCurrentPage } from '~/lib/utils/url_utility';
export default function adminInit() {
$('input#user_force_random_password').on('change', function randomPasswordClick() {

View File

@ -1,5 +1,5 @@
import { parseBoolean } from '~/lib/utils/common_utils';
import axios from '../../lib/utils/axios_utils';
import axios from '~/lib/utils/axios_utils';
export default class PerformanceBarService {
static interceptor = null;

View File

@ -1,5 +1,5 @@
import Api from '~/api';
import axios from '../../lib/utils/axios_utils';
import axios from '~/lib/utils/axios_utils';
import { validateParams } from '../utils';
export default class PipelinesService {

View File

@ -1,4 +1,4 @@
import { parseIntPagination, normalizeHeaders } from '../../lib/utils/common_utils';
import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
export default class PipelinesStore {
constructor() {

View File

@ -1,7 +1,7 @@
import Visibility from 'visibilityjs';
import axios from '../../../lib/utils/axios_utils';
import httpStatusCodes from '../../../lib/utils/http_status';
import Poll from '../../../lib/utils/poll';
import axios from '~/lib/utils/axios_utils';
import httpStatusCodes from '~/lib/utils/http_status';
import Poll from '~/lib/utils/poll';
import * as types from './mutation_types';
export const setPaths = ({ commit }, paths) => commit(types.SET_PATHS, paths);

View File

@ -16,6 +16,7 @@ import RunnerPagination from '../components/runner_pagination.vue';
import RunnerTypeTabs from '../components/runner_type_tabs.vue';
import RunnerActionsCell from '../components/cells/runner_actions_cell.vue';
import { pausedTokenConfig } from '../components/search_tokens/paused_token_config';
import { statusTokenConfig } from '../components/search_tokens/status_token_config';
import { tagTokenConfig } from '../components/search_tokens/tag_token_config';
import {
@ -178,6 +179,7 @@ export default {
},
searchTokens() {
return [
pausedTokenConfig,
statusTokenConfig,
{
...tagTokenConfig,

View File

@ -0,0 +1,28 @@
import { __, s__ } from '~/locale';
import { OPERATOR_IS_ONLY } from '~/vue_shared/components/filtered_search_bar/constants';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
import { PARAM_KEY_PAUSED } from '../../constants';
const options = [
{ value: 'true', title: __('Yes') },
{ value: 'false', title: __('No') },
];
export const pausedTokenConfig = {
icon: 'pause',
title: s__('Runners|Paused'),
type: PARAM_KEY_PAUSED,
token: BaseToken,
unique: true,
options: options.map(({ value, title }) => ({
value,
// Replace whitespace with a special character to avoid
// splitting this value.
// Replacing in each option, as translations may also
// contain spaces!
// see: https://gitlab.com/gitlab-org/gitlab/-/issues/344142
// see: https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1438
title: title.replace(' ', '\u00a0'),
})),
operators: OPERATOR_IS_ONLY,
};

View File

@ -2,8 +2,6 @@ import { __, s__ } from '~/locale';
import { OPERATOR_IS_ONLY } from '~/vue_shared/components/filtered_search_bar/constants';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
import {
STATUS_ACTIVE,
STATUS_PAUSED,
STATUS_ONLINE,
STATUS_OFFLINE,
STATUS_NEVER_CONTACTED,
@ -12,8 +10,6 @@ import {
} from '../../constants';
const options = [
{ value: STATUS_ACTIVE, title: s__('Runners|Active') },
{ value: STATUS_PAUSED, title: s__('Runners|Paused') },
{ value: STATUS_ONLINE, title: s__('Runners|Online') },
{ value: STATUS_OFFLINE, title: s__('Runners|Offline') },
{ value: STATUS_NEVER_CONTACTED, title: s__('Runners|Never contacted') },

View File

@ -95,6 +95,7 @@ export const RUNNER_TAG_BG_CLASS = 'gl-bg-blue-100';
// - GlFilteredSearch tokens type
export const PARAM_KEY_STATUS = 'status';
export const PARAM_KEY_PAUSED = 'paused';
export const PARAM_KEY_RUNNER_TYPE = 'runner_type';
export const PARAM_KEY_TAG = 'tag';
export const PARAM_KEY_SEARCH = 'search';
@ -112,9 +113,6 @@ export const PROJECT_TYPE = 'PROJECT_TYPE';
// CiRunnerStatus
export const STATUS_ACTIVE = 'ACTIVE';
export const STATUS_PAUSED = 'PAUSED';
export const STATUS_ONLINE = 'ONLINE';
export const STATUS_NEVER_CONTACTED = 'NEVER_CONTACTED';
export const STATUS_OFFLINE = 'OFFLINE';

View File

@ -6,6 +6,7 @@ query getRunners(
$after: String
$first: Int
$last: Int
$paused: Boolean
$status: CiRunnerStatus
$type: CiRunnerType
$tagList: [String!]
@ -17,6 +18,7 @@ query getRunners(
after: $after
first: $first
last: $last
paused: $paused
status: $status
type: $type
tagList: $tagList

View File

@ -1,10 +1,11 @@
query getRunnersCount(
$paused: Boolean
$status: CiRunnerStatus
$type: CiRunnerType
$tagList: [String!]
$search: String
) {
runners(status: $status, type: $type, tagList: $tagList, search: $search) {
runners(paused: $paused, status: $status, type: $type, tagList: $tagList, search: $search) {
count
}
}

View File

@ -7,6 +7,7 @@ query getGroupRunners(
$after: String
$first: Int
$last: Int
$paused: Boolean
$status: CiRunnerStatus
$type: CiRunnerType
$search: String
@ -20,6 +21,7 @@ query getGroupRunners(
after: $after
first: $first
last: $last
paused: $paused
status: $status
type: $type
search: $search

View File

@ -1,5 +1,6 @@
query getGroupRunnersCount(
$groupFullPath: ID!
$paused: Boolean
$status: CiRunnerStatus
$type: CiRunnerType
$tagList: [String!]
@ -9,6 +10,7 @@ query getGroupRunnersCount(
id # Apollo required
runners(
membership: DESCENDANTS
paused: $paused
status: $status
type: $type
tagList: $tagList

View File

@ -14,6 +14,7 @@ import RunnerPagination from '../components/runner_pagination.vue';
import RunnerTypeTabs from '../components/runner_type_tabs.vue';
import RunnerActionsCell from '../components/cells/runner_actions_cell.vue';
import { pausedTokenConfig } from '../components/search_tokens/paused_token_config';
import { statusTokenConfig } from '../components/search_tokens/status_token_config';
import {
GROUP_FILTERED_SEARCH_NAMESPACE,
@ -189,7 +190,7 @@ export default {
return !this.runnersLoading && !this.runners.items.length;
},
searchTokens() {
return [statusTokenConfig];
return [pausedTokenConfig, statusTokenConfig];
},
filteredSearchNamespace() {
return `${GROUP_FILTERED_SEARCH_NAMESPACE}/${this.groupFullPath}`;

View File

@ -5,7 +5,9 @@ import {
urlQueryToFilter,
prepareTokens,
} from '~/vue_shared/components/filtered_search_bar/filtered_search_utils';
import { parseBoolean } from '~/lib/utils/common_utils';
import {
PARAM_KEY_PAUSED,
PARAM_KEY_STATUS,
PARAM_KEY_RUNNER_TYPE,
PARAM_KEY_TAG,
@ -83,6 +85,19 @@ const getPaginationFromParams = (params) => {
// Outdated URL parameters
const STATUS_NOT_CONNECTED = 'NOT_CONNECTED';
const STATUS_ACTIVE = 'ACTIVE';
const STATUS_PAUSED = 'PAUSED';
/**
* Replaces params into a URL
*
* @param {String} url - Original URL
* @param {Object} params - Query parameters to update
* @returns Updated URL
*/
const updateUrlParams = (url, params = {}) => {
return setUrlParams(params, url, false, true, true);
};
/**
* Returns an updated URL for old (or deprecated) admin runner URLs.
@ -98,14 +113,26 @@ export const updateOutdatedUrl = (url = window.location.href) => {
const params = queryToObject(query, { gatherArrays: true });
const runnerType = params[PARAM_KEY_STATUS]?.[0] || null;
if (runnerType === STATUS_NOT_CONNECTED) {
const updatedParams = {
[PARAM_KEY_STATUS]: [STATUS_NEVER_CONTACTED],
};
return setUrlParams(updatedParams, url, false, true, true);
const status = params[PARAM_KEY_STATUS]?.[0] || null;
switch (status) {
case STATUS_NOT_CONNECTED:
return updateUrlParams(url, {
[PARAM_KEY_STATUS]: [STATUS_NEVER_CONTACTED],
});
case STATUS_ACTIVE:
return updateUrlParams(url, {
[PARAM_KEY_PAUSED]: ['false'],
[PARAM_KEY_STATUS]: [], // Important! clear PARAM_KEY_STATUS to avoid a redirection loop!
});
case STATUS_PAUSED:
return updateUrlParams(url, {
[PARAM_KEY_PAUSED]: ['true'],
[PARAM_KEY_STATUS]: [], // Important! clear PARAM_KEY_STATUS to avoid a redirection loop!
});
default:
return null;
}
return null;
};
/**
@ -121,7 +148,7 @@ export const fromUrlQueryToSearch = (query = window.location.search) => {
runnerType,
filters: prepareTokens(
urlQueryToFilter(query, {
filterNamesAllowList: [PARAM_KEY_STATUS, PARAM_KEY_TAG],
filterNamesAllowList: [PARAM_KEY_PAUSED, PARAM_KEY_STATUS, PARAM_KEY_TAG],
filteredSearchTermKey: PARAM_KEY_SEARCH,
}),
),
@ -195,6 +222,12 @@ export const fromSearchToVariables = ({
filterVariables.search = queryObj[PARAM_KEY_SEARCH];
filterVariables.tagList = queryObj[PARAM_KEY_TAG];
if (queryObj[PARAM_KEY_PAUSED]) {
filterVariables.paused = parseBoolean(queryObj[PARAM_KEY_PAUSED]);
} else {
filterVariables.paused = undefined;
}
if (runnerType) {
filterVariables.type = runnerType;
}

View File

@ -1,4 +1,4 @@
import AccessorUtilities from '../../lib/utils/accessor';
import AccessorUtilities from '~/lib/utils/accessor';
import { MAX_FREQUENT_ITEMS, MAX_FREQUENCY, SIDEBAR_PARAMS } from './constants';
function extractKeys(object, keyList) {

View File

@ -3,7 +3,7 @@ import { GlButton, GlSkeletonLoader } from '@gitlab/ui';
import createFlash from '~/flash';
import { __ } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import simplePoll from '../../../lib/utils/simple_poll';
import simplePoll from '~/lib/utils/simple_poll';
import eventHub from '../../event_hub';
import mergeRequestQueryVariablesMixin from '../../mixins/merge_request_query_variables';
import rebaseQuery from '../../queries/states/rebase.query.graphql';

View File

@ -1,5 +1,5 @@
import { normalizeHeaders } from '~/lib/utils/common_utils';
import axios from '../../lib/utils/axios_utils';
import axios from '~/lib/utils/axios_utils';
export default class MRWidgetService {
constructor(endpoints) {

View File

@ -31,7 +31,7 @@ import { __ } from '~/locale';
import initMRPopovers from '~/mr_popover/';
import noteHeader from '~/notes/components/note_header.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { spriteIcon } from '../../../lib/utils/common_utils';
import { spriteIcon } from '~/lib/utils/common_utils';
import TimelineEntryItem from './timeline_entry_item.vue';
const MAX_VISIBLE_COMMIT_LIST_COUNT = 3;

View File

@ -2,7 +2,7 @@
import { GlTooltipDirective } from '@gitlab/ui';
import timeagoMixin from '../mixins/timeago';
import '../../lib/utils/datetime_utility';
import '~/lib/utils/datetime_utility';
/**
* Port of ruby helper time_ago_with_tooltip

View File

@ -1,4 +1,4 @@
import { formatDate, getTimeago } from '../../lib/utils/datetime_utility';
import { formatDate, getTimeago } from '~/lib/utils/datetime_utility';
/**
* Mixin with time ago methods used in some vue components

View File

@ -89,7 +89,7 @@ module Integrations
param_values = return_value[:integration]
if param_values.is_a?(ActionController::Parameters)
integration.password_fields.each do |param|
integration.secret_fields.each do |param|
param_values.delete(param) if param_values[param].blank?
end
end

View File

@ -12,7 +12,8 @@ module Resolvers
required: false,
description: 'Current state of this issue.'
type Types::IssueType.connection_type, null: true
# see app/graphql/types/issue_connection.rb
type 'Types::IssueConnection', null: true
NON_STABLE_CURSOR_SORTS = %i[priority_asc priority_desc
popularity_asc popularity_desc

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
# Normally this wouldn't be needed and we could use
# type Types::IssueType.connection_type, null: true
# in a resolver. However we can end up with cyclic definitions,
# which can result in errors like
# NameError: uninitialized constant Resolvers::GroupIssuesResolver
#
# Now we would use
# type "Types::IssueConnection", null: true
# which gives a delayed resolution, and the proper connection type.
# See app/graphql/resolvers/base_issues_resolver.rb
# Reference: https://github.com/rmosolgo/graphql-ruby/issues/3974#issuecomment-1084444214
Types::IssueConnection = Types::IssueType.connection_type

View File

@ -8,6 +8,7 @@ class Blob < SimpleDelegator
include BlobActiveModel
MODE_SYMLINK = '120000' # The STRING 120000 is the git-reported octal filemode for a symlink
MODE_EXECUTABLE = '100755' # The STRING 100755 is the git-reported octal filemode for an executable file
CACHE_TIME = 60 # Cache raw blobs referred to by a (mutable) ref for 1 minute
CACHE_TIME_IMMUTABLE = 3600 # Cache blobs referred to by an immutable reference for 1 hour
@ -181,6 +182,10 @@ class Blob < SimpleDelegator
mode == MODE_SYMLINK
end
def executable?
mode == MODE_EXECUTABLE
end
def extension
@extension ||= extname.downcase.delete('.')
end

View File

@ -428,7 +428,9 @@ class Integration < ApplicationRecord
[]
end
def password_fields
# TODO: Once all integrations use `Integrations::Field` we can
# use `#secret?` here.
def secret_fields
fields.select { |f| f[:type] == 'password' }.pluck(:name)
end

View File

@ -2,7 +2,7 @@
module Integrations
class Field
SENSITIVE_NAME = %r/token|key|password|passphrase|secret/.freeze
SECRET_NAME = %r/token|key|password|passphrase|secret/.freeze
ATTRIBUTES = %i[
section type placeholder required choices value checkbox_label
@ -17,7 +17,7 @@ module Integrations
def initialize(name:, type: 'text', api_only: false, **attributes)
@name = name.to_s.freeze
attributes[:type] = SENSITIVE_NAME.match?(@name) ? 'password' : type
attributes[:type] = SECRET_NAME.match?(@name) ? 'password' : type
attributes[:api_only] = api_only
@attributes = attributes.freeze
end
@ -31,7 +31,7 @@ module Integrations
value
end
def sensitive?
def secret?
@attributes[:type] == 'password'
end

View File

@ -789,6 +789,12 @@ class Repository
def create_file(user, path, content, **options)
options[:actions] = [{ action: :create, file_path: path, content: content }]
execute_filemode = options.delete(:execute_filemode)
unless execute_filemode.nil?
options[:actions].push({ action: :chmod, file_path: path, execute_filemode: execute_filemode })
end
multi_action(user, **options)
end
@ -798,6 +804,12 @@ class Repository
options[:actions] = [{ action: action, file_path: path, previous_path: previous_path, content: content }]
execute_filemode = options.delete(:execute_filemode)
unless execute_filemode.nil?
options[:actions].push({ action: :chmod, file_path: path, execute_filemode: execute_filemode })
end
multi_action(user, **options)
end

View File

@ -19,6 +19,8 @@ module Files
@file_content = params[:file_content]
@file_content = Base64.decode64(@file_content) if params[:file_content_encoding] == 'base64'
@execute_filemode = params[:execute_filemode]
end
def file_has_changed?(path, commit_id)

View File

@ -22,7 +22,8 @@ module Files
author_email: @author_email,
author_name: @author_name,
start_project: @start_project,
start_branch_name: @start_branch)
start_branch_name: @start_branch,
execute_filemode: @execute_filemode)
end
end
end

View File

@ -10,7 +10,8 @@ module Files
author_email: @author_email,
author_name: @author_name,
start_project: @start_project,
start_branch_name: @start_branch)
start_branch_name: @start_branch,
execute_filemode: @execute_filemode)
end
private

View File

@ -0,0 +1,16 @@
- name: "Removed feature flag PUSH_RULES_SUPERSEDE_CODE_OWNERS" # The name of the feature to be deprecated
announcement_milestone: "14.8" # The milestone when this feature was first announced as deprecated.
announcement_date: "2022-02-22" # The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
removal_milestone: "15.0" # The milestone when this feature is planned to be removed
removal_date: "2022-05-22" # The date of the milestone release when this feature is planned to be removed. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
breaking_change: true # If this deprecation is a breaking change, set this value to true
reporter: tlinz # GitLab username of the person reporting the deprecation
body: | # Do not modify this line, instead modify the lines below.
The feature flag `PUSH_RULES_SUPERSEDE_CODE_OWNERS` has been removed in GitLab 15.0. From now on, push rules will supersede CODEOWNERS. The CODEOWNERS feature is no longer available for access control.
# The following items are not published on the docs page, but may be used in the future.
stage: create # (optional - may be required in the future) String value of the stage that the feature was created in. e.g., Growth
tiers: # (optional - may be required in the future) An array of tiers that the feature is available in currently. e.g., [Free, Silver, Gold, Core, Premium, Ultimate]
issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/262019 # (optional) This is a link to the deprecation issue in GitLab
documentation_url: # (optional) This is a link to the current documentation page
image_url: # (optional) This is a link to a thumbnail image depicting the feature
video_url: # (optional) Use the youtube thumbnail URL with the structure of https://img.youtube.com/vi/UNIQUEID/hqdefault.jpg

View File

@ -248,10 +248,11 @@ The `Content-Type` header must be `application/gzip`.
## Import a file from AWS S3
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/348874) in GitLab 14.9 in [Beta](https://about.gitlab.com/handbook/product/gitlab-the-product/#beta), [with a flag](../administration/feature_flags.md) named `import_project_from_remote_file_s3`. Disabled by default.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/348874) in GitLab 14.9 in [Beta](https://about.gitlab.com/handbook/product/gitlab-the-product/#beta), [with a flag](../administration/feature_flags.md) named `import_project_from_remote_file_s3`. Disabled by default.
> - [Enabled on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/348874) in GitLab 14.10.
FLAG:
On self-managed GitLab and GitLab.com, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../administration/feature_flags.md) named `import_project_from_remote_file_s3`. This feature is not ready for production use.
On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../administration/feature_flags.md) named `import_project_from_remote_file_s3`. On GitLab.com, this feature is available.
```plaintext
POST /projects/remote-import-s3
@ -261,6 +262,7 @@ POST /projects/remote-import-s3
| ------------------- | -------------- | -------- | ---------------------------------------- |
| `namespace` | integer/string | no | The ID or path of the namespace to import the project to. Defaults to the current user's namespace. |
| `name` | string | no | The name of the project to import. If not provided, defaults to the path of the project. |
| `path` | string | yes | The full path of the new project. |
| `region` | string | yes | [AWS S3 region name where the file is stored.](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html#Regions) |
| `bucket_name` | string | yes | [AWS S3 bucket name where the file is stored.](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html) |
| `file_key` | string | yes | [AWS S3 file key to identify the file.](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingObjects.html) |
@ -271,7 +273,7 @@ The passed override parameters take precedence over all values defined in the ex
```shell
curl --request POST \
--url "http://localhost:3000/api/v4/projects/remote-import-s3" \
--url "https://gitlab.example.com/api/v4/projects/remote-import-s3" \
--header "PRIVATE-TOKEN: <your gitlab access key>" \
--header 'Content-Type: application/json' \
--data '{

View File

@ -23,6 +23,8 @@ in the following table.
## Get file from repository
> The `execute_filemode` field in the response was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/83499) in GitLab 14.10.
Allows you to receive information about file in repository like name, size,
content. File content is Base64 encoded. This endpoint can be accessed
without authentication if the repository is publicly accessible.
@ -54,7 +56,8 @@ Example response:
"ref": "master",
"blob_id": "79f7bbd25901e8334750839545a9bd021f0e4c83",
"commit_id": "d5a3ff139356ce33e37e73add446f16869741b50",
"last_commit_id": "570e7b2abdd848b95f2f578043fc23bd6f6fd24d"
"last_commit_id": "570e7b2abdd848b95f2f578043fc23bd6f6fd24d",
"execute_filemode": false
}
```
@ -85,6 +88,7 @@ X-Gitlab-File-Path: app/models/key.rb
X-Gitlab-Last-Commit-Id: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
X-Gitlab-Ref: master
X-Gitlab-Size: 1476
X-Gitlab-Execute-Filemode: false
...
```
@ -155,6 +159,7 @@ X-Gitlab-File-Path: path/to/file.rb
X-Gitlab-Last-Commit-Id: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
X-Gitlab-Ref: master
X-Gitlab-Size: 1476
X-Gitlab-Execute-Filemode: false
...
```
@ -179,6 +184,8 @@ Like [Get file from repository](repository_files.md#get-file-from-repository) yo
## Create new file in repository
> The `execute_filemode` parameter was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/83499) in GitLab 14.10.
This allows you to create a single file. For creating multiple files with a single request see the [commits API](commits.md#create-a-commit-with-multiple-files-and-actions).
```plaintext
@ -196,6 +203,7 @@ POST /projects/:id/repository/files/:file_path
| `author_name` | string | no | The commit author's name. |
| `content` | string | yes | The file's content. |
| `commit_message` | string | yes | The commit message. |
| `execute_filemode` | boolean | no | Enables or disables the `execute` flag on the file. Can be `true` or `false`. |
```shell
curl --request POST --header 'PRIVATE-TOKEN: <your_access_token>' \
@ -216,6 +224,8 @@ Example response:
## Update existing file in repository
> The `execute_filemode` parameter was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/83499) in GitLab 14.10.
This allows you to update a single file. For updating multiple files with a single request see the [commits API](commits.md#create-a-commit-with-multiple-files-and-actions).
```plaintext
@ -234,6 +244,7 @@ PUT /projects/:id/repository/files/:file_path
| `content` | string | yes | The file's content. |
| `commit_message` | string | yes | The commit message. |
| `last_commit_id` | string | no | Last known file commit ID. |
| `execute_filemode` | boolean | no | Enables or disables the `execute` flag on the file. Can be `true` or `false`. |
```shell
curl --request PUT --header 'PRIVATE-TOKEN: <your_access_token>' \

View File

@ -4,7 +4,7 @@ group: Runner
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# VM instances and images for SaaS runners on macOS **(FREE SAAS)**
# VM instances and images for SaaS runners on macOS **(PREMIUM SAAS)**
When you use SaaS runners on macOS:

View File

@ -4,7 +4,7 @@ group: Runner
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# SaaS runners on macOS (beta) **(FREE SAAS)**
# SaaS runners on macOS (beta) **(PREMIUM SAAS)**
SaaS runners on macOS are in [Beta](../../../policy/alpha-beta-support.md#beta-features)
and shouldn't be relied upon for mission-critical production jobs.

View File

@ -5,26 +5,26 @@ info: To determine the technical writer assigned to the Stage/Group associated w
type: index, howto
---
# Contribute to the CI Schema **(FREE)**
# Contribute to the CI/CD Schema **(FREE)**
The [pipeline editor](../../ci/pipeline_editor/index.md) uses a CI schema to enhance
the authoring experience of our CI configuration files. With the CI schema, the editor can:
The [pipeline editor](../../ci/pipeline_editor/index.md) uses a CI/CD schema to enhance
the authoring experience of our CI/CD configuration files. With the CI/CD schema, the editor can:
- Validate the content of the CI configuration file as it is being written in the editor.
- Validate the content of the CI/CD configuration file as it is being written in the editor.
- Provide autocomplete functionality and suggest available keywords.
- Provide definitions of keywords through annotations.
As the rules and keywords for configuring our CI configuration files change, so too
should our CI schema.
As the rules and keywords for configuring our CI/CD configuration files change, so too
should our CI/CD schema.
This feature is behind the [`schema_linting`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/feature_flags/development/schema_linting.yml)
feature flag for self-managed instances, and is enabled for GitLab.com.
## JSON Schemas
The CI schema follows the [JSON Schema Draft-07](https://json-schema.org/draft-07/json-schema-release-notes.html)
specification. Although the CI configuration file is written in YAML, it is converted
into JSON by using `monaco-yaml` before it is validated by the CI schema.
The CI/CD schema follows the [JSON Schema Draft-07](https://json-schema.org/draft-07/json-schema-release-notes.html)
specification. Although the CI/CD configuration file is written in YAML, it is converted
into JSON by using `monaco-yaml` before it is validated by the CI/CD schema.
If you're new to JSON schemas, consider checking out
[this guide](https://json-schema.org/learn/getting-started-step-by-step) for
@ -32,8 +32,8 @@ a step-by-step introduction on how to work with JSON schemas.
## Update Keywords
The CI schema is at [`app/assets/javascripts/editor/schema/ci.json`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/editor/schema/ci.json).
It contains all the keywords available for authoring CI configuration files.
The CI/CD schema is at [`app/assets/javascripts/editor/schema/ci.json`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/editor/schema/ci.json).
It contains all the keywords available for authoring CI/CD configuration files.
Check the [keyword reference](../../ci/yaml/index.md) for a comprehensive list of
all available keywords.
@ -138,7 +138,7 @@ under the topmost **properties** key.
## Test the schema
For now, the CI schema can only be tested manually. To verify the behavior is correct:
For now, the CI/CD schema can only be tested manually. To verify the behavior is correct:
1. Enable the `schema_linting` feature flag.
1. Go to **CI/CD** > **Editor**.

View File

@ -97,9 +97,8 @@ a given group, request an engineering review from one of the group's members.
After the engineering review is complete, assign the MR to the
[Technical Writer associated with the stage and group](https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments)
in the modified documentation page's metadata.
If you have questions or need further input, request a review from the
Technical Writer assigned to the [Development Guidelines](https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments-to-development-guidelines).
If the page is not assigned to a specific group, follow the
[Technical Writing review process for development guidelines](https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments-to-development-guidelines).
#### Broader changes
@ -139,12 +138,13 @@ In these cases, use the following workflow:
and approval from the VP of Development, the DRI for Development Guidelines,
@clefelhocz1.
1. After all approvals are complete, review the page's metadata to
[find a Technical Writer](https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments)
who can help you merge the changes.
for final content review and merge. The Technical Writer may ask for
additional approvals as previously suggested before merging the MR.
1. After all approvals are complete, assign the MR to the
[Technical Writer associated with the stage and group](https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments)
in the modified documentation page's metadata.
If the page is not assigned to a specific group, follow the
[Technical Writing review process for development guidelines](https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments-to-development-guidelines).
The Technical Writer may ask for additional approvals as previously suggested before merging the MR.
### Reviewer values
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57293) in GitLab 14.1.

View File

@ -250,189 +250,7 @@ Leading indicators may be health check failures leading to restarts or majority
The [Review Apps Overview dashboard](https://console.cloud.google.com/monitoring/classic/dashboards/6798952013815386466?project=gitlab-review-apps&timeDomain=1d)
aids in identifying load spikes on the cluster, and if nodes are problematic or the entire cluster is trending towards unhealthy.
### Database related errors in `review-deploy`, `review-qa-smoke`, or `review-qa-reliable`
Occasionally the state of a Review App's database could diverge from the database schema. This could be caused by
changes to migration files or schema, such as a migration being renamed or deleted. This typically manifests in migration errors such as:
- migration job failing with a column that already exists
- migration job failing with a column that does not exist
To recover from this, please attempt to [redeploy Review App from a clean slate](#redeploy-review-app-from-a-clean-slate)
### Release failed with `ImagePullBackOff`
**Potential cause:**
If you see an `ImagePullBackoff` status, check for a missing Docker image.
**Where to look for further debugging:**
To check that the Docker images were created, run the following Docker command:
```shell
`DOCKER_CLI_EXPERIMENTAL=enabled docker manifest repository:tag`
```
The output of this command indicates if the Docker image exists. For example:
```shell
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect registry.gitlab.com/gitlab-org/build/cng-mirror/gitlab-rails-ee:39467-allow-a-release-s-associated-milestones-to-be-edited-thro
```
If the Docker image does not exist:
- Verify the `image.repository` and `image.tag` options in the `helm upgrade --install` command match the repository names used by CNG-mirror pipeline.
- Look further in the corresponding downstream CNG-mirror pipeline in `review-build-cng` job.
### Node count is always increasing (never stabilizing or decreasing)
**Potential cause:**
That could be a sign that the `review-cleanup` job is
failing to cleanup stale Review Apps and Kubernetes resources.
**Where to look for further debugging:**
Look at the latest `review-cleanup` job log, and identify look for any
unexpected failure.
### p99 CPU utilization is at 100% for most of the nodes and/or many components
**Potential cause:**
This could be a sign that Helm is failing to deploy Review Apps. When Helm has a
lot of `FAILED` releases, it seems that the CPU utilization is increasing, probably
due to Helm or Kubernetes trying to recreate the components.
**Where to look for further debugging:**
Look at a recent `review-deploy` job log.
**Useful commands:**
```shell
# Identify if node spikes are common or load on specific nodes which may get rebalanced by the Kubernetes scheduler
kubectl top nodes | sort --key 3 --numeric
# Identify pods under heavy CPU load
kubectl top pods | sort --key 2 --numeric
```
### The `logging/user/events/FailedMount` chart is going up
**Potential cause:**
This could be a sign that there are too many stale secrets and/or configuration maps.
**Where to look for further debugging:**
Look at [the list of Configurations](https://console.cloud.google.com/kubernetes/config?project=gitlab-review-apps)
or `kubectl get secret,cm --sort-by='{.metadata.creationTimestamp}' | grep 'review-'`.
Any secrets or configuration maps older than 5 days are suspect and should be deleted.
**Useful commands:**
```shell
# List secrets and config maps ordered by created date
kubectl get secret,cm --sort-by='{.metadata.creationTimestamp}' | grep 'review-'
# Delete all secrets that are 5 to 9 days old
kubectl get secret --sort-by='{.metadata.creationTimestamp}' | grep '^review-' | grep '[5-9]d$' | cut -d' ' -f1 | xargs kubectl delete secret
# Delete all secrets that are 10 to 99 days old
kubectl get secret --sort-by='{.metadata.creationTimestamp}' | grep '^review-' | grep '[1-9][0-9]d$' | cut -d' ' -f1 | xargs kubectl delete secret
# Delete all config maps that are 5 to 9 days old
kubectl get cm --sort-by='{.metadata.creationTimestamp}' | grep 'review-' | grep -v 'dns-gitlab-review-app' | grep '[5-9]d$' | cut -d' ' -f1 | xargs kubectl delete cm
# Delete all config maps that are 10 to 99 days old
kubectl get cm --sort-by='{.metadata.creationTimestamp}' | grep 'review-' | grep -v 'dns-gitlab-review-app' | grep '[1-9][0-9]d$' | cut -d' ' -f1 | xargs kubectl delete cm
```
### Using K9s
[K9s](https://github.com/derailed/k9s) is a powerful command line dashboard which allows you to filter by labels. This can help identify trends with apps exceeding the [review-app resource requests](https://gitlab.com/gitlab-org/gitlab/-/blob/master/scripts/review_apps/base-config.yaml). Kubernetes schedules pods to nodes based on resource requests and allow for CPU usage up to the limits.
- In K9s you can sort or add filters by typing the `/` character
- `-lrelease=<review-app-slug>` - filters down to all pods for a release. This aids in determining what is having issues in a single deployment
- `-lapp=<app>` - filters down to all pods for a specific app. This aids in determining resource usage by app.
- You can scroll to a Kubernetes resource and hit `d`(describe), `s`(shell), `l`(logs) for a deeper inspection
![K9s](img/k9s.png)
### Troubleshoot a pending `dns-gitlab-review-app-external-dns` Deployment
#### Finding the problem
[In the past](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/62834), it happened
that the `dns-gitlab-review-app-external-dns` Deployment was in a pending state,
effectively preventing all the Review Apps from getting a DNS record assigned,
making them unreachable via domain name.
This in turn prevented other components of the Review App to properly start
(for example, `gitlab-runner`).
After some digging, we found that new mounts fail when performed
with transient scopes (for example, pods) of `systemd-mount`:
```plaintext
MountVolume.SetUp failed for volume "dns-gitlab-review-app-external-dns-token-sj5jm" : mount failed: exit status 1
Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/06add1c3-87b4-11e9-80a9-42010a800107/volumes/kubernetes.io~secret/dns-gitlab-review-app-external-dns-token-sj5jm --scope -- mount -t tmpfs tmpfs /var/lib/kubelet/pods/06add1c3-87b4-11e9-80a9-42010a800107/volumes/kubernetes.io~secret/dns-gitlab-review-app-external-dns-token-sj5jm
Output: Failed to start transient scope unit: Connection timed out
```
This probably happened because the GitLab chart creates 67 resources, leading to
a lot of mount points being created on the underlying GCP node.
The [underlying issue seems to be a `systemd` bug](https://github.com/kubernetes/kubernetes/issues/57345#issuecomment-359068048)
that was fixed in `systemd` `v237`. Unfortunately, our GCP nodes are currently
using `v232`.
For the record, the debugging steps to find out this issue were:
1. Switch kubectl context to `review-apps-ce` (we recommend using [`kubectx`](https://github.com/ahmetb/kubectx/))
1. `kubectl get pods | grep dns`
1. `kubectl describe pod <pod name>` & confirm exact error message
1. Web search for exact error message, following rabbit hole to [a relevant Kubernetes bug report](https://github.com/kubernetes/kubernetes/issues/57345)
1. Access the node over SSH via the GCP console (**Computer Engine > VM
instances** then click the "SSH" button for the node where the `dns-gitlab-review-app-external-dns` pod runs)
1. In the node: `systemctl --version` => `systemd 232`
1. Gather some more information:
- `mount | grep kube | wc -l` (returns a count, for example, 290)
- `systemctl list-units --all | grep -i var-lib-kube | wc -l` (returns a count, for example, 142)
1. Check how many pods are in a bad state:
- Get all pods running a given node: `kubectl get pods --field-selector=spec.nodeName=NODE_NAME`
- Get all the `Running` pods on a given node: `kubectl get pods --field-selector=spec.nodeName=NODE_NAME | grep Running`
- Get all the pods in a bad state on a given node: `kubectl get pods --field-selector=spec.nodeName=NODE_NAME | grep -v 'Running' | grep -v 'Completed'`
#### Solving the problem
To resolve the problem, we needed to (forcibly) drain some nodes:
1. Try a normal drain on the node where the `dns-gitlab-review-app-external-dns`
pod runs so that Kubernetes automatically move it to another node: `kubectl drain NODE_NAME`
1. If that doesn't work, you can also perform a forcible "drain" the node by removing all pods: `kubectl delete pods --field-selector=spec.nodeName=NODE_NAME`
1. In the node:
- Perform `systemctl daemon-reload` to remove the dead/inactive units
- If that doesn't solve the problem, perform a hard reboot: `sudo systemctl reboot`
1. Uncordon any cordoned nodes: `kubectl uncordon NODE_NAME`
In parallel, since most Review Apps were in a broken state, we deleted them to
clean up the list of non-`Running` pods.
Following is a command to delete Review Apps based on their last deployment date
(current date was June 6th at the time) with
```shell
helm ls -d | grep "Jun 4" | cut -f1 | xargs helm delete --purge
```
#### Mitigation steps taken to avoid this problem in the future
We've created a new node pool with smaller machines to reduce the risk
that a machine reaches the "too many mount points" problem in the future.
See the [review apps page of the Engineering Productivity Runbook](https://gitlab.com/gitlab-org/quality/engineering-productivity/team/-/blob/main/runbook/review-apps.md) for troubleshooting review app releases.
## Frequently Asked Questions

View File

@ -0,0 +1,51 @@
---
stage: Enablement
group: Distribution
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
comments: false
description: Install GitLab in a cloud native environment
type: index
---
# Cloud Native GitLab **(FREE SELF)**
[Cloud Native GitLab](https://gitlab.com/gitlab-org/build/CNG) provides cloud
native containers to deploy GitLab. These containers may be deployed and managed
via Helm using GitLab Charts or GitLab Operator on Kubernetes, OpenShift,
and Kubernetes compatible container platforms:
- [Helm charts](https://docs.gitlab.com/charts/): The cloud native Helm chart
installs GitLab and all of its components on Kubernetes. Use this method if
your infrastructure is built on Kubernetes and you're familiar with how it
works. The methods for management, observability, and some concepts are
different than traditional deployments.
- [GitLab Operator](https://docs.gitlab.com/operator/): The GitLab Operator
provides an installation and management method for GitLab following the
[Kubernetes Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/).
You can also use the GitLab Operator to run GitLab in an
[OpenShift](../openshift_and_gitlab/index.md) environment.
Here's an overview of how the containers are built:
```mermaid
graph TD
subgraph Code
CNG --> HC
CNG --> GOP
HC --> GOP
end
subgraph Deploy
GOP --> K8s
GOP --> OS
CNG --> DC
HC --> K8s
end
CNG[Cloud Native GitLab containers]
HC[Helm Chart]
K8s(Kubernetes)
GOP[GitLab Operator]
OS(OpenShift)
DC(Docker Compose)
```

View File

@ -29,10 +29,10 @@ install GitLab:
|----------------------------------------------------------------|-------------|----------------|
| [Linux package](https://docs.gitlab.com/omnibus/installation/) | The official deb/rpm packages (also known as Omnibus GitLab) that contains a bundle of GitLab and the components it depends on, including PostgreSQL, Redis, and Sidekiq. | This method is recommended for getting started. The Linux packages are mature, scalable, and are used today on GitLab.com. If you need additional flexibility and resilience, we recommend deploying GitLab as described in the [reference architecture documentation](../administration/reference_architectures/index.md). |
| [Helm charts](https://docs.gitlab.com/charts/) | The cloud native Helm chart for installing GitLab and all of its components on Kubernetes. | When installing GitLab on Kubernetes, there are some trade-offs that you need to be aware of: <br/>- Administration and troubleshooting requires Kubernetes knowledge.<br/>- It can be more expensive for smaller installations. The default installation requires more resources than a single node Linux package deployment, as most services are deployed in a redundant fashion.<br/><br/> Use this method if your infrastructure is built on Kubernetes and you're familiar with how it works. The methods for management, observability, and some concepts are different than traditional deployments. |
| [Docker](https://docs.gitlab.com/omnibus/docker/) | The GitLab packages, Dockerized. | Use this method if you're familiar with Docker. |
| [Docker](docker.md) | The GitLab packages, Dockerized. | Use this method if you're familiar with Docker. |
| [Source](installation.md) | Install GitLab and all of its components from scratch. | Use this method if none of the previous methods are available for your platform. Useful for unsupported systems like \*BSD.|
| [GitLab Environment Toolkit (GET)](https://gitlab.com/gitlab-org/gitlab-environment-toolkit#documentation) | The GitLab Environment Toolkit provides a set of automation tools to deploy a [reference architecture](../administration/reference_architectures/index.md) on most major cloud providers. | Customers are very welcome to trial and evaluate GET today, however be aware of [key limitations](https://gitlab.com/gitlab-org/gitlab-environment-toolkit#missing-features-to-be-aware-of) of the current iteration. For production environments further manual setup will be required based on your specific requirements. |
| [GitLab Operator](https://docs.gitlab.com/charts/installation/operator.html) | The GitLab Operator provides an installation and management method for GitLab following the [Kubernetes Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/). | Use the GitLab Operator to run GitLab in an [OpenShift](openshift_and_gitlab/index.md) environment. |
| [GitLab Operator](https://docs.gitlab.com/operator/) | The GitLab Operator provides an installation and management method for GitLab following the [Kubernetes Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/). | Use the GitLab Operator to run GitLab in an [OpenShift](openshift_and_gitlab/index.md) environment. |
## Install GitLab on cloud providers

View File

@ -30,6 +30,16 @@ For removal reviewers (Technical Writers only):
## 15.0
### Removed feature flag PUSH_RULES_SUPERSEDE_CODE_OWNERS
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
The feature flag `PUSH_RULES_SUPERSEDE_CODE_OWNERS` has been removed in GitLab 15.0. From now on, push rules will supersede CODEOWNERS. The CODEOWNERS feature is no longer available for access control.
### Request a new review
The ability to [request a new review](https://docs.gitlab.com/ee/user/project/merge_requests/reviews/#request-a-new-review) has been removed in GitLab 15.0. This feature is replaced with [requesting attention](https://docs.gitlab.com/ee/user/project/merge_requests/#request-attention-to-a-merge-request) to a merge request.

View File

@ -156,7 +156,9 @@ test:
- npx nyc --reporter cobertura mocha
artifacts:
reports:
cobertura: coverage/cobertura-coverage.xml
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
```
### Java and Kotlin examples

View File

@ -24,7 +24,8 @@ module API
file_content_encoding: attrs[:encoding],
author_email: attrs[:author_email],
author_name: attrs[:author_name],
last_commit_sha: attrs[:last_commit_id]
last_commit_sha: attrs[:last_commit_id],
execute_filemode: attrs[:execute_filemode]
}
end
@ -65,7 +66,8 @@ module API
ref: params[:ref],
blob_id: @blob.id,
commit_id: @commit.id,
last_commit_id: @repo.last_commit_id_for_path(@commit.sha, params[:file_path], literal_pathspec: true)
last_commit_id: @repo.last_commit_id_for_path(@commit.sha, params[:file_path], literal_pathspec: true),
execute_filemode: @blob.executable?
}
end
@ -83,6 +85,7 @@ module API
requires :content, type: String, desc: 'File content'
optional :encoding, type: String, values: %w[base64], desc: 'File encoding'
optional :last_commit_id, type: String, desc: 'Last known commit id for this file'
optional :execute_filemode, type: Boolean, desc: 'Enable / Disable the executable flag on the file path'
end
end

View File

@ -59,10 +59,8 @@ module ErrorTracking
end
end
def http_request
response = handle_request_exceptions do
yield
end
def http_request(&block)
response = handle_request_exceptions(&block)
handle_response(response)
end
@ -86,9 +84,7 @@ module ErrorTracking
end
def handle_response(response)
unless response.code.between?(200, 204)
raise_error "Sentry response status code: #{response.code}"
end
raise_error "Sentry response status code: #{response.code}" unless response.code.between?(200, 204)
{ body: response.parsed_response, headers: response.headers }
end

View File

@ -15,14 +15,14 @@ module ErrorTracking
stack_trace = parse_stack_trace(event)
Gitlab::ErrorTracking::ErrorEvent.new(
issue_id: event.dig('groupID'),
date_received: event.dig('dateReceived'),
issue_id: event['groupID'],
date_received: event['dateReceived'],
stack_trace_entries: stack_trace
)
end
def parse_stack_trace(event)
exception_entry = event.dig('entries')&.detect { |h| h['type'] == 'exception' }
exception_entry = event['entries']&.detect { |h| h['type'] == 'exception' }
return [] unless exception_entry
exception_values = exception_entry.dig('data', 'values')

View File

@ -54,9 +54,7 @@ module ErrorTracking
end
def list_issue_sentry_query(issue_status:, limit:, sort: nil, search_term: '', cursor: nil)
unless SENTRY_API_SORT_VALUE_MAP.key?(sort)
raise BadRequestError, 'Invalid value for sort param'
end
raise BadRequestError, 'Invalid value for sort param' unless SENTRY_API_SORT_VALUE_MAP.key?(sort)
{
query: "is:#{issue_status} #{search_term}".strip,
@ -69,7 +67,8 @@ module ErrorTracking
def validate_size(issues)
return if Gitlab::Utils::DeepSize.new(issues).valid?
raise ResponseInvalidSizeError, "Sentry API response is too big. Limit is #{Gitlab::Utils::DeepSize.human_default_max_size}."
message = "Sentry API response is too big. Limit is #{Gitlab::Utils::DeepSize.human_default_max_size}."
raise ResponseInvalidSizeError, message
end
def get_issue(issue_id:)
@ -117,7 +116,7 @@ module ErrorTracking
end
def map_to_errors(issues)
issues.map(&method(:map_to_error))
issues.map { map_to_error(_1) }
end
def map_to_error(issue)
@ -142,7 +141,7 @@ module ErrorTracking
end
def map_to_detailed_error(issue)
Gitlab::ErrorTracking::DetailedError.new({
Gitlab::ErrorTracking::DetailedError.new(
id: issue.fetch('id'),
first_seen: issue.fetch('firstSeen', nil),
last_seen: issue.fetch('lastSeen', nil),
@ -169,7 +168,7 @@ module ErrorTracking
last_release_short_version: issue.dig('lastRelease', 'shortVersion'),
last_release_version: issue.dig('lastRelease', 'version'),
integrated: false
})
)
end
def extract_tags(issue)

View File

@ -3,7 +3,7 @@
module ErrorTracking
class SentryClient
module PaginationParser
PATTERN = /rel=\"(?<direction>\w+)\";\sresults=\"(?<results>\w+)\";\scursor=\"(?<cursor>.+)\"/.freeze
PATTERN = /rel="(?<direction>\w+)";\sresults="(?<results>\w+)";\scursor="(?<cursor>.+)"/.freeze
def self.parse(headers)
links = headers['link'].to_s.split(',')

View File

@ -18,7 +18,7 @@ module ErrorTracking
end
def map_to_projects(projects)
projects.map(&method(:map_to_project))
projects.map { map_to_project(_1) }
end
def map_to_project(project)
@ -28,7 +28,7 @@ module ErrorTracking
id: project.fetch('id', nil),
name: project.fetch('name'),
slug: project.fetch('slug'),
status: project.dig('status'),
status: project['status'],
organization_name: organization.fetch('name'),
organization_id: organization.fetch('id', nil),
organization_slug: organization.fetch('slug')

View File

@ -23,7 +23,7 @@ module ErrorTracking
end
def map_to_repos(repos)
repos.map(&method(:map_to_repo))
repos.map { map_to_repo(_1) }
end
def map_to_repo(repo)

View File

@ -154,35 +154,69 @@ RSpec.describe "Admin Runners" do
end
end
describe 'filter by paused' do
before do
create(:ci_runner, :instance, description: 'runner-active')
create(:ci_runner, :instance, description: 'runner-paused', active: false)
visit admin_runners_path
end
it 'shows all runners' do
expect(page).to have_link('All 2')
expect(page).to have_content 'runner-active'
expect(page).to have_content 'runner-paused'
end
it 'shows paused runners' do
input_filtered_search_filter_is_only('Paused', 'Yes')
expect(page).to have_link('All 1')
expect(page).not_to have_content 'runner-active'
expect(page).to have_content 'runner-paused'
end
it 'shows active runners' do
input_filtered_search_filter_is_only('Paused', 'No')
expect(page).to have_link('All 1')
expect(page).to have_content 'runner-active'
expect(page).not_to have_content 'runner-paused'
end
end
describe 'filter by status' do
let!(:never_contacted) { create(:ci_runner, :instance, description: 'runner-never-contacted', contacted_at: nil) }
before do
create(:ci_runner, :instance, description: 'runner-1', contacted_at: Time.zone.now)
create(:ci_runner, :instance, description: 'runner-2', contacted_at: Time.zone.now)
create(:ci_runner, :instance, description: 'runner-paused', active: false, contacted_at: Time.zone.now)
create(:ci_runner, :instance, description: 'runner-offline', contacted_at: 1.week.ago)
visit admin_runners_path
end
it 'shows all runners' do
expect(page).to have_link('All 4')
expect(page).to have_content 'runner-1'
expect(page).to have_content 'runner-2'
expect(page).to have_content 'runner-paused'
expect(page).to have_content 'runner-offline'
expect(page).to have_content 'runner-never-contacted'
expect(page).to have_link('All 4')
end
it 'shows correct runner when status matches' do
input_filtered_search_filter_is_only('Status', 'Active')
input_filtered_search_filter_is_only('Status', 'Online')
expect(page).to have_link('All 3')
expect(page).to have_link('All 2')
expect(page).to have_content 'runner-1'
expect(page).to have_content 'runner-2'
expect(page).to have_content 'runner-never-contacted'
expect(page).not_to have_content 'runner-paused'
expect(page).not_to have_content 'runner-offline'
expect(page).not_to have_content 'runner-never-contacted'
end
it 'shows no runner when status does not match' do
@ -194,15 +228,15 @@ RSpec.describe "Admin Runners" do
end
it 'shows correct runner when status is selected and search term is entered' do
input_filtered_search_filter_is_only('Status', 'Active')
input_filtered_search_filter_is_only('Status', 'Online')
input_filtered_search_keys('runner-1')
expect(page).to have_link('All 1')
expect(page).to have_content 'runner-1'
expect(page).not_to have_content 'runner-2'
expect(page).not_to have_content 'runner-offline'
expect(page).not_to have_content 'runner-never-contacted'
expect(page).not_to have_content 'runner-paused'
end
it 'shows correct runner when status filter is entered' do
@ -308,7 +342,7 @@ RSpec.describe "Admin Runners" do
visit admin_runners_path
input_filtered_search_filter_is_only('Status', 'Active')
input_filtered_search_filter_is_only('Paused', 'No')
expect(page).to have_content 'runner-project'
expect(page).to have_content 'runner-group'
@ -427,6 +461,18 @@ RSpec.describe "Admin Runners" do
expect(page).to have_current_path(admin_runners_path('status[]': 'NEVER_CONTACTED') )
end
it 'updates ACTIVE runner status to paused=false' do
visit admin_runners_path('status[]': 'ACTIVE')
expect(page).to have_current_path(admin_runners_path('paused[]': 'false') )
end
it 'updates PAUSED runner status to paused=true' do
visit admin_runners_path('status[]': 'PAUSED')
expect(page).to have_current_path(admin_runners_path('paused[]': 'true') )
end
end
describe 'runners registration' do

View File

@ -31,9 +31,10 @@ import {
INSTANCE_TYPE,
GROUP_TYPE,
PROJECT_TYPE,
PARAM_KEY_PAUSED,
PARAM_KEY_STATUS,
PARAM_KEY_TAG,
STATUS_ACTIVE,
STATUS_ONLINE,
RUNNER_PAGE_SIZE,
} from '~/runner/constants';
import adminRunnersQuery from '~/runner/graphql/list/admin_runners.query.graphql';
@ -242,6 +243,10 @@ describe('AdminRunnersApp', () => {
createComponent({ mountFn: mountExtended });
expect(findFilteredSearch().props('tokens')).toEqual([
expect.objectContaining({
type: PARAM_KEY_PAUSED,
options: expect.any(Array),
}),
expect.objectContaining({
type: PARAM_KEY_STATUS,
options: expect.any(Array),
@ -297,7 +302,7 @@ describe('AdminRunnersApp', () => {
describe('when a filter is preselected', () => {
beforeEach(async () => {
setWindowLocation(`?status[]=${STATUS_ACTIVE}&runner_type[]=${INSTANCE_TYPE}&tag[]=tag1`);
setWindowLocation(`?status[]=${STATUS_ONLINE}&runner_type[]=${INSTANCE_TYPE}&tag[]=tag1`);
createComponent();
await waitForPromises();
@ -307,7 +312,7 @@ describe('AdminRunnersApp', () => {
expect(findRunnerFilteredSearchBar().props('value')).toEqual({
runnerType: INSTANCE_TYPE,
filters: [
{ type: 'status', value: { data: STATUS_ACTIVE, operator: '=' } },
{ type: 'status', value: { data: STATUS_ONLINE, operator: '=' } },
{ type: 'tag', value: { data: 'tag1', operator: '=' } },
],
sort: 'CREATED_DESC',
@ -317,7 +322,7 @@ describe('AdminRunnersApp', () => {
it('requests the runners with filter parameters', () => {
expect(mockRunnersQuery).toHaveBeenLastCalledWith({
status: STATUS_ACTIVE,
status: STATUS_ONLINE,
type: INSTANCE_TYPE,
tagList: ['tag1'],
sort: DEFAULT_SORT,
@ -330,7 +335,7 @@ describe('AdminRunnersApp', () => {
beforeEach(() => {
findRunnerFilteredSearchBar().vm.$emit('input', {
runnerType: null,
filters: [{ type: PARAM_KEY_STATUS, value: { data: STATUS_ACTIVE, operator: '=' } }],
filters: [{ type: PARAM_KEY_STATUS, value: { data: STATUS_ONLINE, operator: '=' } }],
sort: CREATED_ASC,
});
});
@ -338,13 +343,13 @@ describe('AdminRunnersApp', () => {
it('updates the browser url', () => {
expect(updateHistory).toHaveBeenLastCalledWith({
title: expect.any(String),
url: 'http://test.host/admin/runners?status[]=ACTIVE&sort=CREATED_ASC',
url: 'http://test.host/admin/runners?status[]=ONLINE&sort=CREATED_ASC',
});
});
it('requests the runners with filters', () => {
expect(mockRunnersQuery).toHaveBeenLastCalledWith({
status: STATUS_ACTIVE,
status: STATUS_ONLINE,
sort: CREATED_ASC,
first: RUNNER_PAGE_SIZE,
});

View File

@ -4,7 +4,7 @@ import RunnerFilteredSearchBar from '~/runner/components/runner_filtered_search_
import { statusTokenConfig } from '~/runner/components/search_tokens/status_token_config';
import TagToken from '~/runner/components/search_tokens/tag_token.vue';
import { tagTokenConfig } from '~/runner/components/search_tokens/tag_token_config';
import { PARAM_KEY_STATUS, PARAM_KEY_TAG, STATUS_ACTIVE, INSTANCE_TYPE } from '~/runner/constants';
import { PARAM_KEY_STATUS, PARAM_KEY_TAG, STATUS_ONLINE, INSTANCE_TYPE } from '~/runner/constants';
import FilteredSearch from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
@ -18,7 +18,7 @@ describe('RunnerList', () => {
const mockDefaultSort = 'CREATED_DESC';
const mockOtherSort = 'CONTACTED_DESC';
const mockFilters = [
{ type: PARAM_KEY_STATUS, value: { data: STATUS_ACTIVE, operator: '=' } },
{ type: PARAM_KEY_STATUS, value: { data: STATUS_ONLINE, operator: '=' } },
{ type: 'filtered-search-term', value: { data: '' } },
];

View File

@ -28,8 +28,9 @@ import {
INSTANCE_TYPE,
GROUP_TYPE,
PROJECT_TYPE,
PARAM_KEY_PAUSED,
PARAM_KEY_STATUS,
STATUS_ACTIVE,
STATUS_ONLINE,
RUNNER_PAGE_SIZE,
I18N_EDIT,
} from '~/runner/constants';
@ -188,13 +189,16 @@ describe('GroupRunnersApp', () => {
const tokens = findFilteredSearch().props('tokens');
expect(tokens).toHaveLength(1);
expect(tokens[0]).toEqual(
expect(tokens).toEqual([
expect.objectContaining({
type: PARAM_KEY_PAUSED,
options: expect.any(Array),
}),
expect.objectContaining({
type: PARAM_KEY_STATUS,
options: expect.any(Array),
}),
);
]);
});
describe('Single runner row', () => {
@ -253,7 +257,7 @@ describe('GroupRunnersApp', () => {
describe('when a filter is preselected', () => {
beforeEach(async () => {
setWindowLocation(`?status[]=${STATUS_ACTIVE}&runner_type[]=${INSTANCE_TYPE}`);
setWindowLocation(`?status[]=${STATUS_ONLINE}&runner_type[]=${INSTANCE_TYPE}`);
createComponent();
await waitForPromises();
@ -262,7 +266,7 @@ describe('GroupRunnersApp', () => {
it('sets the filters in the search bar', () => {
expect(findRunnerFilteredSearchBar().props('value')).toEqual({
runnerType: INSTANCE_TYPE,
filters: [{ type: 'status', value: { data: STATUS_ACTIVE, operator: '=' } }],
filters: [{ type: 'status', value: { data: STATUS_ONLINE, operator: '=' } }],
sort: 'CREATED_DESC',
pagination: { page: 1 },
});
@ -271,7 +275,7 @@ describe('GroupRunnersApp', () => {
it('requests the runners with filter parameters', () => {
expect(mockGroupRunnersQuery).toHaveBeenLastCalledWith({
groupFullPath: mockGroupFullPath,
status: STATUS_ACTIVE,
status: STATUS_ONLINE,
type: INSTANCE_TYPE,
sort: DEFAULT_SORT,
first: RUNNER_PAGE_SIZE,
@ -283,7 +287,7 @@ describe('GroupRunnersApp', () => {
beforeEach(async () => {
findRunnerFilteredSearchBar().vm.$emit('input', {
runnerType: null,
filters: [{ type: PARAM_KEY_STATUS, value: { data: STATUS_ACTIVE, operator: '=' } }],
filters: [{ type: PARAM_KEY_STATUS, value: { data: STATUS_ONLINE, operator: '=' } }],
sort: CREATED_ASC,
});
@ -293,14 +297,14 @@ describe('GroupRunnersApp', () => {
it('updates the browser url', () => {
expect(updateHistory).toHaveBeenLastCalledWith({
title: expect.any(String),
url: 'http://test.host/groups/group1/-/runners?status[]=ACTIVE&sort=CREATED_ASC',
url: 'http://test.host/groups/group1/-/runners?status[]=ONLINE&sort=CREATED_ASC',
});
});
it('requests the runners with filters', () => {
expect(mockGroupRunnersQuery).toHaveBeenLastCalledWith({
groupFullPath: mockGroupFullPath,
status: STATUS_ACTIVE,
status: STATUS_ONLINE,
sort: CREATED_ASC,
first: RUNNER_PAGE_SIZE,
});

View File

@ -181,6 +181,28 @@ describe('search_params.js', () => {
first: RUNNER_PAGE_SIZE,
},
},
{
name: 'paused runners',
urlQuery: '?paused[]=true',
search: {
runnerType: null,
filters: [{ type: 'paused', value: { data: 'true', operator: '=' } }],
pagination: { page: 1 },
sort: 'CREATED_DESC',
},
graphqlVariables: { paused: true, sort: 'CREATED_DESC', first: RUNNER_PAGE_SIZE },
},
{
name: 'active runners',
urlQuery: '?paused[]=false',
search: {
runnerType: null,
filters: [{ type: 'paused', value: { data: 'false', operator: '=' } }],
pagination: { page: 1 },
sort: 'CREATED_DESC',
},
graphqlVariables: { paused: false, sort: 'CREATED_DESC', first: RUNNER_PAGE_SIZE },
},
];
describe('searchValidator', () => {
@ -197,14 +219,18 @@ describe('search_params.js', () => {
expect(updateOutdatedUrl('http://test.host/?a=b')).toBe(null);
});
it('returns updated url for updating NOT_CONNECTED to NEVER_CONTACTED', () => {
expect(updateOutdatedUrl('http://test.host/admin/runners?status[]=NOT_CONNECTED')).toBe(
'http://test.host/admin/runners?status[]=NEVER_CONTACTED',
);
it.each`
query | updatedQuery
${'status[]=NOT_CONNECTED'} | ${'status[]=NEVER_CONTACTED'}
${'status[]=NOT_CONNECTED&a=b'} | ${'status[]=NEVER_CONTACTED&a=b'}
${'status[]=ACTIVE'} | ${'paused[]=false'}
${'status[]=ACTIVE&a=b'} | ${'a=b&paused[]=false'}
${'status[]=ACTIVE'} | ${'paused[]=false'}
${'status[]=PAUSED'} | ${'paused[]=true'}
`('updates "$query" to "$updatedQuery"', ({ query, updatedQuery }) => {
const mockUrl = 'http://test.host/admin/runners?';
expect(updateOutdatedUrl('http://test.host/admin/runners?status[]=NOT_CONNECTED&a=b')).toBe(
'http://test.host/admin/runners?status[]=NEVER_CONTACTED&a=b',
);
expect(updateOutdatedUrl(`${mockUrl}${query}`)).toBe(`${mockUrl}${updatedQuery}`);
});
});

View File

@ -13,7 +13,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
describe '#list_issues' do
shared_examples 'issues have correct return type' do |klass|
it "returns objects of type #{klass}" do
expect(subject[:issues]).to all( be_a(klass) )
expect(subject[:issues]).to all(be_a(klass))
end
end
@ -41,10 +41,18 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
let(:cursor) { nil }
let(:sort) { 'last_seen' }
let(:sentry_api_response) { issues_sample_response }
let(:sentry_request_url) { sentry_url + '/issues/?limit=20&query=is:unresolved' }
let(:sentry_request_url) { "#{sentry_url}/issues/?limit=20&query=is:unresolved" }
let!(:sentry_api_request) { stub_sentry_request(sentry_request_url, body: sentry_api_response) }
subject { client.list_issues(issue_status: issue_status, limit: limit, search_term: search_term, sort: sort, cursor: cursor) }
subject do
client.list_issues(
issue_status: issue_status,
limit: limit,
search_term: search_term,
sort: sort,
cursor: cursor
)
end
it_behaves_like 'calls sentry api'
@ -52,7 +60,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
it_behaves_like 'issues have correct length', 3
shared_examples 'has correct external_url' do
context 'external_url' do
describe '#external_url' do
it 'is constructed correctly' do
expect(subject[:issues][0].external_url).to eq('https://sentrytest.gitlab.com/sentry-org/sentry-project/issues/11')
end
@ -62,7 +70,8 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
context 'when response has a pagination info' do
let(:headers) do
{
link: '<https://sentrytest.gitlab.com>; rel="previous"; results="true"; cursor="1573556671000:0:1", <https://sentrytest.gitlab.com>; rel="next"; results="true"; cursor="1572959139000:0:0"'
link: '<https://sentrytest.gitlab.com>; rel="previous"; results="true"; cursor="1573556671000:0:1",' \
'<https://sentrytest.gitlab.com>; rel="next"; results="true"; cursor="1572959139000:0:0"'
}
end
@ -76,7 +85,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
end
end
context 'error object created from sentry response' do
context 'when error object created from sentry response' do
using RSpec::Parameterized::TableSyntax
where(:error_object, :sentry_response) do
@ -104,13 +113,13 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
it_behaves_like 'has correct external_url'
end
context 'redirects' do
let(:sentry_api_url) { sentry_url + '/issues/?limit=20&query=is:unresolved' }
context 'with redirects' do
let(:sentry_api_url) { "#{sentry_url}/issues/?limit=20&query=is:unresolved" }
it_behaves_like 'no Sentry redirects'
end
context 'requests with sort parameter in sentry api' do
context 'with sort parameter in sentry api' do
let(:sentry_request_url) do
'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/' \
'issues/?limit=20&query=is:unresolved&sort=freq'
@ -140,7 +149,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
end
end
context 'Older sentry versions where keys are not present' do
context 'with older sentry versions where keys are not present' do
let(:sentry_api_response) do
issues_sample_response[0...1].map do |issue|
issue[:project].delete(:id)
@ -156,7 +165,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
it_behaves_like 'has correct external_url'
end
context 'essential keys missing in API response' do
context 'when essential keys are missing in API response' do
let(:sentry_api_response) do
issues_sample_response[0...1].map do |issue|
issue.except(:id)
@ -164,16 +173,18 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
end
it 'raises exception' do
expect { subject }.to raise_error(ErrorTracking::SentryClient::MissingKeysError, 'Sentry API response is missing keys. key not found: "id"')
expect { subject }.to raise_error(ErrorTracking::SentryClient::MissingKeysError,
'Sentry API response is missing keys. key not found: "id"')
end
end
context 'sentry api response too large' do
context 'when sentry api response is too large' do
it 'raises exception' do
deep_size = double('Gitlab::Utils::DeepSize', valid?: false)
deep_size = instance_double(Gitlab::Utils::DeepSize, valid?: false)
allow(Gitlab::Utils::DeepSize).to receive(:new).with(sentry_api_response).and_return(deep_size)
expect { subject }.to raise_error(ErrorTracking::SentryClient::ResponseInvalidSizeError, 'Sentry API response is too big. Limit is 1 MB.')
expect { subject }.to raise_error(ErrorTracking::SentryClient::ResponseInvalidSizeError,
'Sentry API response is too big. Limit is 1 MB.')
end
end
@ -212,7 +223,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
subject { client.issue_details(issue_id: issue_id) }
context 'error object created from sentry response' do
context 'with error object created from sentry response' do
using RSpec::Parameterized::TableSyntax
where(:error_object, :sentry_response) do
@ -298,17 +309,16 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
describe '#update_issue' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0' }
let(:sentry_request_url) { "#{sentry_url}/issues/#{issue_id}/" }
before do
stub_sentry_request(sentry_request_url, :put)
end
let(:params) do
{
status: 'resolved'
}
end
before do
stub_sentry_request(sentry_request_url, :put)
end
subject { client.update_issue(issue_id: issue_id, params: params) }
it_behaves_like 'calls sentry api' do
@ -319,7 +329,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
expect(subject).to be_truthy
end
context 'error encountered' do
context 'when error is encountered' do
let(:error) { StandardError.new('error') }
before do

View File

@ -229,6 +229,20 @@ RSpec.describe Blob do
end
end
describe '#executable?' do
it 'is true for executables' do
executable_blob = fake_blob(path: 'file', mode: '100755')
expect(executable_blob.executable?).to eq true
end
it 'is false for non-executables' do
non_executable_blob = fake_blob(path: 'file', mode: '100655')
expect(non_executable_blob.executable?).to eq false
end
end
describe '#extension' do
it 'returns the extension' do
blob = fake_blob(path: 'file.md')

View File

@ -720,7 +720,7 @@ RSpec.describe Integration do
describe '#api_field_names' do
shared_examples 'api field names' do
it 'filters out sensitive fields' do
it 'filters out secret fields' do
safe_fields = %w[some_safe_field safe_field url trojan_gift]
expect(fake_integration.new).to have_attributes(
@ -857,7 +857,7 @@ RSpec.describe Integration do
end
end
describe '#password_fields' do
describe '#secret_fields' do
it 'returns all fields with type `password`' do
allow(subject).to receive(:fields).and_return([
{ name: 'password', type: 'password' },
@ -865,11 +865,11 @@ RSpec.describe Integration do
{ name: 'public', type: 'text' }
])
expect(subject.password_fields).to match_array(%w[password secret])
expect(subject.secret_fields).to match_array(%w[password secret])
end
it 'returns an empty array if no password fields exist' do
expect(subject.password_fields).to eq([])
it 'returns an empty array if no secret fields exist' do
expect(subject.secret_fields).to eq([])
end
end

View File

@ -84,17 +84,17 @@ RSpec.describe ::Integrations::Field do
end
end
describe '#sensitive' do
describe '#secret?' do
context 'when empty' do
it { is_expected.not_to be_sensitive }
it { is_expected.not_to be_secret }
end
context 'when a password field' do
context 'when a secret field' do
before do
attrs[:type] = 'password'
end
it { is_expected.to be_sensitive }
it { is_expected.to be_secret }
end
%w[token api_token api_key secret_key secret_sauce password passphrase].each do |name|
@ -103,7 +103,7 @@ RSpec.describe ::Integrations::Field do
attrs[:name] = name
end
it { is_expected.to be_sensitive }
it { is_expected.to be_secret }
end
end
@ -112,7 +112,7 @@ RSpec.describe ::Integrations::Field do
attrs[:name] = :url
end
it { is_expected.not_to be_sensitive }
it { is_expected.not_to be_secret }
end
end
end

View File

@ -9,6 +9,7 @@ RSpec.describe API::Files do
let!(:project) { create(:project, :repository, namespace: user.namespace ) }
let(:guest) { create(:user) { |u| project.add_guest(u) } }
let(:file_path) { "files%2Fruby%2Fpopen%2Erb" }
let(:executable_file_path) { "files%2Fexecutables%2Fls" }
let(:rouge_file_path) { "%2e%2e%2f" }
let(:absolute_path) { "%2Fetc%2Fpasswd.rb" }
let(:invalid_file_message) { 'file_path should be a valid file path' }
@ -18,6 +19,12 @@ RSpec.describe API::Files do
}
end
let(:executable_ref_params) do
{
ref: 'with-executables'
}
end
let(:author_email) { 'user@example.org' }
let(:author_name) { 'John Doe' }
@ -219,9 +226,26 @@ RSpec.describe API::Files do
expect(json_response['file_name']).to eq('popen.rb')
expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
expect(json_response['content_sha256']).to eq('c440cd09bae50c4632cc58638ad33c6aa375b6109d811e76a9cc3a613c1e8887')
expect(json_response['execute_filemode']).to eq(false)
expect(Base64.decode64(json_response['content']).lines.first).to eq("require 'fileutils'\n")
end
context 'for executable file' do
it 'returns file attributes as json' do
get api(route(executable_file_path), api_user, **options), params: executable_ref_params
aggregate_failures 'testing response' do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['file_path']).to eq(CGI.unescape(executable_file_path))
expect(json_response['file_name']).to eq('ls')
expect(json_response['last_commit_id']).to eq('6b8dc4a827797aa025ff6b8f425e583858a10d4f')
expect(json_response['content_sha256']).to eq('2c74b1181ef780dfb692c030d3a0df6e0b624135c38a9344e56b9f80007b6191')
expect(json_response['execute_filemode']).to eq(true)
expect(Base64.decode64(json_response['content']).lines.first).to eq("#!/bin/sh\n")
end
end
end
it 'returns json when file has txt extension' do
file_path = "bar%2Fbranch-test.txt"
@ -386,6 +410,23 @@ RSpec.describe API::Files do
expect(response.headers['X-Gitlab-Last-Commit-Id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
expect(response.headers['X-Gitlab-Content-Sha256'])
.to eq('c440cd09bae50c4632cc58638ad33c6aa375b6109d811e76a9cc3a613c1e8887')
expect(response.headers['X-Gitlab-Execute-Filemode']).to eq("false")
end
context 'for executable file' do
it 'returns file attributes in headers' do
head api(route(executable_file_path) + '/blame', current_user), params: executable_ref_params
aggregate_failures 'testing response' do
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Gitlab-File-Path']).to eq(CGI.unescape(executable_file_path))
expect(response.headers['X-Gitlab-File-Name']).to eq('ls')
expect(response.headers['X-Gitlab-Last-Commit-Id']).to eq('6b8dc4a827797aa025ff6b8f425e583858a10d4f')
expect(response.headers['X-Gitlab-Content-Sha256'])
.to eq('2c74b1181ef780dfb692c030d3a0df6e0b624135c38a9344e56b9f80007b6191')
expect(response.headers['X-Gitlab-Execute-Filemode']).to eq("true")
end
end
end
it 'returns 400 when file path is invalid' do
@ -642,6 +683,15 @@ RSpec.describe API::Files do
}
end
let(:executable_params) do
{
branch: "master",
content: "puts 8",
commit_message: "Added newfile",
execute_filemode: true
}
end
it 'returns 400 when file path is invalid' do
post api(route(rouge_file_path), user), params: params
@ -661,6 +711,18 @@ RSpec.describe API::Files do
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(user.email)
expect(last_commit.author_name).to eq(user.name)
expect(project.repository.blob_at_branch(params[:branch], CGI.unescape(file_path)).executable?).to eq(false)
end
it "creates a new executable file in project repo" do
post api(route(file_path), user), params: executable_params
expect(response).to have_gitlab_http_status(:created)
expect(json_response["file_path"]).to eq(CGI.unescape(file_path))
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(user.email)
expect(last_commit.author_name).to eq(user.name)
expect(project.repository.blob_at_branch(params[:branch], CGI.unescape(file_path)).executable?).to eq(true)
end
it "returns a 400 bad request if no mandatory params given" do
@ -820,6 +882,44 @@ RSpec.describe API::Files do
expect(last_commit.author_name).to eq(author_name)
end
end
context 'when specifying the execute_filemode' do
let(:executable_params) do
{
branch: 'master',
content: 'puts 8',
commit_message: 'Changed file',
execute_filemode: true
}
end
let(:non_executable_params) do
{
branch: 'with-executables',
content: 'puts 8',
commit_message: 'Changed file',
execute_filemode: false
}
end
it 'updates to executable file mode' do
put api(route(file_path), user), params: executable_params
aggregate_failures 'testing response' do
expect(response).to have_gitlab_http_status(:ok)
expect(project.repository.blob_at_branch(executable_params[:branch], CGI.unescape(file_path)).executable?).to eq(true)
end
end
it 'updates to non-executable file mode' do
put api(route(executable_file_path), user), params: non_executable_params
aggregate_failures 'testing response' do
expect(response).to have_gitlab_http_status(:ok)
expect(project.repository.blob_at_branch(non_executable_params[:branch], CGI.unescape(executable_file_path)).executable?).to eq(false)
end
end
end
end
describe "DELETE /projects/:id/repository/files" do

View File

@ -378,15 +378,15 @@ RSpec.describe API::Integrations do
def assert_correct_response_fields(response_keys, integration)
assert_fields_match_integration(response_keys, integration)
assert_password_fields_filtered(response_keys, integration)
assert_secret_fields_filtered(response_keys, integration)
end
def assert_fields_match_integration(response_keys, integration)
expect(response_keys).to match_array(integration.api_field_names)
end
def assert_password_fields_filtered(response_keys, integration)
expect(response_keys).not_to include(*integration.password_fields)
def assert_secret_fields_filtered(response_keys, integration)
expect(response_keys).not_to include(*integration.secret_fields)
end
end
end

View File

@ -81,7 +81,8 @@ module TestEnv
'compare-with-merge-head-target' => '2f1e176',
'trailers' => 'f0a5ed6',
'add_commit_with_5mb_subject' => '8cf8e80',
'blame-on-renamed' => '32c33da'
'blame-on-renamed' => '32c33da',
'with-executables' => '6b8dc4a'
}.freeze
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily