diff options
33 files changed, 193 insertions, 81 deletions
diff --git a/app/finders/deployments_finder.rb b/app/finders/deployments_finder.rb new file mode 100644 index 00000000000..085c6a04fa6 --- /dev/null +++ b/app/finders/deployments_finder.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +class DeploymentsFinder + attr_reader :project, :params + + ALLOWED_SORT_VALUES = %w[id iid created_at updated_at ref].freeze + DEFAULT_SORT_VALUE = 'id'.freeze + + ALLOWED_SORT_DIRECTIONS = %w[asc desc].freeze + DEFAULT_SORT_DIRECTION = 'asc'.freeze + + def initialize(project, params = {}) + @project = project + @params = params + end + + def execute + items = init_collection + items = by_updated_at(items) + sort(items) + end + + private + + def init_collection + project.deployments + end + + # rubocop: disable CodeReuse/ActiveRecord + def sort(items) + items.order(sort_params) + end + # rubocop: enable CodeReuse/ActiveRecord + + def by_updated_at(items) + items = items.updated_before(params[:updated_before]) if params[:updated_before].present? + items = items.updated_after(params[:updated_after]) if params[:updated_after].present? + + items + end + + def sort_params + order_by = ALLOWED_SORT_VALUES.include?(params[:order_by]) ? params[:order_by] : DEFAULT_SORT_VALUE + order_direction = ALLOWED_SORT_DIRECTIONS.include?(params[:sort]) ? params[:sort] : DEFAULT_SORT_DIRECTION + + { order_by => order_direction } + end +end diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 4a38912db9b..8ef49fc56c6 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -4,6 +4,7 @@ class Deployment < ApplicationRecord include AtomicInternalId include IidRoutes include AfterCommitQueue + include UpdatedAtFilterable belongs_to :project, required: true belongs_to :environment, required: true diff --git a/doc/administration/gitaly/praefect.md b/doc/administration/gitaly/praefect.md index 1c01f3cebd5..b510314abfb 100644 --- a/doc/administration/gitaly/praefect.md +++ b/doc/administration/gitaly/praefect.md @@ -181,7 +181,7 @@ git_data_dirs({ }) ``` -For more information on Gitaly server configuration, see our [gitaly documentation](index.md#3-gitaly-server-configuration). +For more information on Gitaly server configuration, see our [Gitaly documentation](index.md#3-gitaly-server-configuration). #### GitLab diff --git a/doc/administration/gitaly/reference.md b/doc/administration/gitaly/reference.md index fe88ef13958..2c5e54743c3 100644 --- a/doc/administration/gitaly/reference.md +++ b/doc/administration/gitaly/reference.md @@ -134,7 +134,7 @@ A lot of Gitaly RPCs need to look up Git objects from repositories. Most of the time we use `git cat-file --batch` processes for that. For better performance, Gitaly can re-use these `git cat-file` processes across RPC calls. Previously used processes are kept around in a -["git cat-file cache"](https://about.gitlab.com/blog/2019/07/08/git-performance-on-nfs/#enter-cat-file-cache). +["Git cat-file cache"](https://about.gitlab.com/blog/2019/07/08/git-performance-on-nfs/#enter-cat-file-cache). In order to control how much system resources this uses, we have a maximum number of cat-file processes that can go into the cache. @@ -165,11 +165,11 @@ Gitaly restarts its `gitaly-ruby` helpers when their memory exceeds the | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| `dir` | string | yes | Path to where gitaly-ruby is installed (needed to boot the process).| -| `max_rss` | integer | no | Resident set size limit that triggers a gitaly-ruby restart, in bytes. Default is `200000000` (200MB). | -| `graceful_restart_timeout` | string | no | Grace period before a gitaly-ruby process is forcibly terminated after exceeding `max_rss`. Default is `10m` (10 minutes).| -| `restart_delay` | string | no |Time that gitaly-ruby memory must remain high before a restart. Default is `5m` (5 minutes).| -| `num_workers` | integer | no |Number of gitaly-ruby worker processes. Try increasing this number in case of `ResourceExhausted` errors. Default is `2`, minimum is `2`.| +| `dir` | string | yes | Path to where `gitaly-ruby` is installed (needed to boot the process).| +| `max_rss` | integer | no | Resident set size limit that triggers a `gitaly-ruby` restart, in bytes. Default is `200000000` (200MB). | +| `graceful_restart_timeout` | string | no | Grace period before a `gitaly-ruby` process is forcibly terminated after exceeding `max_rss`. Default is `10m` (10 minutes).| +| `restart_delay` | string | no |Time that `gitaly-ruby` memory must remain high before a restart. Default is `5m` (5 minutes).| +| `num_workers` | integer | no |Number of `gitaly-ruby` worker processes. Try increasing this number in case of `ResourceExhausted` errors. Default is `2`, minimum is `2`.| | `linguist_languages_path` | string | no | Override for dynamic `languages.json` discovery. Defaults to an empty string (use of dynamic discovery).| Example: @@ -231,11 +231,11 @@ The following values configure logging in Gitaly under the `[logging]` section. | `level` | string | no | Log level: `debug`, `info`, `warn`, `error`, `fatal`, or `panic`. Default: `info`. | | `sentry_dsn` | string | no | Sentry DSN for exception monitoring. | | `sentry_environment` | string | no | [Sentry Environment](https://docs.sentry.io/enriching-error-data/environments/) for exception monitoring. | -| `ruby_sentry_dsn` | string | no | Sentry DSN for gitaly-ruby exception monitoring. | +| `ruby_sentry_dsn` | string | no | Sentry DSN for `gitaly-ruby` exception monitoring. | While the main Gitaly application logs go to stdout, there are some extra log files that go to a configured directory, like the GitLab Shell logs. -Gitlab Shell does not support `panic` or `trace` level logs. `panic` will fall +GitLab Shell does not support `panic` or `trace` level logs. `panic` will fall back to `error`, while `trace` will fall back to `debug`. Any other invalid log levels will default to `info`. diff --git a/doc/administration/high_availability/README.md b/doc/administration/high_availability/README.md index 75874b9b3a9..9066266c832 100644 --- a/doc/administration/high_availability/README.md +++ b/doc/administration/high_availability/README.md @@ -84,7 +84,7 @@ you can continue with the next step. 1. [Load Balancer(s)](load_balancer.md)[^2] 1. [Consul](consul.md) -1. [PostgreSQL](database.md#postgresql-in-a-scaled-environment) with [PGBouncer](https://docs.gitlab.com/ee/administration/high_availability/pgbouncer.html) +1. [PostgreSQL](database.md#postgresql-in-a-scaled-environment) with [PgBouncer](https://docs.gitlab.com/ee/administration/high_availability/pgbouncer.html) 1. [Redis](redis.md#redis-in-a-scaled-environment) 1. [Gitaly](gitaly.md) (recommended) and / or [NFS](nfs.md)[^4] 1. [GitLab application nodes](gitlab.md) diff --git a/doc/administration/index.md b/doc/administration/index.md index bf21347fb99..3d70083892f 100644 --- a/doc/administration/index.md +++ b/doc/administration/index.md @@ -80,7 +80,7 @@ Learn how to install, configure, update, and maintain your GitLab instance. - [Backup and restore](../raketasks/backup_restore.md): Backup and restore your GitLab instance. - [Operations](operations/index.md): Keeping GitLab up and running (clean up Redis sessions, moving repositories, Sidekiq MemoryKiller, Unicorn). - [Restart GitLab](restart_gitlab.md): Learn how to restart GitLab and its components. -- [Invalidate markdown cache](invalidate_markdown_cache.md): Invalidate any cached markdown. +- [Invalidate Markdown cache](invalidate_markdown_cache.md): Invalidate any cached Markdown. #### Updating GitLab diff --git a/doc/administration/invalidate_markdown_cache.md b/doc/administration/invalidate_markdown_cache.md index ad64cb077c1..ebd8578e410 100644 --- a/doc/administration/invalidate_markdown_cache.md +++ b/doc/administration/invalidate_markdown_cache.md @@ -1,6 +1,6 @@ # Invalidate Markdown Cache -For performance reasons, GitLab caches the HTML version of markdown text +For performance reasons, GitLab caches the HTML version of Markdown text (e.g. issue and merge request descriptions, comments). It's possible that these cached versions become outdated, for example when the `external_url` configuration option is changed - causing links diff --git a/doc/administration/monitoring/prometheus/gitlab_metrics.md b/doc/administration/monitoring/prometheus/gitlab_metrics.md index 02920293daa..80fa30da357 100644 --- a/doc/administration/monitoring/prometheus/gitlab_metrics.md +++ b/doc/administration/monitoring/prometheus/gitlab_metrics.md @@ -25,8 +25,8 @@ The following metrics are available: | Metric | Type | Since | Description | Labels | |:---------------------------------------------------------------|:----------|-----------------------:|:----------------------------------------------------------------------------------------------------|:----------------------------------------------------| -| `gitlab_banzai_cached_render_real_duration_seconds` | Histogram | 9.4 | Duration of rendering markdown into HTML when cached output exists | controller, action | -| `gitlab_banzai_cacheless_render_real_duration_seconds` | Histogram | 9.4 | Duration of rendering markdown into HTML when cached outupt does not exist | controller, action | +| `gitlab_banzai_cached_render_real_duration_seconds` | Histogram | 9.4 | Duration of rendering Markdown into HTML when cached output exists | controller, action | +| `gitlab_banzai_cacheless_render_real_duration_seconds` | Histogram | 9.4 | Duration of rendering Markdown into HTML when cached outupt does not exist | controller, action | | `gitlab_cache_misses_total` | Counter | 10.2 | Cache read miss | controller, action | | `gitlab_cache_operation_duration_seconds` | Histogram | 10.2 | Cache access time | | | `gitlab_cache_operations_total` | Counter | 12.2 | Cache operations by controller/action | controller, action, operation | diff --git a/doc/administration/raketasks/uploads/migrate.md b/doc/administration/raketasks/uploads/migrate.md index 517d6b01438..26c811ca54d 100644 --- a/doc/administration/raketasks/uploads/migrate.md +++ b/doc/administration/raketasks/uploads/migrate.md @@ -122,10 +122,10 @@ your data out of Object Storage and back into your local storage. **Before proceeding, it is important to disable both `direct_upload` and `background_upload` under `uploads` settings in `gitlab.rb`** CAUTION: **Warning:** - **Extended downtime is required** so no new files are created in object storage during - the migration. A configuration setting will be added soon to allow migrating - from object storage to local files with only a brief moment of downtime for configuration changes. - See issue [gitlab-org/gitlab#30979](https://gitlab.com/gitlab-org/gitlab/issues/30979) +**Extended downtime is required** so no new files are created in object storage during +the migration. A configuration setting will be added soon to allow migrating +from object storage to local files with only a brief moment of downtime for configuration changes. +To follow progress, see the [relevant issue](https://gitlab.com/gitlab-org/gitlab/issues/30979). ### All-in-one rake task diff --git a/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md b/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md index ca58c4f6836..cb0b24ae026 100644 --- a/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md +++ b/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md @@ -923,7 +923,7 @@ queue = Sidekiq::Queue.new('update_merge_requests') queue.each { |job| job.delete if job.args[0]==125 and job.args[4]=='ref/heads/my_branch'} ``` -**Note:** Running jobs will not be killed. Stop sidekiq before doing this, to get all matching jobs. +**Note:** Running jobs will not be killed. Stop Sidekiq before doing this, to get all matching jobs. ### Enable debug logging of Sidekiq diff --git a/doc/administration/troubleshooting/postgresql.md b/doc/administration/troubleshooting/postgresql.md index f427cd88ce0..d1e2e3488b8 100644 --- a/doc/administration/troubleshooting/postgresql.md +++ b/doc/administration/troubleshooting/postgresql.md @@ -46,7 +46,7 @@ This section is for links to information elsewhere in the GitLab documentation. - Managing Omnibus PostgreSQL versions [from the development docs](https://docs.gitlab.com/omnibus/development/managing-postgresql-versions.html) - [PostgreSQL scaling and HA](../high_availability/database.md) - - including [troubleshooting](../high_availability/database.md#troubleshooting) gitlab-ctl repmgr-check-master and pgbouncer errors + - including [troubleshooting](../high_availability/database.md#troubleshooting) `gitlab-ctl repmgr-check-master` and PgBouncer errors - [Developer database documentation](../../development/README.md#database-guides) - some of which is absolutely not for production use. Including: - understanding EXPLAIN plans @@ -58,7 +58,7 @@ This section is for links to information elsewhere in the GitLab documentation. - required extension pg_trgm - required extension postgres_fdw for Geo -- Errors like this in the production/sidekiq log; see: [Set default_transaction_isolation into read committed](https://docs.gitlab.com/omnibus/settings/database.html#set-default_transaction_isolation-into-read-committed) +- Errors like this in the `production / Sidekiq` log; see: [Set default_transaction_isolation into read committed](https://docs.gitlab.com/omnibus/settings/database.html#set-default_transaction_isolation-into-read-committed) ``` ActiveRecord::StatementInvalid PG::TRSerializationFailure: ERROR: could not serialize access due to concurrent update @@ -96,7 +96,7 @@ PANIC: could not write to file ‘pg_xlog/xlogtemp.123’: No space left on devi References: - [Issue #1 Deadlocks with GitLab 12.1, PostgreSQL 10.7](https://gitlab.com/gitlab-org/gitlab/issues/30528) -- [Customer ticket (internal) GitLab 12.1.6](https://gitlab.zendesk.com/agent/tickets/134307) and [google doc (internal)](https://docs.google.com/document/d/19xw2d_D1ChLiU-MO1QzWab-4-QXgsIUcN5e_04WTKy4) +- [Customer ticket (internal) GitLab 12.1.6](https://gitlab.zendesk.com/agent/tickets/134307) and [Google doc (internal)](https://docs.google.com/document/d/19xw2d_D1ChLiU-MO1QzWab-4-QXgsIUcN5e_04WTKy4) - [Issue #2 deadlocks can occur if an instance is flooded with pushes](https://gitlab.com/gitlab-org/gitlab/issues/33650). Provided for context about how GitLab code can have this sort of unanticipated effect in unusual situations. ``` @@ -117,7 +117,7 @@ Quoting from from issue [#1](https://gitlab.com/gitlab-org/gitlab/issues/30528): TIP: **Tip:** In support, our general approach to reconfiguring timeouts (applies also to the HTTP stack as well) is that it's acceptable to do it temporarily as a workaround. If it makes GitLab usable for the customer, then it buys time to understand the problem more completely, implement a hot fix, or make some other change that addresses the root cause. Generally, the timeouts should be put back to reasonable defaults once the root cause is resolved. -In this case, the guidance we had from development was to drop deadlock_timeout and/or statement_timeout but to leave the third setting at 60s. Setting idle_in_transaction protects the database from sessions potentially hanging for days. There's more discussion in [the issue relating to introducing this timeout on gitlab.com.](https://gitlab.com/gitlab-com/gl-infra/production/issues/1053) +In this case, the guidance we had from development was to drop deadlock_timeout and/or statement_timeout but to leave the third setting at 60s. Setting idle_in_transaction protects the database from sessions potentially hanging for days. There's more discussion in [the issue relating to introducing this timeout on GitLab.com](https://gitlab.com/gitlab-com/gl-infra/production/issues/1053). PostgresSQL defaults: diff --git a/doc/api/deployments.md b/doc/api/deployments.md index 6fc6599a47d..916c99d5f89 100644 --- a/doc/api/deployments.md +++ b/doc/api/deployments.md @@ -13,6 +13,8 @@ GET /projects/:id/deployments | `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | | `order_by`| string | no | Return deployments ordered by `id` or `iid` or `created_at` or `updated_at` or `ref` fields. Default is `id` | | `sort` | string | no | Return deployments sorted in `asc` or `desc` order. Default is `asc` | +| `updated_after` | datetime | no | Return deployments updated after the specified date | +| `updated_before` | datetime | no | Return deployments updated before the specified date | ```bash curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/deployments" diff --git a/doc/api/markdown.md b/doc/api/markdown.md index f5aee725c6a..f4ad1de9ad8 100644 --- a/doc/api/markdown.md +++ b/doc/api/markdown.md @@ -12,7 +12,7 @@ POST /api/v4/markdown | Attribute | Type | Required | Description | | --------- | ------- | ------------- | ------------------------------------------ | -| `text` | string | yes | The markdown text to render | +| `text` | string | yes | The Markdown text to render | | `gfm` | boolean | no (optional) | Render text using GitLab Flavored Markdown. Default is `false` | | `project` | string | no (optional) | Use `project` as a context when creating references using GitLab Flavored Markdown. [Authentication](README.html#authentication) is required if a project is not public. | diff --git a/doc/api/releases/index.md b/doc/api/releases/index.md index 41c4bcd00ce..b5e24188043 100644 --- a/doc/api/releases/index.md +++ b/doc/api/releases/index.md @@ -312,7 +312,7 @@ POST /projects/:id/releases | `id` | integer/string | yes | The ID or [URL-encoded path of the project](../README.md#namespaced-path-encoding). | | `name` | string | no | The release name. | | `tag_name` | string | yes | The tag where the release will be created from. | -| `description` | string | yes | The description of the release. You can use [markdown](../../user/markdown.md). | +| `description` | string | yes | The description of the release. You can use [Markdown](../../user/markdown.md). | | `ref` | string | yes, if `tag_name` doesn't exist | If `tag_name` doesn't exist, the release will be created from `ref`. It can be a commit SHA, another tag name, or a branch name. | | `milestones` | array of string | no | The title of each milestone the release is associated with. | | `assets:links` | array of hash | no | An array of assets links. | @@ -439,7 +439,7 @@ PUT /projects/:id/releases/:tag_name | `id` | integer/string | yes | The ID or [URL-encoded path of the project](../README.md#namespaced-path-encoding). | | `tag_name` | string | yes | The tag where the release will be created from. | | `name` | string | no | The release name. | -| `description` | string | no | The description of the release. You can use [markdown](../../user/markdown.md). | +| `description` | string | no | The description of the release. You can use [Markdown](../../user/markdown.md). | | `milestones` | array of string | no | The title of each milestone to associate with the release (`[]` to remove all milestones from the release). | | `released_at` | datetime | no | The date when the release will be/was ready. Expected in ISO 8601 format (`2019-03-15T08:00:00Z`). | diff --git a/doc/api/settings.md b/doc/api/settings.md index 51d5e5f35d7..9f9e90e4d11 100644 --- a/doc/api/settings.md +++ b/doc/api/settings.md @@ -265,7 +265,7 @@ are listed in the descriptions of the relevant settings. | `html_emails_enabled` | boolean | no | Enable HTML emails. | | `import_sources` | array of strings | no | Sources to allow project import from, possible values: `github`, `bitbucket`, `bitbucket_server`, `gitlab`, `google_code`, `fogbugz`, `git`, `gitlab_project`, `gitea`, `manifest`, and `phabricator`. | | `instance_statistics_visibility_private` | boolean | no | When set to `true` Instance statistics will only be available to admins. | -| `local_markdown_version` | integer | no | Increase this value when any cached markdown should be invalidated. | +| `local_markdown_version` | integer | no | Increase this value when any cached Markdown should be invalidated. | | `max_artifacts_size` | integer | no | Maximum artifacts size in MB | | `max_attachment_size` | integer | no | Limit attachment size in MB | | `max_pages_size` | integer | no | Maximum size of pages repositories in MB | diff --git a/doc/api/tags.md b/doc/api/tags.md index 13c4b83dda8..11291065edc 100644 --- a/doc/api/tags.md +++ b/doc/api/tags.md @@ -189,7 +189,7 @@ Parameters: Request body: -- `description` (required) - Release notes with markdown support +- `description` (required) - Release notes with Markdown support ```json { @@ -221,7 +221,7 @@ Parameters: Request body: -- `description` (required) - Release notes with markdown support +- `description` (required) - Release notes with Markdown support ```json { diff --git a/doc/user/admin_area/appearance.md b/doc/user/admin_area/appearance.md index 1fea6ab8b02..b9eb9e2a731 100644 --- a/doc/user/admin_area/appearance.md +++ b/doc/user/admin_area/appearance.md @@ -46,8 +46,8 @@ of your GitLab instance. These messages will appear on all projects and pages of instance, including the sign in / sign up page. The default color is white text on an orange background, but this can be customized by clicking on **Customize colors**. -Limited [markdown](../markdown.md) is supported, such as bold, italics, and links, for -example. Other markdown features, including lists, images and quotes, are not supported, +Limited [Markdown](../markdown.md) is supported, such as bold, italics, and links, for +example. Other Markdown features, including lists, images and quotes, are not supported, as the header and footer messages can only be a single line. ![header and footer screenshot](img/appearance_header_footer_v12_3.png) @@ -61,7 +61,7 @@ to activate it in the GitLab instance. ## Sign in / Sign up pages You can replace the default message on the sign in / sign up page with your own message -and logo. You can make full use of [markdown](../markdown.md) in the description: +and logo. You can make full use of [Markdown](../markdown.md) in the description: ![sign in message screenshot](img/appearance_sign_in_v12_3.png) @@ -81,7 +81,7 @@ You can add also add a [customized help message](settings/help_page.md) below th ## New project pages You can add a new project guidelines message to the **New project page** within GitLab. -You can make full use of [markdown](../markdown.md) in the description: +You can make full use of [Markdown](../markdown.md) in the description: ![new project message screenshot](img/appearance_new_project_v12_3.png) diff --git a/doc/user/admin_area/monitoring/health_check.md b/doc/user/admin_area/monitoring/health_check.md index 103d7ecc573..68767efc72a 100644 --- a/doc/user/admin_area/monitoring/health_check.md +++ b/doc/user/admin_area/monitoring/health_check.md @@ -103,7 +103,7 @@ This check is being exempt from Rack Attack. ## Liveness DANGER: **Warning:** -In Gitlab [12.4](https://about.gitlab.com/upcoming-releases/) +In GitLab [12.4](https://about.gitlab.com/upcoming-releases/) the response body of the Liveness check was changed to match the example below. diff --git a/doc/user/application_security/container_scanning/index.md b/doc/user/application_security/container_scanning/index.md index 931755c6305..2b021264345 100644 --- a/doc/user/application_security/container_scanning/index.md +++ b/doc/user/application_security/container_scanning/index.md @@ -127,7 +127,7 @@ If you want to whitelist specific vulnerabilities, you'll need to: [overriding the Container Scanning template](#overriding-the-container-scanning-template) section of this document. 1. Define the whitelisted vulnerabilities in a YAML file named `clair-whitelist.yml` which must use the format described in the [following whitelist example file](https://github.com/arminc/clair-scanner/blob/v12/example-whitelist.yaml). - 1. Add the `clair-whitelist.yml` file to the git repository of your project + 1. Add the `clair-whitelist.yml` file to the Git repository of your project ### Overriding the Container Scanning template diff --git a/doc/user/application_security/dast/index.md b/doc/user/application_security/dast/index.md index d285b5ff585..3a8a81f5f57 100644 --- a/doc/user/application_security/dast/index.md +++ b/doc/user/application_security/dast/index.md @@ -85,7 +85,7 @@ There are two ways to define the URL to be scanned by DAST: 1. Add it in an `environment_url.txt` file at the root of your project. This is great for testing in dynamic environments. In order to run DAST against - an app that is dynamically created during a Gitlab CI pipeline, have the app + an app that is dynamically created during a GitLab CI pipeline, have the app persist its domain in an `environment_url.txt` file, and DAST will automatically parse that file to find its scan target. You can see an [example](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml) @@ -228,7 +228,7 @@ server { ###### Apache Apache can also be used as a [reverse proxy](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html) -to add the Gitlab-DAST-Permission [header](https://httpd.apache.org/docs/current/mod/mod_headers.html). +to add the `Gitlab-DAST-Permission` [header](https://httpd.apache.org/docs/current/mod/mod_headers.html). To do so, add the following lines to `httpd.conf`: diff --git a/doc/user/clusters/crossplane.md b/doc/user/clusters/crossplane.md index 37210b22f6f..ee0bd4c33db 100644 --- a/doc/user/clusters/crossplane.md +++ b/doc/user/clusters/crossplane.md @@ -220,9 +220,9 @@ The Resource Classes allow you to define classes of service for a managed servic The Auto DevOps pipeline can be run with the following options: -The Environment variables, `AUTO_DEVOPS_POSTGRES_MANAGED` and `AUTO_DEVOPS_POSTGRES_MANAGED_CLASS_SELECTOR` need to be set to provision PostgresQL using Crossplane +The Environment variables, `AUTO_DEVOPS_POSTGRES_MANAGED` and `AUTO_DEVOPS_POSTGRES_MANAGED_CLASS_SELECTOR` need to be set to provision PostgreSQL using Crossplane -Alertnatively, the following options can be overridden from the values for the helm chart. +Alertnatively, the following options can be overridden from the values for the Helm chart. - `postgres.managed` set to true which will select a default resource class. The resource class needs to be marked with the annotation @@ -237,7 +237,7 @@ Alertnatively, the following options can be overridden from the values for the h The Auto DevOps pipeline should provision a PostgresqlInstance when it runs succesfully. -Verify creation of the PostgresQL Instance. +Verify creation of the PostgreSQL Instance. ```sh kubectl get postgresqlinstance @@ -286,7 +286,7 @@ serverCACertificateInstance: 41 bytes serverCACertificateSha1Fingerprint: 40 bytes ``` -## Connect to the PostgresQL instance +## Connect to the PostgreSQL instance Follow this [GCP guide](https://cloud.google.com/sql/docs/postgres/connect-kubernetes-engine) if you would like to connect to the newly provisioned Postgres database instance on CloudSQL. diff --git a/doc/user/discussions/index.md b/doc/user/discussions/index.md index dcb75a19b2a..d4e485d7c32 100644 --- a/doc/user/discussions/index.md +++ b/doc/user/discussions/index.md @@ -386,7 +386,7 @@ from any device you're logged into. > [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/issues/18008) in GitLab 11.6. As a reviewer, you're able to suggest code changes with a simple -markdown syntax in Merge Request Diff threads. Then, the +Markdown syntax in Merge Request Diff threads. Then, the Merge Request author (or other users with appropriate [permission](../permissions.md)) is able to apply these suggestions with a click, which will generate a commit in diff --git a/doc/user/project/clusters/serverless/aws.md b/doc/user/project/clusters/serverless/aws.md index a195360aa12..0b74f1e73eb 100644 --- a/doc/user/project/clusters/serverless/aws.md +++ b/doc/user/project/clusters/serverless/aws.md @@ -94,7 +94,7 @@ The `events` declaration will create a AWS API Gateway `GET` endpoint to receive You can read more about the available properties and additional configuration possibilities of the Serverless Framework here: <https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/> -### Crafting the .gitlab-ci.yml file +### Crafting the `.gitlab-ci.yml` file In a `.gitlab-ci.yml` file in the root of your project, place the following code: diff --git a/doc/user/project/integrations/prometheus.md b/doc/user/project/integrations/prometheus.md index d3d4afefb59..6f7f9b27aa7 100644 --- a/doc/user/project/integrations/prometheus.md +++ b/doc/user/project/integrations/prometheus.md @@ -520,7 +520,7 @@ The sharing dialog within Grafana provides the link, as highlighted below. NOTE: **Note:** For this embed to display correctly the Grafana instance must be available to the target user, either as a public dashboard or on the same network. -Copy the link and add an image tag as [inline HTML](../../markdown.md#inline-html) in your markdown. You may tweak the query parameters as required. For instance, removing the `&from=` and `&to=` parameters will give you a live chart. Here is example markup for a live chart from GitLab's public dashboard: +Copy the link and add an image tag as [inline HTML](../../markdown.md#inline-html) in your Markdown. You may tweak the query parameters as required. For instance, removing the `&from=` and `&to=` parameters will give you a live chart. Here is example markup for a live chart from GitLab's public dashboard: ```html <img src="https://dashboards.gitlab.com/render/d-solo/RZmbBr7mk/gitlab-triage?orgId=1&refresh=30s&var-env=gprd&var-environment=gprd&var-prometheus=prometheus-01-inf-gprd&var-prometheus_app=prometheus-app-01-inf-gprd&var-backend=All&var-type=All&var-stage=main&panelId=1247&width=1000&height=300"/> @@ -534,7 +534,7 @@ This will render like so: > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/31376) in GitLab 12.5. -Each project can support integration with one Grafana instance. This configuration allows a user to copy a link to a panel in Grafana, then paste it into a GitLab markdown field. The chart will be rendered in the GitLab chart format. +Each project can support integration with one Grafana instance. This configuration allows a user to copy a link to a panel in Grafana, then paste it into a GitLab Markdown field. The chart will be rendered in the GitLab chart format. Prerequisites for embedding from a Grafana instance: @@ -562,7 +562,7 @@ Prerequisites for embedding from a Grafana instance: 1. If your Prometheus queries use Grafana's custom template variables, ensure that "Template variables" and "Current time range" options are toggled to **On**. Of Grafana global template variables, only `$__interval`, `$__from`, and `$__to` are currently supported. ![Grafana Sharing Dialog](img/grafana_sharing_dialog_v12_5.png) 1. Click **Copy** to copy the URL to the clipboard. -1. In GitLab, paste the URL into a markdown field and save. The chart will take a few moments to render. +1. In GitLab, paste the URL into a Markdown field and save. The chart will take a few moments to render. ![GitLab Rendered Grafana Panel](img/rendered_grafana_embed_v12_5.png) ## Troubleshooting diff --git a/doc/user/project/integrations/prometheus_library/nginx.md b/doc/user/project/integrations/prometheus_library/nginx.md index 3c6919561fd..cf46456ca42 100644 --- a/doc/user/project/integrations/prometheus_library/nginx.md +++ b/doc/user/project/integrations/prometheus_library/nginx.md @@ -22,7 +22,7 @@ NGINX server metrics are detected, which tracks the pages and content directly s To get started with NGINX monitoring, you should first enable the [VTS statistics](https://github.com/vozlt/nginx-module-vts)) module for your NGINX server. This will capture and display statistics in an HTML readable form. Next, you should install and configure the [NGINX VTS exporter](https://github.com/hnlq715/nginx-vts-exporter) which parses these statistics and translates them into a Prometheus monitoring endpoint. -If you are using NGINX as your Kubernetes ingress, GitLab will [automatically detect](nginx_ingress.md) the metrics once enabled in 0.9.0 and later releases. +If you are using NGINX as your Kubernetes Ingress, GitLab will [automatically detect](nginx_ingress.md) the metrics once enabled in 0.9.0 and later releases. ## Specifying the Environment label diff --git a/doc/user/project/integrations/prometheus_library/nginx_ingress.md b/doc/user/project/integrations/prometheus_library/nginx_ingress.md index 93f6dbb0302..a973f8c757e 100644 --- a/doc/user/project/integrations/prometheus_library/nginx_ingress.md +++ b/doc/user/project/integrations/prometheus_library/nginx_ingress.md @@ -4,7 +4,7 @@ NOTE: **Note:** NGINX Ingress versions prior to 0.16.0 offer an included [VTS Prometheus metrics exporter](nginx_ingress_vts.md), which exports metrics different than the built-in metrics. -GitLab has support for automatically detecting and monitoring the Kubernetes NGINX Ingress controller. This is provided by leveraging the built-in Prometheus metrics included with Kubernetes NGINX Ingress controller [version 0.16.0](https://github.com/kubernetes/ingress-nginx/blob/master/Changelog.md#0160) onward. +GitLab has support for automatically detecting and monitoring the Kubernetes NGINX Ingress controller. This is provided by leveraging the built-in Prometheus metrics included with Kubernetes NGINX Ingress Controller [version 0.16.0](https://github.com/kubernetes/ingress-nginx/blob/master/Changelog.md#0160) onward. ## Requirements diff --git a/doc/user/project/operations/error_tracking.md b/doc/user/project/operations/error_tracking.md index 04eda026bc3..ed244a622b2 100644 --- a/doc/user/project/operations/error_tracking.md +++ b/doc/user/project/operations/error_tracking.md @@ -32,7 +32,7 @@ GitLab provides an easy way to connect Sentry to your project: 1. Click **Save changes** for the changes to take effect. 1. You can now visit **Operations > Error Tracking** in your project's sidebar to [view a list](#error-tracking-list) of Sentry errors. -### Enabling Gitlab issues links +### Enabling GitLab issues links You may also want to enable Sentry's GitLab integration by following the steps in the [Sentry documentation](https://docs.sentry.io/workflow/integrations/global-integrations/#gitlab) diff --git a/doc/user/project/releases/index.md b/doc/user/project/releases/index.md index 9b7b20be98f..54e59a318c3 100644 --- a/doc/user/project/releases/index.md +++ b/doc/user/project/releases/index.md @@ -32,7 +32,7 @@ your users to quickly scan the differences between each one you publish. NOTE: **Note:** [Git's tagging messages](https://git-scm.com/book/en/v2/Git-Basics-Tagging) and -Release descriptions are unrelated. Description supports [markdown](../../markdown.md). +Release descriptions are unrelated. Description supports [Markdown](../../markdown.md). ### Release assets @@ -126,7 +126,7 @@ following modal window will be then displayed, from which you can select **New r ## Add release notes to Git tags You can add release notes to any Git tag using the notes feature. Release notes -behave like any other markdown form in GitLab so you can write text and +behave like any other Markdown form in GitLab so you can write text and drag and drop files to it. Release notes are stored in GitLab's database. There are several ways to add release notes: diff --git a/doc/user/project/repository/web_editor.md b/doc/user/project/repository/web_editor.md index 944720c3863..ef7cfdb8d8e 100644 --- a/doc/user/project/repository/web_editor.md +++ b/doc/user/project/repository/web_editor.md @@ -152,7 +152,7 @@ SHA. From a project's files page, choose **New tag** from the dropdown. Give the tag a name such as `v1.0.0`. Choose the branch or SHA from which you would like to create this new tag. You can optionally add a message and -release notes. The release notes section supports markdown format and you can +release notes. The release notes section supports Markdown format and you can also upload an attachment. Click **Create tag** and you will be taken to the tag list page. diff --git a/doc/user/project/settings/index.md b/doc/user/project/settings/index.md index 2dc507901d0..810bd2a5937 100644 --- a/doc/user/project/settings/index.md +++ b/doc/user/project/settings/index.md @@ -18,7 +18,7 @@ Adjust your project's name, description, avatar, [default branch](../repository/ ![general project settings](img/general_settings.png) -The project description also partially supports [standard markdown](../../markdown.md#standard-markdown-and-extensions-in-gitlab). You can use [emphasis](../../markdown.md#emphasis), [links](../../markdown.md#links), and [line-breaks](../../markdown.md#line-breaks) to add more context to the project description. +The project description also partially supports [standard Markdown](../../markdown.md#standard-markdown-and-extensions-in-gitlab). You can use [emphasis](../../markdown.md#emphasis), [links](../../markdown.md#links), and [line-breaks](../../markdown.md#line-breaks) to add more context to the project description. ### Sharing and permissions diff --git a/lib/api/deployments.rb b/lib/api/deployments.rb index f97200f20b9..84d1d8a0aac 100644 --- a/lib/api/deployments.rb +++ b/lib/api/deployments.rb @@ -17,16 +17,19 @@ module API end params do use :pagination - optional :order_by, type: String, values: %w[id iid created_at updated_at ref], default: 'id', desc: 'Return deployments ordered by `id` or `iid` or `created_at` or `updated_at` or `ref`' - optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)' + optional :order_by, type: String, values: DeploymentsFinder::ALLOWED_SORT_VALUES, default: DeploymentsFinder::DEFAULT_SORT_VALUE, desc: 'Return deployments ordered by specified value' + optional :sort, type: String, values: DeploymentsFinder::ALLOWED_SORT_DIRECTIONS, default: DeploymentsFinder::DEFAULT_SORT_DIRECTION, desc: 'Sort by asc (ascending) or desc (descending)' + optional :updated_after, type: DateTime, desc: 'Return deployments updated after the specified date' + optional :updated_before, type: DateTime, desc: 'Return deployments updated before the specified date' end - # rubocop: disable CodeReuse/ActiveRecord + get ':id/deployments' do authorize! :read_deployment, user_project - present paginate(user_project.deployments.order(params[:order_by] => params[:sort])), with: Entities::Deployment + deployments = DeploymentsFinder.new(user_project, params).execute + + present paginate(deployments), with: Entities::Deployment end - # rubocop: enable CodeReuse/ActiveRecord desc 'Gets a specific deployment' do detail 'This feature was introduced in GitLab 8.11.' diff --git a/spec/finders/deployments_finder_spec.rb b/spec/finders/deployments_finder_spec.rb new file mode 100644 index 00000000000..f21bb068c24 --- /dev/null +++ b/spec/finders/deployments_finder_spec.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe DeploymentsFinder do + subject { described_class.new(project, params).execute } + + let(:project) { create(:project, :public, :repository) } + let(:params) { {} } + + describe "#execute" do + it 'returns all deployments by default' do + deployments = create_list(:deployment, 2, :success, project: project) + is_expected.to match_array(deployments) + end + + describe 'filtering' do + context 'when updated_at filters are specified' do + let(:params) { { updated_before: 1.day.ago, updated_after: 3.days.ago } } + let!(:deployment_1) { create(:deployment, :success, project: project, updated_at: 2.days.ago) } + let!(:deployment_2) { create(:deployment, :success, project: project, updated_at: 4.days.ago) } + let!(:deployment_3) { create(:deployment, :success, project: project, updated_at: 1.hour.ago) } + + it 'returns deployments with matched updated_at' do + is_expected.to match_array([deployment_1]) + end + end + end + + describe 'ordering' do + using RSpec::Parameterized::TableSyntax + + let(:params) { { order_by: order_by, sort: sort } } + + let!(:deployment_1) { create(:deployment, :success, project: project, iid: 11, ref: 'master', created_at: Time.now, updated_at: Time.now) } + let!(:deployment_2) { create(:deployment, :success, project: project, iid: 12, ref: 'feature', created_at: 1.day.ago, updated_at: 2.hours.ago) } + let!(:deployment_3) { create(:deployment, :success, project: project, iid: 8, ref: 'patch', created_at: 2.days.ago, updated_at: 1.hour.ago) } + + where(:order_by, :sort, :ordered_deployments) do + 'created_at' | 'asc' | [:deployment_3, :deployment_2, :deployment_1] + 'created_at' | 'desc' | [:deployment_1, :deployment_2, :deployment_3] + 'id' | 'asc' | [:deployment_1, :deployment_2, :deployment_3] + 'id' | 'desc' | [:deployment_3, :deployment_2, :deployment_1] + 'iid' | 'asc' | [:deployment_3, :deployment_1, :deployment_2] + 'iid' | 'desc' | [:deployment_2, :deployment_1, :deployment_3] + 'ref' | 'asc' | [:deployment_2, :deployment_1, :deployment_3] + 'ref' | 'desc' | [:deployment_3, :deployment_1, :deployment_2] + 'updated_at' | 'asc' | [:deployment_2, :deployment_3, :deployment_1] + 'updated_at' | 'desc' | [:deployment_1, :deployment_3, :deployment_2] + 'invalid' | 'asc' | [:deployment_1, :deployment_2, :deployment_3] + 'iid' | 'err' | [:deployment_3, :deployment_1, :deployment_2] + end + + with_them do + it 'returns the deployments ordered' do + expect(subject).to eq(ordered_deployments.map { |name| public_send(name) }) + end + end + end + end +end diff --git a/spec/requests/api/deployments_spec.rb b/spec/requests/api/deployments_spec.rb index 26849c0991d..91e047774bf 100644 --- a/spec/requests/api/deployments_spec.rb +++ b/spec/requests/api/deployments_spec.rb @@ -31,39 +31,36 @@ describe API::Deployments do end describe 'ordering' do - using RSpec::Parameterized::TableSyntax - - let(:order_by) { nil } - let(:sort) { nil } + let(:order_by) { 'iid' } + let(:sort) { 'desc' } subject { get api("/projects/#{project.id}/deployments?order_by=#{order_by}&sort=#{sort}", user) } + before do + subject + end + def expect_deployments(ordered_deployments) - json_response.each_with_index do |deployment_json, index| - expect(deployment_json['id']).to eq(public_send(ordered_deployments[index]).id) - end + expect(json_response.map { |d| d['id'] }).to eq(ordered_deployments.map(&:id)) end - before do - subject + it 'returns ordered deployments' do + expect(json_response.map { |i| i['id'] }).to eq([deployment_2.id, deployment_1.id, deployment_3.id]) end - where(:order_by, :sort, :ordered_deployments) do - 'created_at' | 'asc' | [:deployment_3, :deployment_2, :deployment_1] - 'created_at' | 'desc' | [:deployment_1, :deployment_2, :deployment_3] - 'id' | 'asc' | [:deployment_1, :deployment_2, :deployment_3] - 'id' | 'desc' | [:deployment_3, :deployment_2, :deployment_1] - 'iid' | 'asc' | [:deployment_3, :deployment_1, :deployment_2] - 'iid' | 'desc' | [:deployment_2, :deployment_1, :deployment_3] - 'ref' | 'asc' | [:deployment_2, :deployment_1, :deployment_3] - 'ref' | 'desc' | [:deployment_3, :deployment_1, :deployment_2] - 'updated_at' | 'asc' | [:deployment_2, :deployment_3, :deployment_1] - 'updated_at' | 'desc' | [:deployment_1, :deployment_3, :deployment_2] + context 'with invalid order_by' do + let(:order_by) { 'wrong_sorting_value' } + + it 'returns error' do + expect(response).to have_gitlab_http_status(400) + end end - with_them do - it 'returns the deployments ordered' do - expect_deployments(ordered_deployments) + context 'with invalid sorting' do + let(:sort) { 'wrong_sorting_direction' } + + it 'returns error' do + expect(response).to have_gitlab_http_status(400) end end end |