Commit c5f02e00 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 4094dc97d61d
...@@ -547,3 +547,13 @@ export const calculateRemainingMilliseconds = endDate => { ...@@ -547,3 +547,13 @@ export const calculateRemainingMilliseconds = endDate => {
const remainingMilliseconds = new Date(endDate).getTime() - Date.now(); const remainingMilliseconds = new Date(endDate).getTime() - Date.now();
return Math.max(remainingMilliseconds, 0); return Math.max(remainingMilliseconds, 0);
}; };
/**
* Subtracts a given number of days from a given date and returns the new date.
*
* @param {Date} date the date that we will substract days from
* @param {number} daysInPast number of days that are subtracted from a given date
* @returns {String} Date string in ISO format
*/
export const getDateInPast = (date, daysInPast) =>
new Date(date.setTime(date.getTime() - daysInPast * 24 * 60 * 60 * 1000)).toISOString();
...@@ -106,3 +106,14 @@ export const sum = (a = 0, b = 0) => a + b; ...@@ -106,3 +106,14 @@ export const sum = (a = 0, b = 0) => a + b;
* @param {Int} number * @param {Int} number
*/ */
export const isOdd = (number = 0) => number % 2; export const isOdd = (number = 0) => number % 2;
/**
* Computes the median for a given array.
* @param {Array} arr An array of numbers
* @returns {Number} The median of the given array
*/
export const median = arr => {
const middle = Math.floor(arr.length / 2);
const sorted = arr.sort((a, b) => a - b);
return arr.length % 2 !== 0 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
};
...@@ -120,6 +120,13 @@ def clean_path(path) ...@@ -120,6 +120,13 @@ def clean_path(path)
uniquify = Uniquify.new uniquify = Uniquify.new
uniquify.string(path) { |s| Namespace.find_by_path_or_name(s) } uniquify.string(path) { |s| Namespace.find_by_path_or_name(s) }
end end
def find_by_pages_host(host)
gitlab_host = "." + Settings.pages.host.downcase
name = host.downcase.delete_suffix(gitlab_host)
Namespace.find_by_full_path(name)
end
end end
def visibility_level_field def visibility_level_field
...@@ -305,8 +312,16 @@ def aggregation_scheduled? ...@@ -305,8 +312,16 @@ def aggregation_scheduled?
aggregation_schedule.present? aggregation_schedule.present?
end end
def pages_virtual_domain
Pages::VirtualDomain.new(all_projects_with_pages, trim_prefix: full_path)
end
private private
def all_projects_with_pages
all_projects.with_pages_deployed
end
def parent_changed? def parent_changed?
parent_id_changed? parent_id_changed?
end end
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
module Pages module Pages
class LookupPath class LookupPath
def initialize(project, domain: nil) def initialize(project, trim_prefix: nil, domain: nil)
@project = project @project = project
@domain = domain @domain = domain
@trim_prefix = trim_prefix || project.full_path
end end
def project_id def project_id
...@@ -28,11 +29,15 @@ def source ...@@ -28,11 +29,15 @@ def source
end end
def prefix def prefix
'/' if project.pages_group_root?
'/'
else
project.full_path.delete_prefix(trim_prefix) + '/'
end
end end
private private
attr_reader :project, :domain attr_reader :project, :trim_prefix, :domain
end end
end end
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
module Pages module Pages
class VirtualDomain class VirtualDomain
def initialize(projects, domain: nil) def initialize(projects, trim_prefix: nil, domain: nil)
@projects = projects @projects = projects
@trim_prefix = trim_prefix
@domain = domain @domain = domain
end end
...@@ -17,12 +18,12 @@ def key ...@@ -17,12 +18,12 @@ def key
def lookup_paths def lookup_paths
projects.map do |project| projects.map do |project|
project.pages_lookup_path(domain: domain) project.pages_lookup_path(trim_prefix: trim_prefix, domain: domain)
end.sort_by(&:prefix).reverse end.sort_by(&:prefix).reverse
end end
private private
attr_reader :projects, :domain attr_reader :projects, :trim_prefix, :domain
end end
end end
...@@ -186,11 +186,17 @@ def gitlab_provided_key=(key) ...@@ -186,11 +186,17 @@ def gitlab_provided_key=(key)
end end
def pages_virtual_domain def pages_virtual_domain
return unless pages_deployed?
Pages::VirtualDomain.new([project], domain: self) Pages::VirtualDomain.new([project], domain: self)
end end
private private
def pages_deployed?
project.pages_metadatum&.deployed?
end
def set_verification_code def set_verification_code
return if self.verification_code.present? return if self.verification_code.present?
......
...@@ -104,6 +104,9 @@ class Project < ApplicationRecord ...@@ -104,6 +104,9 @@ class Project < ApplicationRecord
unless: :ci_cd_settings, unless: :ci_cd_settings,
if: proc { ProjectCiCdSetting.available? } if: proc { ProjectCiCdSetting.available? }
after_create :create_pages_metadatum,
unless: :pages_metadatum
after_create :set_timestamps_for_create after_create :set_timestamps_for_create
after_update :update_forks_visibility_level after_update :update_forks_visibility_level
...@@ -295,6 +298,8 @@ class Project < ApplicationRecord ...@@ -295,6 +298,8 @@ class Project < ApplicationRecord
has_many :external_pull_requests, inverse_of: :project has_many :external_pull_requests, inverse_of: :project
has_one :pages_metadatum, class_name: 'ProjectPagesMetadatum', inverse_of: :project
accepts_nested_attributes_for :variables, allow_destroy: true accepts_nested_attributes_for :variables, allow_destroy: true
accepts_nested_attributes_for :project_feature, update_only: true accepts_nested_attributes_for :project_feature, update_only: true
accepts_nested_attributes_for :import_data accepts_nested_attributes_for :import_data
...@@ -425,6 +430,10 @@ class Project < ApplicationRecord ...@@ -425,6 +430,10 @@ class Project < ApplicationRecord
.where(project_ci_cd_settings: { group_runners_enabled: true }) .where(project_ci_cd_settings: { group_runners_enabled: true })
end end
scope :with_pages_deployed, -> do
joins(:pages_metadatum).merge(ProjectPagesMetadatum.deployed)
end
enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 } enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 }
chronic_duration_attr :build_timeout_human_readable, :build_timeout, chronic_duration_attr :build_timeout_human_readable, :build_timeout,
...@@ -1643,6 +1652,10 @@ def pages_url ...@@ -1643,6 +1652,10 @@ def pages_url
"#{url}/#{url_path}" "#{url}/#{url_path}"
end end
def pages_group_root?
pages_group_url == pages_url
end
def pages_subdomain def pages_subdomain
full_path.partition('/').first full_path.partition('/').first
end end
...@@ -1681,6 +1694,7 @@ def remove_pages ...@@ -1681,6 +1694,7 @@ def remove_pages
# Projects with a missing namespace cannot have their pages removed # Projects with a missing namespace cannot have their pages removed
return unless namespace return unless namespace
mark_pages_as_not_deployed unless destroyed?
::Projects::UpdatePagesConfigurationService.new(self).execute ::Projects::UpdatePagesConfigurationService.new(self).execute
# 1. We rename pages to temporary directory # 1. We rename pages to temporary directory
...@@ -1694,6 +1708,14 @@ def remove_pages ...@@ -1694,6 +1708,14 @@ def remove_pages
end end
# rubocop: enable CodeReuse/ServiceClass # rubocop: enable CodeReuse/ServiceClass
def mark_pages_as_deployed
ensure_pages_metadatum.update!(deployed: true)
end
def mark_pages_as_not_deployed
ensure_pages_metadatum.update!(deployed: false)
end
# rubocop:disable Gitlab/RailsLogger # rubocop:disable Gitlab/RailsLogger
def write_repository_config(gl_full_path: full_path) def write_repository_config(gl_full_path: full_path)
# We'd need to keep track of project full path otherwise directory tree # We'd need to keep track of project full path otherwise directory tree
...@@ -2213,8 +2235,8 @@ def access_request_approvers_to_be_notified ...@@ -2213,8 +2235,8 @@ def access_request_approvers_to_be_notified
members.maintainers.order_recent_sign_in.limit(ACCESS_REQUEST_APPROVERS_TO_BE_NOTIFIED_LIMIT) members.maintainers.order_recent_sign_in.limit(ACCESS_REQUEST_APPROVERS_TO_BE_NOTIFIED_LIMIT)
end end
def pages_lookup_path(domain: nil) def pages_lookup_path(trim_prefix: nil, domain: nil)
Pages::LookupPath.new(self, domain: domain) Pages::LookupPath.new(self, trim_prefix: trim_prefix, domain: domain)
end end
private private
...@@ -2342,6 +2364,13 @@ def fetch_branch_allows_collaboration(user, branch_name = nil) ...@@ -2342,6 +2364,13 @@ def fetch_branch_allows_collaboration(user, branch_name = nil)
def services_templates def services_templates
@services_templates ||= Service.where(template: true) @services_templates ||= Service.where(template: true)
end end
def ensure_pages_metadatum
pages_metadatum || create_pages_metadatum!
rescue ActiveRecord::RecordNotUnique
reset
retry
end
end end
Project.prepend_if_ee('EE::Project') Project.prepend_if_ee('EE::Project')
# frozen_string_literal: true
class ProjectPagesMetadatum < ApplicationRecord
self.primary_key = :project_id
belongs_to :project, inverse_of: :pages_metadatum
scope :deployed, -> { where(deployed: true) }
end
...@@ -53,6 +53,7 @@ def execute ...@@ -53,6 +53,7 @@ def execute
def success def success
@status.success @status.success
@project.mark_pages_as_deployed
super super
end end
......
---
title: Add project_pages_metadata DB table
merge_request: 17197
author:
type: added
# frozen_string_literal: true
class CreateProjectPagesMetadata < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :project_pages_metadata, id: false do |t|
t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
t.boolean :deployed, null: false, default: false
t.index :project_id, name: 'index_project_pages_metadata_on_project_id_and_deployed_is_true', where: "deployed = TRUE"
end
end
end
...@@ -2774,6 +2774,13 @@ ...@@ -2774,6 +2774,13 @@
t.index ["status"], name: "index_project_mirror_data_on_status" t.index ["status"], name: "index_project_mirror_data_on_status"
end end
create_table "project_pages_metadata", id: false, force: :cascade do |t|
t.bigint "project_id", null: false
t.boolean "deployed", default: false, null: false
t.index ["project_id"], name: "index_project_pages_metadata_on_project_id", unique: true
t.index ["project_id"], name: "index_project_pages_metadata_on_project_id_and_deployed_is_true", where: "(deployed = true)"
end
create_table "project_repositories", force: :cascade do |t| create_table "project_repositories", force: :cascade do |t|
t.integer "shard_id", null: false t.integer "shard_id", null: false
t.string "disk_path", null: false t.string "disk_path", null: false
...@@ -4084,6 +4091,7 @@ ...@@ -4084,6 +4091,7 @@
add_foreign_key "project_incident_management_settings", "projects", on_delete: :cascade add_foreign_key "project_incident_management_settings", "projects", on_delete: :cascade
add_foreign_key "project_metrics_settings", "projects", on_delete: :cascade add_foreign_key "project_metrics_settings", "projects", on_delete: :cascade
add_foreign_key "project_mirror_data", "projects", name: "fk_d1aad367d7", on_delete: :cascade add_foreign_key "project_mirror_data", "projects", name: "fk_d1aad367d7", on_delete: :cascade
add_foreign_key "project_pages_metadata", "projects", on_delete: :cascade
add_foreign_key "project_repositories", "projects", on_delete: :cascade add_foreign_key "project_repositories", "projects", on_delete: :cascade
add_foreign_key "project_repositories", "shards", on_delete: :restrict add_foreign_key "project_repositories", "shards", on_delete: :restrict
add_foreign_key "project_repository_states", "projects", on_delete: :cascade add_foreign_key "project_repository_states", "projects", on_delete: :cascade
......
...@@ -32,9 +32,9 @@ For example, [Active Directory](https://technet.microsoft.com/en-us/library/hh83 ...@@ -32,9 +32,9 @@ For example, [Active Directory](https://technet.microsoft.com/en-us/library/hh83
We won't cover the installation and configuration of Windows Server or Active Directory Domain Services in this tutorial. There are a number of resources online to guide you through this process: We won't cover the installation and configuration of Windows Server or Active Directory Domain Services in this tutorial. There are a number of resources online to guide you through this process:
- Install Windows Server 2012 - (_technet.microsoft.com_) - [Installing Windows Server 2012](https://technet.microsoft.com/en-us/library/jj134246(v=ws.11).aspx) - Install Windows Server 2012 - (`technet.microsoft.com`) - [Installing Windows Server 2012](https://technet.microsoft.com/en-us/library/jj134246(v=ws.11).aspx)
- Install Active Directory Domain Services (AD DS) (_technet.microsoft.com_)- [Install Active Directory Domain Services](https://technet.microsoft.com/windows-server-docs/identity/ad-ds/deploy/install-active-directory-domain-services--level-100-#BKMK_PS) - Install Active Directory Domain Services (AD DS) (`technet.microsoft.com`)- [Install Active Directory Domain Services](https://technet.microsoft.com/windows-server-docs/identity/ad-ds/deploy/install-active-directory-domain-services--level-100-#BKMK_PS)
> **Shortcut:** You can quickly install AD DS via PowerShell using > **Shortcut:** You can quickly install AD DS via PowerShell using
`Install-WindowsFeature AD-Domain-Services -IncludeManagementTools` `Install-WindowsFeature AD-Domain-Services -IncludeManagementTools`
......
...@@ -413,7 +413,7 @@ nested members in the user filter should not be confused with ...@@ -413,7 +413,7 @@ nested members in the user filter should not be confused with
[group sync nested groups support](ldap-ee.md#supported-ldap-group-typesattributes). **(STARTER ONLY)** [group sync nested groups support](ldap-ee.md#supported-ldap-group-typesattributes). **(STARTER ONLY)**
Please note that GitLab does not support the custom filter syntax used by Please note that GitLab does not support the custom filter syntax used by
omniauth-ldap. OmniAuth LDAP.
### Escaping special characters ### Escaping special characters
...@@ -536,7 +536,7 @@ ldapsearch -H ldaps://$host:$port -D "$bind_dn" -y bind_dn_password.txt -b "$ba ...@@ -536,7 +536,7 @@ ldapsearch -H ldaps://$host:$port -D "$bind_dn" -y bind_dn_password.txt -b "$ba
- Variables beginning with a `$` refer to a variable from the LDAP section of - Variables beginning with a `$` refer to a variable from the LDAP section of
your configuration file. your configuration file.
- Replace ldaps:// with ldap:// if you are using the plain authentication method. - Replace `ldaps://` with `ldap://` if you are using the plain authentication method.
Port `389` is the default `ldap://` port and `636` is the default `ldaps://` Port `389` is the default `ldap://` port and `636` is the default `ldaps://`
port. port.
- We are assuming the password for the bind_dn user is in bind_dn_password.txt. - We are assuming the password for the bind_dn user is in bind_dn_password.txt.
......
...@@ -206,7 +206,7 @@ attribute. As a prerequisite, you must use an LDAP server that: ...@@ -206,7 +206,7 @@ attribute. As a prerequisite, you must use an LDAP server that:
**For installations from source** **For installations from source**
1. Add the `san_extensions` line to config/gitlab.yml` within the smartcard section: 1. Add the `san_extensions` line to `config/gitlab.yml` within the smartcard section:
```yaml ```yaml
smartcard: smartcard:
......
...@@ -96,7 +96,7 @@ The connection settings match those provided by [Fog](https://github.com/fog), a ...@@ -96,7 +96,7 @@ The connection settings match those provided by [Fog](https://github.com/fog), a
| `enable_signature_v4_streaming` | Set to true to enable HTTP chunked transfers with [AWS v4 signatures](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html). Oracle Cloud S3 needs this to be false | true | | `enable_signature_v4_streaming` | Set to true to enable HTTP chunked transfers with [AWS v4 signatures](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html). Oracle Cloud S3 needs this to be false | true |
| `region` | AWS region | us-east-1 | | `region` | AWS region | us-east-1 |
| `host` | S3 compatible host for when not using AWS, e.g. `localhost` or `storage.example.com` | s3.amazonaws.com | | `host` | S3 compatible host for when not using AWS, e.g. `localhost` or `storage.example.com` | s3.amazonaws.com |
| `endpoint` | Can be used when configuring an S3 compatible service such as [Minio](https://www.minio.io), by entering a URL such as `http://127.0.0.1:9000` | (optional) | | `endpoint` | Can be used when configuring an S3 compatible service such as [MinIO](https://www.minio.io), by entering a URL such as `http://127.0.0.1:9000` | (optional) |
| `path_style` | Set to true to use `host/bucket_name/object` style paths instead of `bucket_name.host/object`. Leave as false for AWS S3 | false | | `path_style` | Set to true to use `host/bucket_name/object` style paths instead of `bucket_name.host/object`. Leave as false for AWS S3 | false |
| `use_iam_profile` | Set to true to use IAM profile instead of access keys | false | `use_iam_profile` | Set to true to use IAM profile instead of access keys | false
......
...@@ -81,7 +81,7 @@ The connection settings match those provided by [Fog](https://github.com/fog), a ...@@ -81,7 +81,7 @@ The connection settings match those provided by [Fog](https://github.com/fog), a
| `enable_signature_v4_streaming` | Set to true to enable HTTP chunked transfers with [AWS v4 signatures](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html). Oracle Cloud S3 needs this to be false | true | | `enable_signature_v4_streaming` | Set to true to enable HTTP chunked transfers with [AWS v4 signatures](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html). Oracle Cloud S3 needs this to be false | true |
| `region` | AWS region | us-east-1 | | `region` | AWS region | us-east-1 |
| `host` | S3 compatible host for when not using AWS, e.g. `localhost` or `storage.example.com` | s3.amazonaws.com | | `host` | S3 compatible host for when not using AWS, e.g. `localhost` or `storage.example.com` | s3.amazonaws.com |
| `endpoint` | Can be used when configuring an S3 compatible service such as [Minio](https://www.minio.io), by entering a URL such as `http://127.0.0.1:9000` | (optional) | | `endpoint` | Can be used when configuring an S3 compatible service such as [MinIO](https://www.minio.io), by entering a URL such as `http://127.0.0.1:9000` | (optional) |
| `path_style` | Set to true to use `host/bucket_name/object` style paths instead of `bucket_name.host/object`. Leave as false for AWS S3 | false | | `path_style` | Set to true to use `host/bucket_name/object` style paths instead of `bucket_name.host/object`. Leave as false for AWS S3 | false |
| `use_iam_profile` | Set to true to use IAM profile instead of access keys | false | `use_iam_profile` | Set to true to use IAM profile instead of access keys | false
...@@ -165,7 +165,7 @@ The connection settings match those provided by [Fog](https://github.com/fog), a ...@@ -165,7 +165,7 @@ The connection settings match those provided by [Fog](https://github.com/fog), a
|---------|-------------|---------| |---------|-------------|---------|
| `provider` | Always `OpenStack` for compatible hosts | OpenStack | | `provider` | Always `OpenStack` for compatible hosts | OpenStack |
| `openstack_username` | OpenStack username | | | `openstack_username` | OpenStack username | |
| `openstack_api_key` | OpenStack api key | | | `openstack_api_key` | OpenStack API key | |
| `openstack_temp_url_key` | OpenStack key for generating temporary urls | | | `openstack_temp_url_key` | OpenStack key for generating temporary urls | |
| `openstack_auth_url` | OpenStack authentication endpont | | | `openstack_auth_url` | OpenStack authentication endpont | |
| `openstack_region` | OpenStack region | | | `openstack_region` | OpenStack region | |
......
...@@ -14,7 +14,7 @@ Note that color settings will only be applied within the app interface and not t ...@@ -14,7 +14,7 @@ Note that color settings will only be applied within the app interface and not t
![appearance](system_header_and_footer_messages/appearance.png) ![appearance](system_header_and_footer_messages/appearance.png)
After saving, all GitLab pages will contain the custom system header and/or footer messages: After saving, all pages within GitLab will contain the custom system header and/or footer messages:
![custom_header_footer](system_header_and_footer_messages/custom_header_footer.png) ![custom_header_footer](system_header_and_footer_messages/custom_header_footer.png)
......
...@@ -27,7 +27,7 @@ The Admin Area is made up of the following sections: ...@@ -27,7 +27,7 @@ The Admin Area is made up of the following sections:
| Applications | Create system [OAuth applications](../../integration/oauth_provider.md) for integrations with other services. | | Applications | Create system [OAuth applications](../../integration/oauth_provider.md) for integrations with other services. |
| Abuse Reports | Manage [abuse reports](abuse_reports.md) submitted by your users. | | Abuse Reports | Manage [abuse reports](abuse_reports.md) submitted by your users. |
| License **(STARTER ONLY)** | Upload, display, and remove [licenses](license.md). | | License **(STARTER ONLY)** | Upload, display, and remove [licenses](license.md). |
| Push Rules **(STARTER)** | Configure pre-defined git [push rules](../../push_rules/push_rules.md) for projects. | | Push Rules **(STARTER)** | Configure pre-defined Git [push rules](../../push_rules/push_rules.md) for projects. |
| Geo **(PREMIUM ONLY)** | Configure and maintain [Geo nodes](geo_nodes.md). | | Geo **(PREMIUM ONLY)** | Configure and maintain [Geo nodes](geo_nodes.md). |
| Deploy Keys | Create instance-wide [SSH deploy keys](../../ssh/README.md#deploy-keys). | | Deploy Keys | Create instance-wide [SSH deploy keys](../../ssh/README.md#deploy-keys). |
| Service Templates | Create [service templates](../project/integrations/services_templates.md) for projects. | | Service Templates | Create [service templates](../project/integrations/services_templates.md) for projects. |
......
...@@ -59,7 +59,7 @@ GitLab OK ...@@ -59,7 +59,7 @@ GitLab OK
## Readiness ## Readiness
The readiness probe checks whether the Gitlab instance is ready to use. It checks the dependent services (Database, Redis, Gitaly etc.) and gives a status for each. The readiness probe checks whether the GitLab instance is ready to use. It checks the dependent services (Database, Redis, Gitaly etc.) and gives a status for each.
```text ```text
GET /-/readiness GET /-/readiness
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment