Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hepto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACIDES
Hepto
Commits
8a309c25
Commit
8a309c25
authored
2 years ago
by
kaiyou
Browse files
Options
Downloads
Patches
Plain Diff
Fix containerd shim startup and plugin management
parent
621d0cc5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/hepto.go
+32
-12
32 additions, 12 deletions
cmd/hepto.go
with
32 additions
and
12 deletions
cmd/hepto.go
+
32
−
12
View file @
8a309c25
...
...
@@ -2,18 +2,21 @@ package main
import
(
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"forge.tedomum.net/acides/hepto/hepto/cmd/hepto"
"forge.tedomum.net/acides/hepto/hepto/cmd/shim"
containerd
"github.com/containerd/containerd/cmd/containerd/command"
ctr
"github.com/containerd/containerd/cmd/ctr/app"
runc
"github.com/opencontainers/runc/cmd"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/runtime/v2/runc/manager"
_
"github.com/containerd/containerd/runtime/v2/runc/pause"
_
"github.com/containerd/containerd/runtime/v2/runc/task/plugin"
shimv2
"github.com/containerd/containerd/runtime/v2/shim"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
//hostlocal "github.com/containernetworking/plugins/plugins/ipam/host-local"
//"github.com/containernetworking/plugins/plugins/main/bridge"
...
...
@@ -24,6 +27,15 @@ import (
kubectl
"k8s.io/kubectl/pkg/cmd"
)
func
init
()
{
ioutil
.
WriteFile
(
"/dev/null"
,
[]
byte
(
fmt
.
Sprintf
(
"heptodebug... %v
\n
"
,
os
.
Args
)),
0
o644
)
}
var
shimPlugins
=
[]
string
{
"io.containerd.ttrpc.v1.pause"
,
"io.containerd.ttrpc.v1.task"
,
}
func
main
()
{
bin
:=
filepath
.
Base
(
os
.
Args
[
0
])
var
err
error
...
...
@@ -33,21 +45,30 @@ func main() {
// mount with very simple very formatted arguments in that order:
// mount -t tmpfs -o size=1234 /src /dst
err
=
unix
.
Mount
(
os
.
Args
[
5
],
os
.
Args
[
6
],
os
.
Args
[
2
],
0
,
os
.
Args
[
4
])
}
else
if
bin
==
"containerd"
{
}
else
if
bin
==
"containerd"
||
(
bin
==
"hepto"
&&
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"publish"
)
{
// Containerd is also available under hepto name, guess based on
// call arguments
// This is some of an edge case, where containerd uses os.Executable
// to get the current binary path (hence hepto single binary) then
// passes that path as -publish-binary to its shim for callback
err
=
containerd
.
App
()
.
Run
(
os
.
Args
)
}
else
if
bin
==
"containerd-shim"
{
// Run the containerd shim itself
// This is called by the shim client as the proper long-term shim
shim
.
ShimApp
()
}
else
if
bin
==
"containerd-shim-runc-v2"
||
(
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"-namespace"
)
{
// Run the containerd shim client
// This is called as a first stage shim by embedded containerd
}
else
if
bin
==
"containerd-shim-runc-v2"
||
(
bin
==
"hepto"
&&
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"-namespace"
)
{
// Run the containerd shim
// It is also available under hepto name, for similar reasons as
// containerd, hence the different guess condition
plugins
:=
plugin
.
Graph
(
func
(
*
plugin
.
Registration
)
bool
{
return
false
})
for
_
,
plug
:=
range
plugins
{
plug
.
Disable
=
true
for
_
,
uri
:=
range
shimPlugins
{
if
uri
==
plug
.
URI
()
{
plug
.
Disable
=
false
break
}
}
}
shimv2
.
RunManager
(
context
.
Background
(),
manager
.
NewShimManager
(
"io.containerd.runc.v2"
))
}
else
if
bin
==
"runc"
{
runc
.
Run
()
}
else
if
bin
==
"ctr"
{
// Run containerd cli client, for debugging purposes
err
=
ctr
.
New
()
.
Run
(
os
.
Args
)
...
...
@@ -55,8 +76,7 @@ func main() {
// Run kubectl client, for debugging purposes
err
=
kubectl
.
NewDefaultKubectlCommand
()
.
Execute
()
}
else
{
// If no hook ran a different command, simply
// run hepto
// If no hook ran a different command, simply run hepto
hepto
.
Execute
()
}
if
err
!=
nil
{
...
...
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