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
5cd863a4
Commit
5cd863a4
authored
Jan 22, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
b0a9c823
30c141c9
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
181 additions
and
94 deletions
+181
-94
GITLAB_WORKHORSE_VERSION
GITLAB_WORKHORSE_VERSION
+1
-1
app/assets/javascripts/diffs/components/compare_versions_dropdown.vue
...avascripts/diffs/components/compare_versions_dropdown.vue
+1
-1
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+73
-57
changelogs/unreleased/gitlab-workhorse-update-8.1.0.yml
changelogs/unreleased/gitlab-workhorse-update-8.1.0.yml
+5
-0
spec/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table_spec.rb
...ation/populate_cluster_kubernetes_namespace_table_spec.rb
+30
-35
spec/support/migrations_helpers/cluster_helpers.rb
spec/support/migrations_helpers/cluster_helpers.rb
+71
-0
No files found.
GITLAB_WORKHORSE_VERSION
View file @
5cd863a4
8.
0
.0
8.
1
.0
\ No newline at end of file
app/assets/javascripts/diffs/components/compare_versions_dropdown.vue
View file @
5cd863a4
...
...
@@ -141,7 +141,7 @@ export default {
<time-ago
v-if=
"version.created_at"
:time=
"version.created_at"
class=
"js-timeago
js-timeago-render
"
class=
"js-timeago"
/>
</small>
</div>
...
...
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
5cd863a4
...
...
@@ -87,80 +87,96 @@ let timeagoInstance;
*/
export
const
getTimeago
=
()
=>
{
if
(
!
timeagoInstance
)
{
const
localeRemaining
=
(
number
,
index
)
=>
[
[
s__
(
'
Timeago|just now
'
),
s__
(
'
Timeago|right now
'
)],
[
s__
(
'
Timeago|%s seconds ago
'
),
s__
(
'
Timeago|%s seconds remaining
'
)],
[
s__
(
'
Timeago|1 minute ago
'
),
s__
(
'
Timeago|1 minute remaining
'
)],
[
s__
(
'
Timeago|%s minutes ago
'
),
s__
(
'
Timeago|%s minutes remaining
'
)],
[
s__
(
'
Timeago|1 hour ago
'
),
s__
(
'
Timeago|1 hour remaining
'
)],
[
s__
(
'
Timeago|%s hours ago
'
),
s__
(
'
Timeago|%s hours remaining
'
)],
[
s__
(
'
Timeago|1 day ago
'
),
s__
(
'
Timeago|1 day remaining
'
)],
[
s__
(
'
Timeago|%s days ago
'
),
s__
(
'
Timeago|%s days remaining
'
)],
[
s__
(
'
Timeago|1 week ago
'
),
s__
(
'
Timeago|1 week remaining
'
)],
[
s__
(
'
Timeago|%s weeks ago
'
),
s__
(
'
Timeago|%s weeks remaining
'
)],
[
s__
(
'
Timeago|1 month ago
'
),
s__
(
'
Timeago|1 month remaining
'
)],
[
s__
(
'
Timeago|%s months ago
'
),
s__
(
'
Timeago|%s months remaining
'
)],
[
s__
(
'
Timeago|1 year ago
'
),
s__
(
'
Timeago|1 year remaining
'
)],
[
s__
(
'
Timeago|%s years ago
'
),
s__
(
'
Timeago|%s years remaining
'
)],
][
index
];
const
locale
=
(
number
,
index
)
=>
[
[
s__
(
'
Timeago|just now
'
),
s__
(
'
Timeago|right now
'
)],
[
s__
(
'
Timeago|%s seconds ago
'
),
s__
(
'
Timeago|in %s seconds
'
)],
[
s__
(
'
Timeago|1 minute ago
'
),
s__
(
'
Timeago|in 1 minute
'
)],
[
s__
(
'
Timeago|%s minutes ago
'
),
s__
(
'
Timeago|in %s minutes
'
)],
[
s__
(
'
Timeago|1 hour ago
'
),
s__
(
'
Timeago|in 1 hour
'
)],
[
s__
(
'
Timeago|%s hours ago
'
),
s__
(
'
Timeago|in %s hours
'
)],
[
s__
(
'
Timeago|1 day ago
'
),
s__
(
'
Timeago|in 1 day
'
)],
[
s__
(
'
Timeago|%s days ago
'
),
s__
(
'
Timeago|in %s days
'
)],
[
s__
(
'
Timeago|1 week ago
'
),
s__
(
'
Timeago|in 1 week
'
)],
[
s__
(
'
Timeago|%s weeks ago
'
),
s__
(
'
Timeago|in %s weeks
'
)],
[
s__
(
'
Timeago|1 month ago
'
),
s__
(
'
Timeago|in 1 month
'
)],
[
s__
(
'
Timeago|%s months ago
'
),
s__
(
'
Timeago|in %s months
'
)],
[
s__
(
'
Timeago|1 year ago
'
),
s__
(
'
Timeago|in 1 year
'
)],
[
s__
(
'
Timeago|%s years ago
'
),
s__
(
'
Timeago|in %s years
'
)],
][
index
];
timeago
.
register
(
timeagoLanguageCode
,
locale
);
timeago
.
register
(
`
${
timeagoLanguageCode
}
-remaining`
,
localeRemaining
);
timeagoInstance
=
timeago
();
const
memoizedLocaleRemaining
=
()
=>
{
const
cache
=
[];
const
timeAgoLocaleRemaining
=
[
()
=>
[
s__
(
'
Timeago|just now
'
),
s__
(
'
Timeago|right now
'
)],
()
=>
[
s__
(
'
Timeago|%s seconds ago
'
),
s__
(
'
Timeago|%s seconds remaining
'
)],
()
=>
[
s__
(
'
Timeago|1 minute ago
'
),
s__
(
'
Timeago|1 minute remaining
'
)],
()
=>
[
s__
(
'
Timeago|%s minutes ago
'
),
s__
(
'
Timeago|%s minutes remaining
'
)],
()
=>
[
s__
(
'
Timeago|1 hour ago
'
),
s__
(
'
Timeago|1 hour remaining
'
)],
()
=>
[
s__
(
'
Timeago|%s hours ago
'
),
s__
(
'
Timeago|%s hours remaining
'
)],
()
=>
[
s__
(
'
Timeago|1 day ago
'
),
s__
(
'
Timeago|1 day remaining
'
)],
()
=>
[
s__
(
'
Timeago|%s days ago
'
),
s__
(
'
Timeago|%s days remaining
'
)],
()
=>
[
s__
(
'
Timeago|1 week ago
'
),
s__
(
'
Timeago|1 week remaining
'
)],
()
=>
[
s__
(
'
Timeago|%s weeks ago
'
),
s__
(
'
Timeago|%s weeks remaining
'
)],
()
=>
[
s__
(
'
Timeago|1 month ago
'
),
s__
(
'
Timeago|1 month remaining
'
)],
()
=>
[
s__
(
'
Timeago|%s months ago
'
),
s__
(
'
Timeago|%s months remaining
'
)],
()
=>
[
s__
(
'
Timeago|1 year ago
'
),
s__
(
'
Timeago|1 year remaining
'
)],
()
=>
[
s__
(
'
Timeago|%s years ago
'
),
s__
(
'
Timeago|%s years remaining
'
)],
];
return
(
number
,
index
)
=>
{
if
(
cache
[
index
])
{
return
cache
[
index
];
}
cache
[
index
]
=
timeAgoLocaleRemaining
[
index
]
&&
timeAgoLocaleRemaining
[
index
]();
return
cache
[
index
];
};
};
return
timeagoInstance
;
};
const
memoizedLocale
=
()
=>
{
const
cache
=
[];
const
timeAgoLocale
=
[
()
=>
[
s__
(
'
Timeago|just now
'
),
s__
(
'
Timeago|right now
'
)],
()
=>
[
s__
(
'
Timeago|%s seconds ago
'
),
s__
(
'
Timeago|in %s seconds
'
)],
()
=>
[
s__
(
'
Timeago|1 minute ago
'
),
s__
(
'
Timeago|in 1 minute
'
)],
()
=>
[
s__
(
'
Timeago|%s minutes ago
'
),
s__
(
'
Timeago|in %s minutes
'
)],
()
=>
[
s__
(
'
Timeago|1 hour ago
'
),
s__
(
'
Timeago|in 1 hour
'
)],
()
=>
[
s__
(
'
Timeago|%s hours ago
'
),
s__
(
'
Timeago|in %s hours
'
)],
()
=>
[
s__
(
'
Timeago|1 day ago
'
),
s__
(
'
Timeago|in 1 day
'
)],
()
=>
[
s__
(
'
Timeago|%s days ago
'
),
s__
(
'
Timeago|in %s days
'
)],
()
=>
[
s__
(
'
Timeago|1 week ago
'
),
s__
(
'
Timeago|in 1 week
'
)],
()
=>
[
s__
(
'
Timeago|%s weeks ago
'
),
s__
(
'
Timeago|in %s weeks
'
)],
()
=>
[
s__
(
'
Timeago|1 month ago
'
),
s__
(
'
Timeago|in 1 month
'
)],
()
=>
[
s__
(
'
Timeago|%s months ago
'
),
s__
(
'
Timeago|in %s months
'
)],
()
=>
[
s__
(
'
Timeago|1 year ago
'
),
s__
(
'
Timeago|in 1 year
'
)],
()
=>
[
s__
(
'
Timeago|%s years ago
'
),
s__
(
'
Timeago|in %s years
'
)],
];
/**
* For the given element, renders a timeago instance.
* @param {jQuery} $els
*/
export
const
renderTimeago
=
$els
=>
{
const
timeagoEls
=
$els
||
document
.
querySelectorAll
(
'
.js-timeago-render
'
);
return
(
number
,
index
)
=>
{
if
(
cache
[
index
])
{
return
cache
[
index
];
}
cache
[
index
]
=
timeAgoLocale
[
index
]
&&
timeAgoLocale
[
index
]();
return
cache
[
index
];
};
};
timeago
.
register
(
timeagoLanguageCode
,
memoizedLocale
());
timeago
.
register
(
`
${
timeagoLanguageCode
}
-remaining`
,
memoizedLocaleRemaining
());
timeagoInstance
=
timeago
();
}
// timeago.js sets timeouts internally for each timeago value to be updated in real time
getTimeago
().
render
(
timeagoEls
,
timeagoLanguageCode
);
return
timeagoInstance
;
};
/**
* For the given elements, sets a tooltip with a formatted date.
* @param {
jQuery}
* @param {
JQuery} $timeagoEls
* @param {Boolean} setTimeago
*/
export
const
localTimeAgo
=
(
$timeagoEls
,
setTimeago
=
true
)
=>
{
getTimeago
().
render
(
$timeagoEls
,
timeagoLanguageCode
);
if
(
!
setTimeago
)
{
return
;
}
function
addTimeAgoTooltip
()
{
$timeagoEls
.
each
((
i
,
el
)
=>
{
if
(
setTimeago
)
{
// Recreate with custom template
$
(
el
).
tooltip
({
template
:
'
<div class="tooltip local-timeago" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>
'
,
});
}
el
.
classList
.
add
(
'
js-timeago-render
'
);
});
}
re
nderTimeago
(
$timeagoEls
);
re
questIdleCallback
(
addTimeAgoTooltip
);
};
/**
...
...
changelogs/unreleased/gitlab-workhorse-update-8.1.0.yml
0 → 100644
View file @
5cd863a4
---
title
:
Upgrade gitlab-workhorse to 8.1.0
merge_request
:
24571
author
:
type
:
other
spec/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table_spec.rb
View file @
5cd863a4
...
...
@@ -2,92 +2,88 @@
require
'spec_helper'
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe
Gitlab
::
BackgroundMigration
::
PopulateClusterKubernetesNamespaceTable
,
:migration
,
schema:
20181022173835
do
include
MigrationHelpers
::
ClusterHelpers
let
(
:migration
)
{
described_class
.
new
}
let
(
:clusters
)
{
create_list
(
:cluster
,
10
,
:project
,
:provided_by_gcp
)
}
let
(
:clusters_table
)
{
table
(
:clusters
)
}
let
(
:cluster_projects_table
)
{
table
(
:cluster_projects
)
}
let
(
:cluster_kubernetes_namespaces_table
)
{
table
(
:clusters_kubernetes_namespaces
)
}
let
(
:projects_table
)
{
table
(
:projects
)
}
let
(
:namespaces_table
)
{
table
(
:namespaces
)
}
let
(
:provider_gcp_table
)
{
table
(
:cluster_providers_gcp
)
}
let
(
:platform_kubernetes_table
)
{
table
(
:cluster_platforms_kubernetes
)
}
before
do
c
lusters
c
reate_cluster_project_list
(
10
)
end
shared_examples
'consistent kubernetes namespace attributes'
do
it
'should populate namespace and service account information'
do
subject
migration
.
perform
clusters_with_namespace
.
each
do
|
cluster
|
project
=
cluster
.
project
cluster_project
=
cluster
.
cluster_projects
.
first
cluster_project
=
cluster_projects_table
.
find_by
(
cluster_id:
cluster
.
id
)
project
=
projects_table
.
find
(
cluster_project
.
project_id
)
kubernetes_namespace
=
cluster_kubernetes_namespaces_table
.
find_by
(
cluster_id:
cluster
.
id
)
namespace
=
"
#{
project
.
path
}
-
#{
project
.
id
}
"
kubernetes_namespace
=
cluster
.
reload
.
kubernetes_namespace
expect
(
kubernetes_namespace
).
to
be_present
expect
(
kubernetes_namespace
.
cluster_project
).
to
eq
(
cluster_project
)
expect
(
kubernetes_namespace
.
project
).
to
eq
(
cluster_project
.
project
)
expect
(
kubernetes_namespace
.
cluster
).
to
eq
(
cluster_project
.
cluster
)
expect
(
kubernetes_namespace
.
cluster_project
_id
).
to
eq
(
cluster_project
.
id
)
expect
(
kubernetes_namespace
.
project
_id
).
to
eq
(
cluster_project
.
project_id
)
expect
(
kubernetes_namespace
.
cluster
_id
).
to
eq
(
cluster_project
.
cluster_id
)
expect
(
kubernetes_namespace
.
namespace
).
to
eq
(
namespace
)
expect
(
kubernetes_namespace
.
service_account_name
).
to
eq
(
"
#{
namespace
}
-service-account"
)
end
end
end
subject
{
migration
.
perform
}
context
'when no Clusters::Project has a Clusters::KubernetesNamespace'
do
let
(
:cluster_projects
)
{
Clusters
::
Project
.
all
}
let
(
:cluster_projects
)
{
cluster_projects_table
.
all
}
it
'should create a Clusters::KubernetesNamespace per Clusters::Project'
do
expect
do
subject
end
.
to
change
(
Clusters
::
KubernetesNamespace
,
:count
).
by
(
cluster_projects
.
count
)
migration
.
perform
end
.
to
change
(
Clusters
::
KubernetesNamespace
,
:count
).
by
(
cluster_projects
_table
.
count
)
end
it_behaves_like
'consistent kubernetes namespace attributes'
do
let
(
:clusters_with_namespace
)
{
clusters
}
let
(
:clusters_with_namespace
)
{
clusters
_table
.
all
}
end
end
context
'when every Clusters::Project has Clusters::KubernetesNamespace'
do
before
do
clusters
.
each
do
|
cluster
|
create
(
:cluster_kubernetes_namespace
,
cluster_project:
cluster
.
cluster_projects
.
first
,
cluster:
cluster
,
project:
cluster
.
project
)
end
create_kubernetes_namespace
(
clusters_table
.
all
)
end
it
'should not create any Clusters::KubernetesNamespace'
do
expect
do
subject
migration
.
perform
end
.
not_to
change
(
Clusters
::
KubernetesNamespace
,
:count
)
end
end
context
'when only some Clusters::Project have Clusters::KubernetesNamespace related'
do
let
(
:with_kubernetes_namespace
)
{
clusters
.
first
(
6
)
}
let
(
:with_no_kubernetes_namespace
)
{
clusters
.
last
(
4
)
}
let
(
:with_kubernetes_namespace
)
{
clusters
_table
.
first
(
6
)
}
let
(
:with_no_kubernetes_namespace
)
{
clusters
_table
.
last
(
4
)
}
before
do
with_kubernetes_namespace
.
each
do
|
cluster
|
create
(
:cluster_kubernetes_namespace
,
cluster_project:
cluster
.
cluster_projects
.
first
,
cluster:
cluster
,
project:
cluster
.
project
)
end
create_kubernetes_namespace
(
with_kubernetes_namespace
)
end
it
'creates limited number of Clusters::KubernetesNamespace'
do
expect
do
subject
migration
.
perform
end
.
to
change
(
Clusters
::
KubernetesNamespace
,
:count
).
by
(
with_no_kubernetes_namespace
.
count
)
end
it
'should not modify clusters with Clusters::KubernetesNamespace'
do
subject
migration
.
perform
with_kubernetes_namespace
.
each
do
|
cluster
|
expect
(
cluster
.
kubernetes_namespaces
.
count
).
to
eq
(
1
)
kubernetes_namespace
=
cluster_kubernetes_namespaces_table
.
where
(
cluster_id:
cluster
.
id
)
expect
(
kubernetes_namespace
.
count
).
to
eq
(
1
)
end
end
...
...
@@ -96,4 +92,3 @@ describe Gitlab::BackgroundMigration::PopulateClusterKubernetesNamespaceTable, :
end
end
end
# rubocop:enable RSpec/FactoriesInMigrationSpecs
spec/support/migrations_helpers/cluster_helpers.rb
0 → 100644
View file @
5cd863a4
# frozen_string_literal: true
module
MigrationHelpers
module
ClusterHelpers
# Creates a list of cluster projects.
def
create_cluster_project_list
(
quantity
)
group
=
namespaces_table
.
create
(
name:
'gitlab-org'
,
path:
'gitlab-org'
)
quantity
.
times
do
|
id
|
create_cluster_project
(
group
,
id
)
end
end
# Creates dependencies for a cluster project:
# - Group
# - Project
# - Cluster
# - Project - cluster relationship
# - GCP provider
# - Platform Kubernetes
def
create_cluster_project
(
group
,
id
)
project
=
projects_table
.
create!
(
name:
"project-
#{
id
}
"
,
path:
"project-
#{
id
}
"
,
namespace_id:
group
.
id
)
cluster
=
clusters_table
.
create
(
name:
'test-cluster'
,
cluster_type:
3
,
provider_type: :gcp
,
platform_type: :kubernetes
)
cluster_projects_table
.
create
(
project_id:
project
.
id
,
cluster_id:
cluster
.
id
)
provider_gcp_table
.
create!
(
gcp_project_id:
"test-gcp-project-
#{
id
}
"
,
endpoint:
'111.111.111.111'
,
cluster_id:
cluster
.
id
,
status:
3
,
num_nodes:
1
,
zone:
'us-central1-a'
)
platform_kubernetes_table
.
create
(
cluster_id:
cluster
.
id
,
api_url:
'https://kubernetes.example.com'
,
encrypted_token:
'a'
*
40
,
encrypted_token_iv:
'a'
*
40
)
end
# Creates a Kubernetes namespace for a list of clusters
def
create_kubernetes_namespace
(
clusters
)
clusters
.
each
do
|
cluster
|
cluster_project
=
cluster_projects_table
.
find_by
(
cluster_id:
cluster
.
id
)
project
=
projects_table
.
find
(
cluster_project
.
project_id
)
namespace
=
"
#{
project
.
path
}
-
#{
project
.
id
}
"
cluster_kubernetes_namespaces_table
.
create
(
cluster_project_id:
cluster_project
.
id
,
cluster_id:
cluster
.
id
,
project_id:
cluster_project
.
project_id
,
namespace:
namespace
,
service_account_name:
"
#{
namespace
}
-service-account"
)
end
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