Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Ship Cat container manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wizards
Ship Cat container manager
Commits
04cf30b9
Commit
04cf30b9
authored
1 year ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Implement create_on_start
parent
90a71da1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
etc/container.toml.example
+11
-1
11 additions, 1 deletion
etc/container.toml.example
etc/shipcat.toml
+9
-3
9 additions, 3 deletions
etc/shipcat.toml
shipcat/config.py
+10
-3
10 additions, 3 deletions
shipcat/config.py
shipcat/main.py
+3
-0
3 additions, 0 deletions
shipcat/main.py
with
33 additions
and
7 deletions
etc/container.toml.example
+
11
−
1
View file @
04cf30b9
root_dir = "/tmp/root"
# Example configuration of a container
# Image to pull
image = "registry.ks.matfyz.cz/gimli/web-checker"
image = "registry.ks.matfyz.cz/gimli/web-checker"
# Root directory where data of the container reside
root_dir = "/tmp/root"
# Users and groups allowed to operate the container
allowed_users = ['root', 'mj']
allowed_users = ['root', 'mj']
allowed_groups = []
allowed_groups = []
# Do we re-create the container on every start?
create_on_start = false
This diff is collapsed.
Click to expand it.
etc/shipcat.toml
+
9
−
3
View file @
04cf30b9
...
@@ -3,8 +3,14 @@
...
@@ -3,8 +3,14 @@
# Where to find container configuration files
# Where to find container configuration files
container_config_dir
=
"/etc/shipcat/containers"
container_config_dir
=
"/etc/shipcat/containers"
# Where to find container roots (can be overridden by container's config)
container_root_dir
=
"/aux/containers"
# Overall verbosity
# Overall verbosity
verbosity
=
0
verbosity
=
0
# Default values of container configuration
[defaults]
# Where to find container root: root_dir/container_name
root_dir
=
"/aux/containers"
# Do we re-create the container on every start?
create_on_start
=
false
This diff is collapsed.
Click to expand it.
shipcat/config.py
+
10
−
3
View file @
04cf30b9
...
@@ -17,8 +17,9 @@ class ConfigError(RuntimeError):
...
@@ -17,8 +17,9 @@ class ConfigError(RuntimeError):
class
GlobalConfig
:
class
GlobalConfig
:
container_config_path
:
Path
container_config_path
:
Path
container_root_path
:
Path
verbosity
:
int
verbosity
:
int
default_root_path
:
Path
default_create_on_start
:
bool
@classmethod
@classmethod
def
load
(
self
,
filename
:
str
)
->
'
GlobalConfig
'
:
def
load
(
self
,
filename
:
str
)
->
'
GlobalConfig
'
:
...
@@ -41,9 +42,12 @@ class GlobalConfig:
...
@@ -41,9 +42,12 @@ class GlobalConfig:
def
parse
(
self
,
walker
:
Walker
)
->
None
:
def
parse
(
self
,
walker
:
Walker
)
->
None
:
with
walker
.
enter_object
()
as
w
:
with
walker
.
enter_object
()
as
w
:
self
.
container_config_path
=
Path
(
w
[
'
container_config_dir
'
].
as_str
())
self
.
container_config_path
=
Path
(
w
[
'
container_config_dir
'
].
as_str
())
self
.
container_root_path
=
Path
(
w
[
'
container_root_dir
'
].
as_str
())
self
.
verbosity
=
w
[
'
verbosity
'
].
as_int
(
0
)
self
.
verbosity
=
w
[
'
verbosity
'
].
as_int
(
0
)
with
w
[
'
defaults
'
].
enter_object
()
as
d
:
self
.
default_root_path
=
Path
(
d
[
'
root_dir
'
].
as_str
())
self
.
default_create_on_start
=
d
[
'
create_on_start
'
].
as_bool
(
False
)
class
ContainerConfig
:
class
ContainerConfig
:
name
:
str
name
:
str
...
@@ -52,6 +56,7 @@ class ContainerConfig:
...
@@ -52,6 +56,7 @@ class ContainerConfig:
image
:
str
image
:
str
allowed_users
:
Set
[
int
]
allowed_users
:
Set
[
int
]
allowed_groups
:
Set
[
int
]
allowed_groups
:
Set
[
int
]
create_on_start
:
bool
global_config
:
GlobalConfig
global_config
:
GlobalConfig
# Automatically generated
# Automatically generated
...
@@ -88,7 +93,7 @@ class ContainerConfig:
...
@@ -88,7 +93,7 @@ class ContainerConfig:
if
rd
.
is_present
():
if
rd
.
is_present
():
self
.
root_path
=
Path
(
rd
.
as_str
())
self
.
root_path
=
Path
(
rd
.
as_str
())
else
:
else
:
self
.
root_path
=
self
.
global_config
.
container
_root_path
/
self
.
name
self
.
root_path
=
self
.
global_config
.
default
_root_path
/
self
.
name
self
.
data_path
=
self
.
root_path
/
'
data
'
self
.
data_path
=
self
.
root_path
/
'
data
'
self
.
root_dir
=
w
[
'
root_dir
'
].
as_str
()
self
.
root_dir
=
w
[
'
root_dir
'
].
as_str
()
...
@@ -112,5 +117,7 @@ class ContainerConfig:
...
@@ -112,5 +117,7 @@ class ContainerConfig:
wu
.
raise_error
(
f
'
Unknown group
{
name
}
'
)
wu
.
raise_error
(
f
'
Unknown group
{
name
}
'
)
self
.
allowed_groups
.
add
(
grp
.
gr_gid
)
self
.
allowed_groups
.
add
(
grp
.
gr_gid
)
self
.
create_on_start
=
w
[
'
create_on_start
'
].
as_bool
(
self
.
global_config
.
default_create_on_start
)
self
.
pid_file
=
f
'
/run/shc/
{
self
.
name
}
.pid
'
self
.
pid_file
=
f
'
/run/shc/
{
self
.
name
}
.pid
'
self
.
user_name
=
self
.
name
self
.
user_name
=
self
.
name
This diff is collapsed.
Click to expand it.
shipcat/main.py
+
3
−
0
View file @
04cf30b9
...
@@ -312,6 +312,9 @@ def main_service_start():
...
@@ -312,6 +312,9 @@ def main_service_start():
pid_file
=
f
'
/run/shc/
{
cc
.
name
}
.pid
'
pid_file
=
f
'
/run/shc/
{
cc
.
name
}
.pid
'
Path
(
pid_file
).
unlink
(
missing_ok
=
True
)
Path
(
pid_file
).
unlink
(
missing_ok
=
True
)
if
cc
.
create_on_start
:
create_container
(
cc
)
run_command
([
'
podman
'
,
'
start
'
,
cc
.
name
])
run_command
([
'
podman
'
,
'
start
'
,
cc
.
name
])
...
...
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