Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
014f6473
Commit
014f6473
authored
Jun 25, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
41c5f5a6
e3fa9d12
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
155 additions
and
114 deletions
+155
-114
.gitlab/ci/memory.gitlab-ci.yml
.gitlab/ci/memory.gitlab-ci.yml
+6
-6
app/views/projects/pages_domains/_form.html.haml
app/views/projects/pages_domains/_form.html.haml
+1
-1
app/workers/pages_domain_ssl_renewal_cron_worker.rb
app/workers/pages_domain_ssl_renewal_cron_worker.rb
+2
-2
app/workers/pages_domain_ssl_renewal_worker.rb
app/workers/pages_domain_ssl_renewal_worker.rb
+2
-4
lib/gitlab/lets_encrypt.rb
lib/gitlab/lets_encrypt.rb
+16
-0
lib/gitlab/lets_encrypt/client.rb
lib/gitlab/lets_encrypt/client.rb
+1
-9
scripts/generate-gems-memory-metrics-static
scripts/generate-gems-memory-metrics-static
+18
-0
scripts/generate-gems-size-metrics-static
scripts/generate-gems-size-metrics-static
+30
-0
scripts/memory-static
scripts/memory-static
+0
-20
scripts/memory-static-objects
scripts/memory-static-objects
+0
-27
spec/lib/gitlab/lets_encrypt/client_spec.rb
spec/lib/gitlab/lets_encrypt/client_spec.rb
+0
-36
spec/lib/gitlab/lets_encrypt_spec.rb
spec/lib/gitlab/lets_encrypt_spec.rb
+56
-0
spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb
spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb
+8
-5
spec/workers/pages_domain_ssl_renewal_worker_spec.rb
spec/workers/pages_domain_ssl_renewal_worker_spec.rb
+15
-4
No files found.
.gitlab/ci/memory.gitlab-ci.yml
View file @
014f6473
...
...
@@ -5,15 +5,15 @@ memory-static:
# Loads each of gems in the Gemfile and checks how much memory they consume when they are required.
# 'derailed_benchmarks' internally uses 'get_process_mem'
-
scripts/memory-static 'tmp/memory_static_full_report.txt' 'tmp/memory_static_metrics.txt'
-
bundle exec derailed bundle:mem > tmp/memory_bundle_mem.txt
-
scripts/generate-gems-size-metrics-static tmp/memory_bundle_mem.txt >> 'tmp/memory_metrics.txt'
# Outputs detailed information about objects created while gems are loaded.
# 'derailed_benchmarks' internally uses 'memory_profiler'
-
scripts/memory-static-objects 'tmp/memory_static_objects_full_report.txt' 'tmp/memory_static_metrics.txt'
-
bundle exec derailed bundle:objects > tmp/memory_bundle_objects.txt
-
scripts/generate-gems-memory-metrics-static tmp/memory_bundle_objects.txt >> 'tmp/memory_metrics.txt'
artifacts
:
paths
:
-
tmp/memory_static_full_report.txt
-
tmp/memory_static_objects_full_report.txt
-
tmp/memory_static_metrics.txt
-
tmp/memory_*.txt
reports
:
metrics
:
tmp/memory_
static_
metrics.txt
metrics
:
tmp/memory_metrics.txt
app/views/projects/pages_domains/_form.html.haml
View file @
014f6473
...
...
@@ -11,7 +11,7 @@
-
if
Gitlab
.
config
.
pages
.
external_https
-
auto_ssl_available
=
::
Gitlab
::
LetsEncrypt
::
Client
.
new
.
enabled?
-
auto_ssl_available
=
::
Gitlab
::
LetsEncrypt
.
enabled?
(
@domain
)
-
auto_ssl_enabled
=
@domain
.
auto_ssl_enabled?
-
auto_ssl_available_and_enabled
=
auto_ssl_available
&&
auto_ssl_enabled
...
...
app/workers/pages_domain_ssl_renewal_cron_worker.rb
View file @
014f6473
...
...
@@ -5,9 +5,9 @@ class PagesDomainSslRenewalCronWorker
include
CronjobQueue
def
perform
return
unless
::
Gitlab
::
LetsEncrypt
::
Client
.
new
.
enabled?
PagesDomain
.
need_auto_ssl_renewal
.
find_each
do
|
domain
|
next
unless
::
Gitlab
::
LetsEncrypt
.
enabled?
(
domain
)
PagesDomainSslRenewalWorker
.
perform_async
(
domain
.
id
)
end
end
...
...
app/workers/pages_domain_ssl_renewal_worker.rb
View file @
014f6473
...
...
@@ -4,11 +4,9 @@ class PagesDomainSslRenewalWorker
include
ApplicationWorker
def
perform
(
domain_id
)
return
unless
::
Gitlab
::
LetsEncrypt
::
Client
.
new
.
enabled?
domain
=
PagesDomain
.
find_by_id
(
domain_id
)
return
unless
domain
return
unless
domain
&
.
enabled?
return
unless
::
Gitlab
::
LetsEncrypt
.
enabled?
(
domain
)
::
PagesDomains
::
ObtainLetsEncryptCertificateService
.
new
(
domain
).
execute
end
...
...
lib/gitlab/lets_encrypt.rb
0 → 100644
View file @
014f6473
# frozen_string_literal: true
module
Gitlab
module
LetsEncrypt
def
self
.
enabled?
(
pages_domain
=
nil
)
return
false
unless
Gitlab
::
CurrentSettings
.
lets_encrypt_terms_of_service_accepted
return
false
unless
Feature
.
enabled?
(
:pages_auto_ssl
)
# If no domain is passed, just check whether we're enabled globally
return
true
unless
pages_domain
!!
pages_domain
.
project
&&
Feature
.
enabled?
(
:pages_auto_ssl_for_project
,
pages_domain
.
project
)
end
end
end
lib/gitlab/lets_encrypt/client.rb
View file @
014f6473
...
...
@@ -34,14 +34,6 @@ module Gitlab
acme_client
.
terms_of_service
end
def
enabled?
return
false
unless
Feature
.
enabled?
(
:pages_auto_ssl
)
return
false
unless
private_key
Gitlab
::
CurrentSettings
.
lets_encrypt_terms_of_service_accepted
end
private
def
acme_client
...
...
@@ -65,7 +57,7 @@ module Gitlab
end
def
ensure_account
raise
'Acme integration is disabled'
unless
enabled?
raise
'Acme integration is disabled'
unless
::
Gitlab
::
LetsEncrypt
.
enabled?
@acme_account
||=
acme_client
.
new_account
(
contact:
contact
,
terms_of_service_agreed:
true
)
end
...
...
scripts/generate-gems-memory-metrics-static
0 → 100755
View file @
014f6473
#!/usr/bin/env ruby
abort
"usage:
#{
__FILE__
}
<memory_bundle_objects_file_name>"
unless
ARGV
.
length
==
1
memory_bundle_objects_file_name
=
ARGV
.
first
full_report
=
File
.
readlines
(
memory_bundle_objects_file_name
)
allocated_str
=
full_report
[
1
]
retained_str
=
full_report
[
2
]
allocated_stats
=
/Total allocated: (?<bytes>.*) bytes \((?<objects>.*) objects\)/
.
match
(
allocated_str
)
retained_stats
=
/Total retained: (?<bytes>.*) bytes \((?<objects>.*) objects\)/
.
match
(
retained_str
)
abort
'failed to process the benchmark output'
unless
allocated_stats
&&
retained_stats
puts
"memory_static_objects_allocated_mb
#{
(
allocated_stats
[
:bytes
].
to_f
/
(
1024
*
1024
)).
round
(
1
)
}
"
puts
"memory_static_objects_retained_mb
#{
(
retained_stats
[
:bytes
].
to_f
/
(
1024
*
1024
)).
round
(
1
)
}
"
puts
"memory_static_objects_allocated_items
#{
allocated_stats
[
:objects
]
}
"
puts
"memory_static_objects_retained_items
#{
retained_stats
[
:objects
]
}
"
scripts/generate-gems-size-metrics-static
0 → 100755
View file @
014f6473
#!/usr/bin/env ruby
abort
"usage:
#{
__FILE__
}
<memory_bundle_mem_file_name>"
unless
ARGV
.
length
==
1
memory_bundle_mem_file_name
=
ARGV
.
first
full_report
=
File
.
readlines
(
memory_bundle_mem_file_name
)
def
total_size
(
memory_bundle_mem_report
)
stats
=
/TOP: (?<total_mibs_str>.*) MiB/
.
match
(
memory_bundle_mem_report
.
first
)
abort
'failed to process the benchmark output'
unless
stats
"gem_total_size_mb
#{
stats
[
:total_mibs_str
].
to_f
.
round
(
1
)
}
"
end
TOP_LEVEL_GEM_LOG_FORMAT
=
/^ (?<gem_name>\S.*):\s*(?<gem_size>\d[.\d]*)\s*MiB/
.
freeze
def
all_gems
(
memory_bundle_mem_report
)
memory_bundle_mem_report
.
map
do
|
line
|
TOP_LEVEL_GEM_LOG_FORMAT
.
match
(
line
)
end
.
compact
end
def
gems_as_metrics
(
gems_match_data
)
gems_match_data
.
map
do
|
gem
|
gem_name
=
gem
[
:gem_name
]
gem_size_mb
=
gem
[
:gem_size
].
to_f
.
round
(
1
)
"gem_size_mb{name=
\"
#{
gem_name
}
\"
}
#{
gem_size_mb
}
"
end
end
puts
total_size
(
full_report
)
puts
gems_as_metrics
(
all_gems
(
full_report
)).
sort
(
&
:casecmp
)
scripts/memory-static
deleted
100755 → 0
View file @
41c5f5a6
#!/usr/bin/env ruby
require_relative
'../lib/gitlab/popen'
full_report_filename
,
metrics_filename
=
ARGV
abort
'usage: memory-static <full_report_filename> <metrics_filename>'
unless
full_report_filename
&&
metrics_filename
full_report
,
status
=
Gitlab
::
Popen
.
popen
(
%w(bundle exec derailed bundle:mem)
)
abort
'failed to execute the benchmark'
unless
status
.
zero?
File
.
open
(
full_report_filename
,
'w'
)
do
|
f
|
f
.
write
(
full_report
)
end
stats
=
/TOP: (?<total_mibs_str>.*) MiB/
.
match
(
full_report
.
lines
.
first
)
abort
'failed to process the benchmark output'
unless
stats
File
.
open
(
metrics_filename
,
'a'
)
do
|
f
|
f
.
puts
"memory_static_total_mb
#{
stats
[
:total_mibs_str
].
to_f
.
round
(
1
)
}
"
end
scripts/memory-static-objects
deleted
100755 → 0
View file @
41c5f5a6
#!/usr/bin/env ruby
require_relative
'../lib/gitlab/popen'
full_report_filename
,
metrics_filename
=
ARGV
abort
'usage: memory-static-objects <full_report_filename> <metrics_filename>'
unless
full_report_filename
&&
metrics_filename
full_report
,
status
=
Gitlab
::
Popen
.
popen
(
%w(bundle exec derailed bundle:objects)
)
abort
'failed to execute the benchmark'
unless
status
.
zero?
File
.
open
(
full_report_filename
,
'w'
)
do
|
f
|
f
.
write
(
full_report
)
end
allocated_str
=
full_report
.
lines
[
1
]
retained_str
=
full_report
.
lines
[
2
]
allocated_stats
=
/Total allocated: (?<bytes>.*) bytes \((?<objects>.*) objects\)/
.
match
(
allocated_str
)
retained_stats
=
/Total retained: (?<bytes>.*) bytes \((?<objects>.*) objects\)/
.
match
(
retained_str
)
abort
'failed to process the benchmark output'
unless
allocated_stats
&&
retained_stats
File
.
open
(
metrics_filename
,
'a'
)
do
|
f
|
f
.
puts
"memory_static_objects_allocated_mb
#{
(
allocated_stats
[
:bytes
].
to_f
/
(
1024
*
1024
)).
round
(
1
)
}
"
f
.
puts
"memory_static_objects_retained_mb
#{
(
retained_stats
[
:bytes
].
to_f
/
(
104
*
1024
)).
round
(
1
)
}
"
f
.
puts
"memory_static_objects_allocated_items
#{
allocated_stats
[
:objects
]
}
"
f
.
puts
"memory_static_objects_retained_items
#{
retained_stats
[
:objects
]
}
"
end
spec/lib/gitlab/lets_encrypt/client_spec.rb
View file @
014f6473
...
...
@@ -116,42 +116,6 @@ describe ::Gitlab::LetsEncrypt::Client do
end
end
describe
'#enabled?'
do
subject
{
client
.
enabled?
}
context
'when terms of service are accepted'
do
it
{
is_expected
.
to
eq
(
true
)
}
context
"when private_key isn't present and database is read only"
do
before
do
allow
(
::
Gitlab
::
Database
).
to
receive
(
:read_only?
).
and_return
(
true
)
end
it
'returns false'
do
expect
(
::
Gitlab
::
CurrentSettings
.
lets_encrypt_private_key
).
to
eq
(
nil
)
is_expected
.
to
eq
(
false
)
end
end
context
'when feature flag is disabled'
do
before
do
stub_feature_flags
(
pages_auto_ssl:
false
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
end
context
'when terms of service are not accepted'
do
before
do
stub_application_setting
(
lets_encrypt_terms_of_service_accepted:
false
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
end
describe
'#terms_of_service_url'
do
subject
{
client
.
terms_of_service_url
}
...
...
spec/lib/gitlab/lets_encrypt_spec.rb
0 → 100644
View file @
014f6473
# frozen_string_literal: true
require
'spec_helper'
describe
::
Gitlab
::
LetsEncrypt
do
include
LetsEncryptHelpers
before
do
stub_lets_encrypt_settings
end
describe
'.enabled?'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:pages_domain
)
{
create
(
:pages_domain
,
project:
project
)
}
subject
{
described_class
.
enabled?
(
pages_domain
)
}
context
'when terms of service are accepted'
do
it
{
is_expected
.
to
eq
(
true
)
}
context
'when feature flag is disabled'
do
before
do
stub_feature_flags
(
pages_auto_ssl:
false
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
end
context
'when terms of service are not accepted'
do
before
do
stub_application_setting
(
lets_encrypt_terms_of_service_accepted:
false
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
context
'when feature flag for project is disabled'
do
before
do
stub_feature_flags
(
pages_auto_ssl_for_project:
false
)
end
it
'returns false'
do
is_expected
.
to
eq
(
false
)
end
end
context
'when domain has not project'
do
let
(
:pages_domain
)
{
create
(
:pages_domain
)
}
it
'returns false'
do
is_expected
.
to
eq
(
false
)
end
end
end
end
spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb
View file @
014f6473
...
...
@@ -12,15 +12,18 @@ describe PagesDomainSslRenewalCronWorker do
end
describe
'#perform'
do
let!
(
:domain
)
{
create
(
:pages_domain
)
}
let!
(
:domain_with_enabled_auto_ssl
)
{
create
(
:pages_domain
,
auto_ssl_enabled:
true
)
}
let!
(
:domain_with_obtained_letsencrypt
)
{
create
(
:pages_domain
,
:letsencrypt
,
auto_ssl_enabled:
true
)
}
let
(
:project
)
{
create
:project
}
let!
(
:domain
)
{
create
(
:pages_domain
,
project:
project
)
}
let!
(
:domain_with_enabled_auto_ssl
)
{
create
(
:pages_domain
,
project:
project
,
auto_ssl_enabled:
true
)
}
let!
(
:domain_with_obtained_letsencrypt
)
do
create
(
:pages_domain
,
:letsencrypt
,
project:
project
,
auto_ssl_enabled:
true
)
end
let!
(
:domain_without_auto_certificate
)
do
create
(
:pages_domain
,
:without_certificate
,
:without_key
,
auto_ssl_enabled:
true
)
create
(
:pages_domain
,
:without_certificate
,
:without_key
,
project:
project
,
auto_ssl_enabled:
true
)
end
let!
(
:domain_with_expired_auto_ssl
)
do
create
(
:pages_domain
,
:letsencrypt
,
:with_expired_certificate
)
create
(
:pages_domain
,
:letsencrypt
,
:with_expired_certificate
,
project:
project
)
end
it
'enqueues a PagesDomainSslRenewalWorker for domains needing renewal'
do
...
...
spec/workers/pages_domain_ssl_renewal_worker_spec.rb
View file @
014f6473
...
...
@@ -7,7 +7,8 @@ describe PagesDomainSslRenewalWorker do
subject
(
:worker
)
{
described_class
.
new
}
let
(
:domain
)
{
create
(
:pages_domain
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:domain
)
{
create
(
:pages_domain
,
project:
project
)
}
before
do
stub_lets_encrypt_settings
...
...
@@ -22,14 +23,24 @@ describe PagesDomainSslRenewalWorker do
worker
.
perform
(
domain
.
id
)
end
shared_examples
'does nothing'
do
it
'does nothing'
do
expect
(
::
PagesDomains
::
ObtainLetsEncryptCertificateService
).
not_to
receive
(
:new
)
end
end
context
'when domain was deleted'
do
before
do
domain
.
destroy!
end
it
'does nothing'
do
expect
(
::
PagesDomains
::
ObtainLetsEncryptCertificateService
).
not_to
receive
(
:new
)
end
include_examples
'does nothing'
end
context
'when domain is disabled'
do
let
(
:domain
)
{
create
(
:pages_domain
,
:disabled
)
}
include_examples
'does nothing'
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment