Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
reference-repository
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
grid5000
reference-repository
Commits
87381f34
Commit
87381f34
authored
2 years ago
by
JACQUOT Pierre
Browse files
Options
Downloads
Patches
Plain Diff
Don't crash when kadeploy data is missing for clusters not in default or
production queues.
parent
52e5e37c
No related branches found
No related tags found
1 merge request
!494
Don't crash when kadeploy data is missing for clusters not in default or production queues.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/refrepo/gen/puppet/kadeployg5k.rb
+44
-36
44 additions, 36 deletions
lib/refrepo/gen/puppet/kadeployg5k.rb
with
44 additions
and
36 deletions
lib/refrepo/gen/puppet/kadeployg5k.rb
+
44
−
36
View file @
87381f34
...
@@ -53,6 +53,47 @@ def generate_puppet_kadeployg5k(options)
...
@@ -53,6 +53,47 @@ def generate_puppet_kadeployg5k(options)
next
unless
options
[
:sites
].
include?
(
site_uid
)
next
unless
options
[
:sites
].
include?
(
site_uid
)
#
# Generate <cluster_uid>-cluster.conf files
#
# Load 'conf/kadeployg5k.yaml' data and fill up the kadeployg5k.conf.erb template for each cluster
conf
=
YAML
::
load
(
ERB
.
new
(
File
.
read
(
"
#{
options
[
:conf_dir
]
}
/kadeployg5k
#{
suffix
}
.yaml"
)).
result
(
binding
))
no_config_clusters_uid
=
[]
site
[
'clusters'
].
each
{
|
cluster_uid
,
cluster
|
defaults
=
conf
[
'defaults'
]
overrides
=
conf
[
site_uid
][
cluster_uid
]
if
overrides
.
nil?
and
!
(
cluster
[
'queues'
].
include?
(
'default'
)
or
cluster
[
'queues'
].
include?
(
'production'
))
puts
"Warning:
#{
cluster_uid
}
has no kadeployg5k
#{
suffix
}
config, and isn't in default or production queue."
puts
"Warning: Skipping
#{
cluster_uid
}
configuration."
no_config_clusters_uid
<<
cluster_uid
next
end
dupes
=
(
defaults
.
to_a
&
overrides
.
to_a
)
key_dupes
=
(
defaults
.
to_a
.
map
(
&
:first
)
&
overrides
.
to_a
.
map
(
&
:first
))
if
not
dupes
.
empty?
puts
"Warning: Overriding default values
#{
dupes
}
by the same value for
#{
cluster_uid
}
"
end
if
not
key_dupes
.
empty?
puts
"Info: cluster-specific configuration for
#{
cluster_uid
}
overrides default values:
#{
key_dupes
}
"
end
data
=
defaults
.
merge
(
overrides
)
if
data
.
nil?
puts
"Warning: configuration not found in
#{
options
[
:conf_dir
]
}
/kadeployg5k
#{
suffix
}
.yaml for
#{
cluster_uid
}
. Skipped"
next
end
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kadeployg5k.conf.erb'
,
File
.
dirname
(
__FILE__
))),
trim_mode:
'-'
).
result
(
binding
)
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kadeploy/server
#{
suffix
.
tr
(
'-'
,
'_'
)
}
/
#{
site_uid
}
/
#{
cluster_uid
}
-cluster.conf"
)
output_file
.
dirname
.
mkpath
()
File
.
write
(
output_file
,
output
)
}
#
#
# Generate site/<site_uid>/servers_conf[_dev]/clusters.conf
# Generate site/<site_uid>/servers_conf[_dev]/clusters.conf
#
#
...
@@ -61,8 +102,9 @@ def generate_puppet_kadeployg5k(options)
...
@@ -61,8 +102,9 @@ def generate_puppet_kadeployg5k(options)
prefix
=
cluster_prefix
(
site
[
'clusters'
].
keys
)
prefix
=
cluster_prefix
(
site
[
'clusters'
].
keys
)
site
[
'clusters'
].
sort
.
each
{
|
cluster_uid
,
cluster
|
site
[
'clusters'
].
sort
.
each
{
|
cluster_uid
,
cluster
|
next
if
no_config_clusters_uid
.
include?
(
cluster_uid
)
# clusters:
# clusters:
# - name: griffon
# - name: griffon
# prefix: gri
# prefix: gri
# conf_file: /etc/kadeploy3/griffon-cluster.conf
# conf_file: /etc/kadeploy3/griffon-cluster.conf
...
@@ -126,40 +168,6 @@ def generate_puppet_kadeployg5k(options)
...
@@ -126,40 +168,6 @@ def generate_puppet_kadeployg5k(options)
write_yaml
(
output_file
,
clusters_conf
)
write_yaml
(
output_file
,
clusters_conf
)
add_header
(
output_file
)
add_header
(
output_file
)
#
# Generate <cluster_uid>-cluster.conf files
#
# Load 'conf/kadeployg5k.yaml' data and fill up the kadeployg5k.conf.erb template for each cluster
conf
=
YAML
::
load
(
ERB
.
new
(
File
.
read
(
"
#{
options
[
:conf_dir
]
}
/kadeployg5k
#{
suffix
}
.yaml"
)).
result
(
binding
))
site
[
'clusters'
].
each
{
|
cluster_uid
,
cluster
|
defaults
=
conf
[
'defaults'
]
overrides
=
conf
[
site_uid
][
cluster_uid
]
dupes
=
(
defaults
.
to_a
&
overrides
.
to_a
)
key_dupes
=
(
defaults
.
to_a
.
map
(
&
:first
)
&
overrides
.
to_a
.
map
(
&
:first
))
if
not
dupes
.
empty?
puts
"Warning: Overriding default values
#{
dupes
}
by the same value for
#{
cluster_uid
}
"
end
if
not
key_dupes
.
empty?
puts
"Info: cluster-specific configuration for
#{
cluster_uid
}
overrides default values:
#{
key_dupes
}
"
end
data
=
defaults
.
merge
(
overrides
)
if
data
.
nil?
puts
"Warning: configuration not found in
#{
options
[
:conf_dir
]
}
/kadeployg5k
#{
suffix
}
.yaml for
#{
cluster_uid
}
. Skipped"
next
end
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kadeployg5k.conf.erb'
,
File
.
dirname
(
__FILE__
))),
trim_mode:
'-'
).
result
(
binding
)
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kadeploy/server
#{
suffix
.
tr
(
'-'
,
'_'
)
}
/
#{
site_uid
}
/
#{
cluster_uid
}
-cluster.conf"
)
output_file
.
dirname
.
mkpath
()
File
.
write
(
output_file
,
output
)
}
}
}
}
}
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment