arkaan 2.5.1 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arkaan/account.rb +0 -3
- data/lib/arkaan/monitoring.rb +2 -7
- data/lib/arkaan/monitoring/service.rb +2 -8
- data/lib/arkaan/version.rb +1 -1
- metadata +2 -9
- data/lib/arkaan/monitoring/action.rb +0 -25
- data/lib/arkaan/monitoring/instance.rb +0 -38
- data/lib/arkaan/monitoring/results.rb +0 -10
- data/lib/arkaan/monitoring/results/heartbeat.rb +0 -50
- data/lib/arkaan/monitoring/results/report.rb +0 -46
- data/lib/arkaan/monitoring/vigilante.rb +0 -48
- data/lib/arkaan/monitoring/websocket.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4990a4abb8ed39b023c47fed7560e0cad8aea739b74ed3a849ede6cf903f655
|
4
|
+
data.tar.gz: c83e4c79e96321d68b2a95774d7203a649850c27883b4bd0aa2f758c9d7bc9ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 511fac191930fd795fc4f3961a249ef44159b0f21680f3a009efdd64b3e80c60a2de1046e938b73ae2eb6889a61e8355889367b6cb868ca2eb4f97eedd730c17
|
7
|
+
data.tar.gz: 72b3aa7b65f4f2bc142c5cab8c4859ca569e57f978d261c50c20c7495724dadbb33f554a9eaf911c12b7774f9f7690bef956891d10250965383d901c748c1b35
|
data/lib/arkaan/account.rb
CHANGED
@@ -57,9 +57,6 @@ module Arkaan
|
|
57
57
|
# @!attribute [rw] invitations
|
58
58
|
# @return [Array<Arkaan::Campaigns::Invitation>] the invitations you've issued yourself to other players.
|
59
59
|
has_many :created_invitations, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :creator
|
60
|
-
# @!attribute [rw] websockets
|
61
|
-
# @return [Array<Arkaan::Monitoring::Websocket>] the websockets created by the owner of this account.
|
62
|
-
has_many :websockets, class_name: 'Arkaan::Monitoring::Websocket', inverse_of: :creator
|
63
60
|
# @!attribute [rw] permissions
|
64
61
|
# @return [Array<Arkaan::Files::Permission>] the file access permissions granted to this account.
|
65
62
|
has_many :permissions, class_name: 'Arkaan::Files::Permission', inverse_of: :account
|
data/lib/arkaan/monitoring.rb
CHANGED
@@ -2,12 +2,7 @@ module Arkaan
|
|
2
2
|
# The monitoring module holds all the logic about the services so they can be activated or deactivated.
|
3
3
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
4
4
|
module Monitoring
|
5
|
-
autoload :
|
6
|
-
autoload :
|
7
|
-
autoload :Results , 'arkaan/monitoring/results'
|
8
|
-
autoload :Route , 'arkaan/monitoring/route'
|
9
|
-
autoload :Service , 'arkaan/monitoring/service'
|
10
|
-
autoload :Vigilante, 'arkaan/monitoring/vigilante'
|
11
|
-
autoload :Websocket, 'arkaan/monitoring/websocket'
|
5
|
+
autoload :Route , 'arkaan/monitoring/route'
|
6
|
+
autoload :Service, 'arkaan/monitoring/service'
|
12
7
|
end
|
13
8
|
end
|
@@ -10,21 +10,15 @@ module Arkaan
|
|
10
10
|
include Arkaan::Concerns::Premiumable
|
11
11
|
|
12
12
|
# @!attribute [rw] key
|
13
|
-
# @return [String] the name
|
13
|
+
# @return [String] the name of the service, used as a namespace on the Kubernetes side.
|
14
14
|
field :key, type: String
|
15
15
|
# @!attribute [rw] path
|
16
|
-
# @return [String] the path the service will be mapped on in the API.
|
16
|
+
# @return [String] the path the service will be mapped on in the API. This will be used in the Ingress.
|
17
17
|
field :path, type: String, default: '/'
|
18
|
-
# @!attribute [rw] test_mode
|
19
|
-
# @return [Boolean] TRUE if the service is currently in test mode and thus the gateway shall only qurty local instances.
|
20
|
-
field :test_mode, type: Boolean, default: false
|
21
18
|
|
22
19
|
# @!attribute [rw] creator
|
23
20
|
# @return [Arkaan::Account] the creator of this service.
|
24
21
|
belongs_to :creator, class_name: 'Arkaan::Account', optional: true, inverse_of: :services
|
25
|
-
# @!attribute [rw] instances
|
26
|
-
# @return [Array<Arkaan::Monitoring::Instance>] the instances of this service currently deployed.
|
27
|
-
embeds_many :instances, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :service
|
28
22
|
# @!attribute [rw] routes
|
29
23
|
# @return [Array<Arkaan::Monitoring::Route>] the routes associated to this service, accessible from the gateway.
|
30
24
|
has_many :routes, class_name: 'Arkaan::Monitoring::Route', inverse_of: :service
|
data/lib/arkaan/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkaan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -272,15 +272,8 @@ files:
|
|
272
272
|
- lib/arkaan/files/document.rb
|
273
273
|
- lib/arkaan/files/permission.rb
|
274
274
|
- lib/arkaan/monitoring.rb
|
275
|
-
- lib/arkaan/monitoring/action.rb
|
276
|
-
- lib/arkaan/monitoring/instance.rb
|
277
|
-
- lib/arkaan/monitoring/results.rb
|
278
|
-
- lib/arkaan/monitoring/results/heartbeat.rb
|
279
|
-
- lib/arkaan/monitoring/results/report.rb
|
280
275
|
- lib/arkaan/monitoring/route.rb
|
281
276
|
- lib/arkaan/monitoring/service.rb
|
282
|
-
- lib/arkaan/monitoring/vigilante.rb
|
283
|
-
- lib/arkaan/monitoring/websocket.rb
|
284
277
|
- lib/arkaan/notification.rb
|
285
278
|
- lib/arkaan/oauth.rb
|
286
279
|
- lib/arkaan/oauth/access_token.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# An action is made by an authorized user on the instance of a server to perform a task.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
class Action
|
6
|
-
include Mongoid::Document
|
7
|
-
include Mongoid::Timestamps
|
8
|
-
include Arkaan::Concerns::Enumerable
|
9
|
-
|
10
|
-
# @!attribute [rw] type
|
11
|
-
# @return [Symbol] the type of action you're making on this instance
|
12
|
-
enum_field :type, [:restart]
|
13
|
-
# @!attribute [rw] success
|
14
|
-
# @return [Boolean] TRUE if the action succeeded (or at least was successfully launched), FALSE otherwise.
|
15
|
-
field :success, type: Boolean, default: false
|
16
|
-
|
17
|
-
# @!attribute [rw] user
|
18
|
-
# @return [Arkaan::Account] the user performing the action on the instance.
|
19
|
-
belongs_to :user, class_name: 'Arkaan::Account'
|
20
|
-
# @!attribute [rw] instance
|
21
|
-
# @return [Arkaan::Monitoring::Instance] the instance of a service on which the action is performed.
|
22
|
-
embedded_in :instance, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :actions
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# An instance is one of the services, deployed on one server. A service may have many instances to balance the load between them all.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
class Instance
|
6
|
-
include Mongoid::Document
|
7
|
-
include Mongoid::Timestamps
|
8
|
-
include Arkaan::Concerns::Activable
|
9
|
-
include Arkaan::Concerns::Typable
|
10
|
-
|
11
|
-
# @!attribute [rw] url
|
12
|
-
# @return [String] the URL of the instance, where the requests will be issued.
|
13
|
-
field :url, type: String
|
14
|
-
# @!attribute [rw] running
|
15
|
-
# @return [Boolean] the running status of the instance, indicating if it can be used or not.
|
16
|
-
field :running, type: Boolean, default: false
|
17
|
-
# @!attribute [rw] data
|
18
|
-
# @return [Hash] the additional datas for this instance (for example for an Heroku instance it's all the data provided by the API)
|
19
|
-
field :data, type: Hash, default: {}
|
20
|
-
|
21
|
-
scope :running , ->{ where(running: true) }
|
22
|
-
|
23
|
-
# @!attribute [r] service
|
24
|
-
# @return [Arkaan::Monitoring::Service] the service this instance is linked to.
|
25
|
-
embedded_in :service, class_name: 'Arkaan::Monitoring::Service', inverse_of: :instances
|
26
|
-
# @!attribute [rw] actions
|
27
|
-
# @return [Arkaan::Monitoring::Action] the actions that has been performed on the service.
|
28
|
-
embeds_many :actions, class_name: 'Arkaan::Monitoring::Action', inverse_of: :instance
|
29
|
-
|
30
|
-
has_many :heartbeats, class_name: 'Arkaan::Monitoring::Results::Heartbeat', inverse_of: :instance
|
31
|
-
|
32
|
-
validates :url,
|
33
|
-
presence: {message: 'required'},
|
34
|
-
format: {with: /\A(https?:\/\/)((([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*)|(localhost:[0-9]{2,4})\/?)\z/, message: 'pattern', if: :url?}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# The results module handle classes to make results for the vigilante runs.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
module Results
|
6
|
-
autoload :Report, 'arkaan/monitoring/results/report'
|
7
|
-
autoload :Heartbeat, 'arkaan/monitoring/results/heartbeat'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
module Results
|
4
|
-
# A record is the result of the vigilante asking the health of one instance.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class Heartbeat
|
7
|
-
include Mongoid::Document
|
8
|
-
|
9
|
-
# @!attribute [rw] status
|
10
|
-
# @return [Integer] the HTTP status of the request made for this record.
|
11
|
-
field :status, type: Integer, default: 500
|
12
|
-
# @!attribute [rw] body
|
13
|
-
# @return [Hash] the JSON parsed body from the heartbeat request.
|
14
|
-
field :body, type: Hash, default: {}
|
15
|
-
# @!attribute [rw] healthy
|
16
|
-
# @return [Boolean] TRUE if the instance is deemed healthy, FALSE otherwise.
|
17
|
-
field :healthy, type: Boolean, default: false
|
18
|
-
# @!attribute [rw] started_at
|
19
|
-
# @return [DateTime] the date at which the heartbeat request has started.
|
20
|
-
field :started_at, type: DateTime
|
21
|
-
# @!attribute [rw] ended_at
|
22
|
-
# @return [DateTime] the date at which the request was terminated.
|
23
|
-
field :ended_at, type: DateTime
|
24
|
-
|
25
|
-
# @!attribute [rw] instance
|
26
|
-
# @return [Arkaan::Monitoring::Instance] the instance on which the record has been done.
|
27
|
-
belongs_to :instance, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :heartbeats
|
28
|
-
|
29
|
-
# @!attribute [rw] report
|
30
|
-
# @return [Arkaan::Monitoring::Results::Report] the report made by the vigilante including this record.
|
31
|
-
belongs_to :report, class_name: 'Arkaan::Monitoring::Results::Report', inverse_of: :heartbeats
|
32
|
-
|
33
|
-
attr_readonly :healthy
|
34
|
-
|
35
|
-
def status=(status)
|
36
|
-
self[:status] = status
|
37
|
-
self[:healthy] = status == 200
|
38
|
-
end
|
39
|
-
|
40
|
-
def start!
|
41
|
-
self.started_at = DateTime.now
|
42
|
-
end
|
43
|
-
|
44
|
-
def end!
|
45
|
-
self.ended_at = DateTime.now
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
module Results
|
4
|
-
# A report is the result of one call to the API on one instance status route.
|
5
|
-
# @author Vincent Courtois <courtoi.vincent@outlook.com>
|
6
|
-
class Report
|
7
|
-
include Mongoid::Document
|
8
|
-
include Mongoid::Timestamps
|
9
|
-
|
10
|
-
field :started_at, type: DateTime
|
11
|
-
# @!attribute [rw] ended_at
|
12
|
-
# @return [DateTime] the timestamp at which the report ends.
|
13
|
-
field :ended_at, type: DateTime
|
14
|
-
# @!attribute [rw] total
|
15
|
-
# @return [Integer] the total number of services monitored.
|
16
|
-
field :total, type: Integer, default: 0
|
17
|
-
# @!attribute [rw] healthy
|
18
|
-
# @return [Integer] the number of healthy services amongst all the monitored services.
|
19
|
-
field :healthy, type: Integer, default: 0
|
20
|
-
|
21
|
-
# @!attribute [rw] records
|
22
|
-
# @return [Array<Arkaan::Monitoring::Results::Record>] the records linked to this report.
|
23
|
-
has_many :heartbeats, class_name: 'Arkaan::Monitoring::Results::Heartbeat', inverse_of: :report
|
24
|
-
# @!attribute [rw] vigilante
|
25
|
-
# @return [Arkaan::Monitoring::Vigilante] the vigilante application that has created this report.
|
26
|
-
belongs_to :vigilante, class_name: 'Arkaan::Monitoring::Vigilante', inverse_of: :reports
|
27
|
-
|
28
|
-
def add_heartbeat(heartbeat)
|
29
|
-
self.heartbeats << heartbeat
|
30
|
-
self.total += 1
|
31
|
-
self.healthy += (heartbeat.healthy ? 1 : 0)
|
32
|
-
heartbeat.end!
|
33
|
-
end
|
34
|
-
|
35
|
-
def start!
|
36
|
-
self.started_at = DateTime.now
|
37
|
-
end
|
38
|
-
|
39
|
-
def end!
|
40
|
-
self.ended_at = DateTime.now
|
41
|
-
self.save!
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# A vigilante is a specific type of service that watches over the
|
4
|
-
# infrastructure and give a clear look at its global state.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class Vigilante
|
7
|
-
include Mongoid::Document
|
8
|
-
include Mongoid::Timestamps
|
9
|
-
|
10
|
-
# @!attribute [rw] token
|
11
|
-
# @return [String] the token the vigilante uses to identify himself in the services
|
12
|
-
field :token, type: String
|
13
|
-
# @!attribute [rw] max_results
|
14
|
-
# @return [Integer] the number of results the vigilante should be keeping at any time.
|
15
|
-
# The oldest result should be erased to not go over the limit
|
16
|
-
field :max_results, type: Integer, default: 20
|
17
|
-
|
18
|
-
# @!attribute [rw] reports
|
19
|
-
# @return [Array<Arkaan::monitoring::Results::Report>] the report generated by running this vigilante.
|
20
|
-
has_many :reports, class_name: 'Arkaan::Monitoring::Results::Report', inverse_of: :vigilante
|
21
|
-
|
22
|
-
validates :token, presence: {message: 'required'}
|
23
|
-
|
24
|
-
validates :max_results,
|
25
|
-
numericality: {greater_than: 0, message: 'minimum'}
|
26
|
-
|
27
|
-
# Adds a report to the collection of reports by eventually deleting the oldest one.
|
28
|
-
# @param report [Arkaan::Monitoring::Results::Report] the report to add to the vigilante,
|
29
|
-
# added only if it does not exceed the max number of reports the vigilante can store.
|
30
|
-
def add_report(report)
|
31
|
-
erase_oldest_result if result_full?
|
32
|
-
reports << report
|
33
|
-
end
|
34
|
-
|
35
|
-
# Checks if the list of reports is already full, or if more can be added.
|
36
|
-
# @return [Boolean] TRUE if the number of reports already exceeds the max number.
|
37
|
-
def results_full?
|
38
|
-
reports.to_a.count >= max_results
|
39
|
-
end
|
40
|
-
|
41
|
-
# Erases the oldest results to keep only MAX - 1 results in the list.
|
42
|
-
def erase_oldest_result
|
43
|
-
limit = reports.count + 1 - vigilante.max_results
|
44
|
-
reports.sort_by(created_at: :asc).limit(limit).each(&:delete)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# The websocket is a particular kind of service, just like the gateway. It always has the same signature.
|
4
|
-
# A websocket document is a particular instance of websocket, located on a server and answering to a URL.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class Websocket
|
7
|
-
include Mongoid::Document
|
8
|
-
include Mongoid::Timestamps
|
9
|
-
include Arkaan::Concerns::Activable
|
10
|
-
include Arkaan::Concerns::Diagnosticable
|
11
|
-
|
12
|
-
# @!attribute [rw] url
|
13
|
-
# @return [String] the URL of the websocket to be contacted on.
|
14
|
-
field :url, type: String
|
15
|
-
|
16
|
-
# @!attribute [rw] creator
|
17
|
-
# @return [Arkaan::Account] the account that created this web socket instance in the database.
|
18
|
-
belongs_to :creator, class_name: 'Arkaan::Account', inverse_of: :web_sockets, optional: true
|
19
|
-
|
20
|
-
validates :url,
|
21
|
-
presence: {message: 'required'},
|
22
|
-
format: {with: /\A(ws:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?\z/, message: 'pattern', if: :url?}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|