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
49551dbc
Commit
49551dbc
authored
Jun 30, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
b51951ef
af2320c7
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
282 additions
and
143 deletions
+282
-143
app/assets/javascripts/tracking/index.js
app/assets/javascripts/tracking/index.js
+15
-6
doc/development/usage_ping/dictionary.md
doc/development/usage_ping/dictionary.md
+54
-30
ee/app/services/network_policies/resources_service.rb
ee/app/services/network_policies/resources_service.rb
+8
-0
ee/config/metrics/counts_28d/20210623202402_clusters_using_network_policies_ui_monthly.yml
...0623202402_clusters_using_network_policies_ui_monthly.yml
+18
-0
ee/config/metrics/counts_7d/20210623202358_clusters_using_network_policies_ui_weekly.yml
...10623202358_clusters_using_network_policies_ui_weekly.yml
+18
-0
ee/spec/services/network_policies/resources_service_spec.rb
ee/spec/services/network_policies/resources_service_spec.rb
+18
-1
lib/gitlab/usage_data_counters/known_events/common.yml
lib/gitlab/usage_data_counters/known_events/common.yml
+5
-0
lib/tasks/gitlab/db.rake
lib/tasks/gitlab/db.rake
+1
-1
spec/frontend/tracking_spec.js
spec/frontend/tracking_spec.js
+46
-0
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+2
-1
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+1
-1
spec/models/integrations/ewm_spec.rb
spec/models/integrations/ewm_spec.rb
+5
-5
spec/models/integrations/jira_spec.rb
spec/models/integrations/jira_spec.rb
+91
-98
No files found.
app/assets/javascripts/tracking/index.js
View file @
49551dbc
...
...
@@ -34,6 +34,12 @@ const addExperimentContext = (opts) => {
return
options
;
};
const
renameKey
=
(
o
,
oldKey
,
newKey
)
=>
{
const
ret
=
{};
delete
Object
.
assign
(
ret
,
o
,
{
[
newKey
]:
o
[
oldKey
]
})[
oldKey
];
return
ret
;
};
const
createEventPayload
=
(
el
,
{
suffix
=
''
}
=
{})
=>
{
const
{
trackAction
,
...
...
@@ -186,15 +192,18 @@ export default class Tracking {
(
context
)
=>
context
.
schema
!==
standardContext
.
schema
,
);
const
mappedConfig
=
{
forms
:
{
whitelist
:
config
.
forms
?.
allow
||
[]
},
fields
:
{
whitelist
:
config
.
fields
?.
allow
||
[]
},
};
const
mappedConfig
=
{};
if
(
config
.
forms
)
mappedConfig
.
forms
=
renameKey
(
config
.
forms
,
'
allow
'
,
'
whitelist
'
);
if
(
config
.
fields
)
mappedConfig
.
fields
=
renameKey
(
config
.
fields
,
'
allow
'
,
'
whitelist
'
);
const
enabler
=
()
=>
window
.
snowplow
(
'
enableFormTracking
'
,
mappedConfig
,
userProvidedContexts
);
if
(
document
.
readyState
!==
'
loading
'
)
enabler
();
else
document
.
addEventListener
(
'
DOMContentLoaded
'
,
enabler
);
if
(
document
.
readyState
===
'
complete
'
)
enabler
();
else
{
document
.
addEventListener
(
'
readystatechange
'
,
()
=>
{
if
(
document
.
readyState
===
'
complete
'
)
enabler
();
});
}
}
static
mixin
(
opts
=
{})
{
...
...
doc/development/usage_ping/dictionary.md
View file @
49551dbc
This diff is collapsed.
Click to expand it.
ee/app/services/network_policies/resources_service.rb
View file @
49551dbc
...
...
@@ -3,6 +3,7 @@
module
NetworkPolicies
class
ResourcesService
include
NetworkPolicies
::
Responses
include
Gitlab
::
Utils
::
UsageData
LIMIT
=
100
...
...
@@ -26,6 +27,12 @@ module NetworkPolicies
private
def
track_usage_data_for_cluster
(
platform
,
policies
)
return
if
policies
.
empty?
track_usage_event
(
:clusters_using_network_policies_ui
,
platform
.
cluster_id
)
end
def
execute_per_environment
(
platform
,
namespace
)
policies
=
platform
.
kubeclient
.
get_network_policies
(
namespace:
namespace
)
...
...
@@ -33,6 +40,7 @@ module NetworkPolicies
policies
+=
platform
.
kubeclient
.
get_cilium_network_policies
(
namespace:
namespace
)
.
map
{
|
resource
|
Gitlab
::
Kubernetes
::
CiliumNetworkPolicy
.
from_resource
(
resource
)
}
track_usage_data_for_cluster
(
platform
,
policies
)
[
policies
,
nil
]
rescue
Kubeclient
::
HttpError
=>
e
[
policies
,
e
]
...
...
ee/config/metrics/counts_28d/20210623202402_clusters_using_network_policies_ui_monthly.yml
0 → 100644
View file @
49551dbc
---
key_path
:
redis_hll_counters.network_policies.clusters_using_network_policies_ui_monthly
description
:
Monthly number of distinct clusters with network policies using the network policies UI
product_section
:
sec
product_stage
:
protect
product_group
:
group::container security
product_category
:
container_network_security
value_type
:
number
status
:
implemented
milestone
:
"
14.1"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64731
time_frame
:
28d
data_source
:
redis_hll
data_category
:
Operational
distribution
:
-
ee
tier
:
-
ultimate
ee/config/metrics/counts_7d/20210623202358_clusters_using_network_policies_ui_weekly.yml
0 → 100644
View file @
49551dbc
---
key_path
:
redis_hll_counters.network_policies.clusters_using_network_policies_ui_weekly
description
:
Weekly number of distinct clusters with network policies using the network policies UI
product_section
:
sec
product_stage
:
protect
product_group
:
group::container security
product_category
:
container_network_security
value_type
:
number
status
:
implemented
milestone
:
"
14.1"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64731
time_frame
:
7d
data_source
:
redis_hll
data_category
:
Operational
distribution
:
-
ee
tier
:
-
ultimate
ee/spec/services/network_policies/resources_service_spec.rb
View file @
49551dbc
...
...
@@ -9,7 +9,7 @@ RSpec.describe NetworkPolicies::ResourcesService do
let
(
:project
)
{
create
(
:project
)
}
let
(
:cluster
)
{
create
(
:cluster
,
:instance
)
}
let!
(
:cluster_kubernetes_namespace
)
{
create
(
:cluster_kubernetes_namespace
,
project:
project
,
cluster:
cluster
,
environment:
environment
,
namespace:
'namespace'
)
}
let
(
:platform
)
{
double
(
'Clusters::Platforms::Kubernetes'
,
kubeclient:
kubeclient
)
}
let
(
:platform
)
{
double
(
'Clusters::Platforms::Kubernetes'
,
kubeclient:
kubeclient
,
cluster_id:
cluster
.
id
)
}
let
(
:kubeclient
)
{
double
(
'Kubeclient::Client'
)
}
let
(
:policy
)
do
Gitlab
::
Kubernetes
::
NetworkPolicy
.
new
(
...
...
@@ -46,6 +46,23 @@ RSpec.describe NetworkPolicies::ResourcesService do
expect
(
subject
.
payload
.
last
.
as_json
).
to
eq
(
cilium_policy
.
as_json
)
end
it_behaves_like
'tracking unique hll events'
do
subject
(
:request
)
{
service
.
execute
}
let
(
:target_id
)
{
'clusters_using_network_policies_ui'
}
let
(
:expected_type
)
{
instance_of
(
Integer
)
}
before
do
allow
(
kubeclient
).
to
receive
(
:get_network_policies
)
.
with
(
namespace:
cluster_kubernetes_namespace
.
namespace
)
.
and_return
[
policy
.
generate
]
allow
(
kubeclient
).
to
receive
(
:get_cilium_network_policies
)
.
with
(
namespace:
cluster_kubernetes_namespace
.
namespace
)
.
and_return
[
cilium_policy
.
generate
]
end
end
context
'without deployment_platform'
do
let
(
:platform
)
{
nil
}
...
...
lib/gitlab/usage_data_counters/known_events/common.yml
View file @
49551dbc
...
...
@@ -369,3 +369,8 @@
category
:
testing
aggregation
:
weekly
feature_flag
:
users_expanding_widgets_usage_data
# Container Security - Network Policies
-
name
:
clusters_using_network_policies_ui
redis_slot
:
network_policies
category
:
network_policies
aggregation
:
weekly
lib/tasks/gitlab/db.rake
View file @
49551dbc
...
...
@@ -114,7 +114,7 @@ namespace :gitlab do
end
desc
'Create missing dynamic database partitions'
task
:create_dynamic_partitions
do
task
create_dynamic_partitions: :environment
do
Gitlab
::
Database
::
Partitioning
::
PartitionCreator
.
new
.
create_partitions
end
...
...
spec/frontend/tracking_spec.js
View file @
49551dbc
...
...
@@ -197,6 +197,52 @@ describe('Tracking', () => {
expectedError
,
);
});
it
(
'
does not add empty form whitelist rules
'
,
()
=>
{
Tracking
.
enableFormTracking
({
fields
:
{
allow
:
[
'
input-class1
'
]
}
});
expect
(
snowplowSpy
).
toHaveBeenCalledWith
(
'
enableFormTracking
'
,
{
fields
:
{
whitelist
:
[
'
input-class1
'
]
}
},
[],
);
});
describe
(
'
when `document.readyState` does not equal `complete`
'
,
()
=>
{
const
originalReadyState
=
document
.
readyState
;
const
setReadyState
=
(
value
)
=>
{
Object
.
defineProperty
(
document
,
'
readyState
'
,
{
value
,
configurable
:
true
,
});
};
const
fireReadyStateChangeEvent
=
()
=>
{
document
.
dispatchEvent
(
new
Event
(
'
readystatechange
'
));
};
beforeEach
(()
=>
{
setReadyState
(
'
interactive
'
);
});
afterEach
(()
=>
{
setReadyState
(
originalReadyState
);
});
it
(
'
does not call `window.snowplow` until `readystatechange` is fired and `document.readyState` equals `complete`
'
,
()
=>
{
Tracking
.
enableFormTracking
({
fields
:
{
allow
:
[
'
input-class1
'
]
}
});
expect
(
snowplowSpy
).
not
.
toHaveBeenCalled
();
fireReadyStateChangeEvent
();
expect
(
snowplowSpy
).
not
.
toHaveBeenCalled
();
setReadyState
(
'
complete
'
);
fireReadyStateChangeEvent
();
expect
(
snowplowSpy
).
toHaveBeenCalled
();
});
});
});
describe
(
'
.flushPendingEvents
'
,
()
=>
{
...
...
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
49551dbc
...
...
@@ -46,7 +46,8 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
'pipeline_authoring'
,
'epics_usage'
,
'epic_boards_usage'
,
'secure'
'secure'
,
'network_policies'
)
end
end
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
49551dbc
...
...
@@ -1269,7 +1269,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
let
(
:categories
)
{
::
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
categories
}
let
(
:ineligible_total_categories
)
do
%w[source_code ci_secrets_management incident_management_alerts snippets terraform incident_management_oncall secure]
%w[source_code ci_secrets_management incident_management_alerts snippets terraform incident_management_oncall secure
network_policies
]
end
context
'with redis_hll_tracking feature enabled'
do
...
...
spec/models/integrations/ewm_spec.rb
View file @
49551dbc
...
...
@@ -9,7 +9,7 @@ RSpec.describe Integrations::Ewm do
end
describe
'Validations'
do
context
'when
service
is active'
do
context
'when
integration
is active'
do
before
do
subject
.
active
=
true
end
...
...
@@ -17,12 +17,12 @@ RSpec.describe Integrations::Ewm do
it
{
is_expected
.
to
validate_presence_of
(
:project_url
)
}
it
{
is_expected
.
to
validate_presence_of
(
:issues_url
)
}
it
{
is_expected
.
to
validate_presence_of
(
:new_issue_url
)
}
it_behaves_like
'issue tracker
service
URL attribute'
,
:project_url
it_behaves_like
'issue tracker
service
URL attribute'
,
:issues_url
it_behaves_like
'issue tracker
service
URL attribute'
,
:new_issue_url
it_behaves_like
'issue tracker
integration
URL attribute'
,
:project_url
it_behaves_like
'issue tracker
integration
URL attribute'
,
:issues_url
it_behaves_like
'issue tracker
integration
URL attribute'
,
:new_issue_url
end
context
'when
service
is inactive'
do
context
'when
integration
is inactive'
do
before
do
subject
.
active
=
false
end
...
...
spec/models/integrations/jira_spec.rb
View file @
49551dbc
This diff is collapsed.
Click to expand it.
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