Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
19086425
Commit
19086425
authored
Jan 25, 2024
by
Brad Davidson
Committed by
Brad Davidson
Feb 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consistently handle component exit on shutdown
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
58575844
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
10 deletions
+52
-10
containerd.go
pkg/agent/containerd/containerd.go
+4
-2
cridockerd.go
pkg/agent/cridockerd/cridockerd.go
+7
-1
setup.go
pkg/agent/flannel/setup.go
+4
-1
embed.go
pkg/daemons/executor/embed.go
+37
-6
No files found.
pkg/agent/containerd/containerd.go
View file @
19086425
...
@@ -99,10 +99,12 @@ func Run(ctx context.Context, cfg *config.Node) error {
...
@@ -99,10 +99,12 @@ func Run(ctx context.Context, cfg *config.Node) error {
cmd
.
Env
=
append
(
env
,
cenv
...
)
cmd
.
Env
=
append
(
env
,
cenv
...
)
addDeathSig
(
cmd
)
addDeathSig
(
cmd
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
err
:=
cmd
.
Run
()
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Errorf
(
"containerd exited: %s"
,
err
)
logrus
.
Errorf
(
"containerd exited: %s"
,
err
)
}
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
os
.
Exit
(
0
)
}()
}()
if
err
:=
cri
.
WaitForService
(
ctx
,
cfg
.
Containerd
.
Address
,
"containerd"
);
err
!=
nil
{
if
err
:=
cri
.
WaitForService
(
ctx
,
cfg
.
Containerd
.
Address
,
"containerd"
);
err
!=
nil
{
...
...
pkg/agent/cridockerd/cridockerd.go
View file @
19086425
...
@@ -5,6 +5,7 @@ package cridockerd
...
@@ -5,6 +5,7 @@ package cridockerd
import
(
import
(
"context"
"context"
"errors"
"os"
"os"
"runtime/debug"
"runtime/debug"
"strings"
"strings"
...
@@ -37,7 +38,12 @@ func Run(ctx context.Context, cfg *config.Node) error {
...
@@ -37,7 +38,12 @@ func Run(ctx context.Context, cfg *config.Node) error {
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"cri-dockerd panic: %v"
,
err
)
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"cri-dockerd panic: %v"
,
err
)
}
}
}()
}()
logrus
.
Fatalf
(
"cri-dockerd exited: %v"
,
command
.
ExecuteContext
(
ctx
))
err
:=
command
.
ExecuteContext
(
ctx
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Errorf
(
"cri-dockerd exited: %v"
,
err
)
os
.
Exit
(
1
)
}
os
.
Exit
(
0
)
}()
}()
return
cri
.
WaitForService
(
ctx
,
cfg
.
CRIDockerd
.
Address
,
"cri-dockerd"
)
return
cri
.
WaitForService
(
ctx
,
cfg
.
CRIDockerd
.
Address
,
"cri-dockerd"
)
...
...
pkg/agent/flannel/setup.go
View file @
19086425
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"context"
"context"
"fmt"
"fmt"
"net"
"net"
"os"
"path/filepath"
"path/filepath"
goruntime
"runtime"
goruntime
"runtime"
"strings"
"strings"
...
@@ -76,8 +77,10 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes typedcorev1.NodeInt
...
@@ -76,8 +77,10 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes typedcorev1.NodeInt
go
func
()
{
go
func
()
{
err
:=
flannel
(
ctx
,
nodeConfig
.
FlannelIface
,
nodeConfig
.
FlannelConfFile
,
nodeConfig
.
AgentConfig
.
KubeConfigKubelet
,
nodeConfig
.
FlannelIPv6Masq
,
nodeConfig
.
MultiClusterCIDR
,
netMode
)
err
:=
flannel
(
ctx
,
nodeConfig
.
FlannelIface
,
nodeConfig
.
FlannelConfFile
,
nodeConfig
.
AgentConfig
.
KubeConfigKubelet
,
nodeConfig
.
FlannelIPv6Masq
,
nodeConfig
.
MultiClusterCIDR
,
netMode
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Fatalf
(
"flannel exited: %v"
,
err
)
logrus
.
Errorf
(
"flannel exited: %v"
,
err
)
os
.
Exit
(
1
)
}
}
os
.
Exit
(
0
)
}()
}()
return
nil
return
nil
...
...
pkg/daemons/executor/embed.go
View file @
19086425
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"context"
"context"
"flag"
"flag"
"net/http"
"net/http"
"os"
"runtime"
"runtime"
"runtime/debug"
"runtime/debug"
"strconv"
"strconv"
...
@@ -90,7 +91,12 @@ func (e *Embedded) Kubelet(ctx context.Context, args []string) error {
...
@@ -90,7 +91,12 @@ func (e *Embedded) Kubelet(ctx context.Context, args []string) error {
if
err
:=
util
.
WaitForAPIServerReady
(
ctx
,
e
.
nodeConfig
.
AgentConfig
.
KubeConfigKubelet
,
util
.
DefaultAPIServerReadyTimeout
);
err
!=
nil
{
if
err
:=
util
.
WaitForAPIServerReady
(
ctx
,
e
.
nodeConfig
.
AgentConfig
.
KubeConfigKubelet
,
util
.
DefaultAPIServerReadyTimeout
);
err
!=
nil
{
logrus
.
Fatalf
(
"Kubelet failed to wait for apiserver ready: %v"
,
err
)
logrus
.
Fatalf
(
"Kubelet failed to wait for apiserver ready: %v"
,
err
)
}
}
logrus
.
Fatalf
(
"kubelet exited: %v"
,
command
.
ExecuteContext
(
ctx
))
err
:=
command
.
ExecuteContext
(
ctx
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Errorf
(
"kubelet exited: %v"
,
err
)
os
.
Exit
(
1
)
}
os
.
Exit
(
0
)
}()
}()
return
nil
return
nil
...
@@ -106,7 +112,12 @@ func (e *Embedded) KubeProxy(ctx context.Context, args []string) error {
...
@@ -106,7 +112,12 @@ func (e *Embedded) KubeProxy(ctx context.Context, args []string) error {
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"kube-proxy panic: %v"
,
err
)
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"kube-proxy panic: %v"
,
err
)
}
}
}()
}()
logrus
.
Fatalf
(
"kube-proxy exited: %v"
,
command
.
ExecuteContext
(
ctx
))
err
:=
command
.
ExecuteContext
(
ctx
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Errorf
(
"kube-proxy exited: %v"
,
err
)
os
.
Exit
(
1
)
}
os
.
Exit
(
0
)
}()
}()
return
nil
return
nil
...
@@ -128,7 +139,12 @@ func (*Embedded) APIServer(ctx context.Context, etcdReady <-chan struct{}, args
...
@@ -128,7 +139,12 @@ func (*Embedded) APIServer(ctx context.Context, etcdReady <-chan struct{}, args
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"apiserver panic: %v"
,
err
)
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"apiserver panic: %v"
,
err
)
}
}
}()
}()
logrus
.
Fatalf
(
"apiserver exited: %v"
,
command
.
ExecuteContext
(
ctx
))
err
:=
command
.
ExecuteContext
(
ctx
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Errorf
(
"apiserver exited: %v"
,
err
)
os
.
Exit
(
1
)
}
os
.
Exit
(
0
)
}()
}()
return
nil
return
nil
...
@@ -157,7 +173,12 @@ func (e *Embedded) Scheduler(ctx context.Context, apiReady <-chan struct{}, args
...
@@ -157,7 +173,12 @@ func (e *Embedded) Scheduler(ctx context.Context, apiReady <-chan struct{}, args
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"scheduler panic: %v"
,
err
)
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"scheduler panic: %v"
,
err
)
}
}
}()
}()
logrus
.
Fatalf
(
"scheduler exited: %v"
,
command
.
ExecuteContext
(
ctx
))
err
:=
command
.
ExecuteContext
(
ctx
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Errorf
(
"scheduler exited: %v"
,
err
)
os
.
Exit
(
1
)
}
os
.
Exit
(
0
)
}()
}()
return
nil
return
nil
...
@@ -174,7 +195,12 @@ func (*Embedded) ControllerManager(ctx context.Context, apiReady <-chan struct{}
...
@@ -174,7 +195,12 @@ func (*Embedded) ControllerManager(ctx context.Context, apiReady <-chan struct{}
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"controller-manager panic: %v"
,
err
)
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"controller-manager panic: %v"
,
err
)
}
}
}()
}()
logrus
.
Fatalf
(
"controller-manager exited: %v"
,
command
.
ExecuteContext
(
ctx
))
err
:=
command
.
ExecuteContext
(
ctx
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Errorf
(
"controller-manager exited: %v"
,
err
)
os
.
Exit
(
1
)
}
os
.
Exit
(
0
)
}()
}()
return
nil
return
nil
...
@@ -215,7 +241,12 @@ func (*Embedded) CloudControllerManager(ctx context.Context, ccmRBACReady <-chan
...
@@ -215,7 +241,12 @@ func (*Embedded) CloudControllerManager(ctx context.Context, ccmRBACReady <-chan
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"cloud-controller-manager panic: %v"
,
err
)
logrus
.
WithField
(
"stack"
,
string
(
debug
.
Stack
()))
.
Fatalf
(
"cloud-controller-manager panic: %v"
,
err
)
}
}
}()
}()
logrus
.
Errorf
(
"cloud-controller-manager exited: %v"
,
command
.
ExecuteContext
(
ctx
))
err
:=
command
.
ExecuteContext
(
ctx
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
context
.
Canceled
)
{
logrus
.
Errorf
(
"cloud-controller-manager exited: %v"
,
err
)
os
.
Exit
(
1
)
}
os
.
Exit
(
0
)
}()
}()
return
nil
return
nil
...
...
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