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
7c2aeecd
Commit
7c2aeecd
authored
Oct 28, 2016
by
bprashanth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SetUp/TearDown II: remove code from kuberuntime
parent
70620790
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
80 deletions
+17
-80
kuberuntime_manager.go
pkg/kubelet/kuberuntime/kuberuntime_manager.go
+9
-61
kuberuntime_sandbox.go
pkg/kubelet/kuberuntime/kuberuntime_sandbox.go
+8
-19
No files found.
pkg/kubelet/kuberuntime/kuberuntime_manager.go
View file @
7c2aeecd
...
@@ -641,41 +641,16 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *api.Pod, _ api.PodStatus, podSt
...
@@ -641,41 +641,16 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *api.Pod, _ api.PodStatus, podSt
return
return
}
}
setupNetworkResult
:=
kubecontainer
.
NewSyncResult
(
kubecontainer
.
SetupNetwork
,
podSandboxID
)
podSandboxStatus
,
err
:=
m
.
runtimeService
.
PodSandboxStatus
(
podSandboxID
)
result
.
AddSyncResult
(
setupNetworkResult
)
if
err
!=
nil
{
if
!
kubecontainer
.
IsHostNetworkPod
(
pod
)
{
glog
.
Errorf
(
"Failed to get pod sandbox status: %v; Skipping pod %q"
,
err
,
format
.
Pod
(
pod
))
glog
.
V
(
3
)
.
Infof
(
"Calling network plugin %s to setup pod for %s"
,
m
.
networkPlugin
.
Name
(),
format
.
Pod
(
pod
))
result
.
Fail
(
err
)
// Setup pod network plugin with sandbox id
return
// TODO: rename the last param to sandboxID
err
=
m
.
networkPlugin
.
SetUpPod
(
pod
.
Namespace
,
pod
.
Name
,
kubecontainer
.
ContainerID
{
Type
:
m
.
runtimeName
,
ID
:
podSandboxID
,
})
if
err
!=
nil
{
message
:=
fmt
.
Sprintf
(
"Failed to setup network for pod %q using network plugins %q: %v"
,
format
.
Pod
(
pod
),
m
.
networkPlugin
.
Name
(),
err
)
setupNetworkResult
.
Fail
(
kubecontainer
.
ErrSetupNetwork
,
message
)
glog
.
Error
(
message
)
killPodSandboxResult
:=
kubecontainer
.
NewSyncResult
(
kubecontainer
.
KillPodSandbox
,
format
.
Pod
(
pod
))
result
.
AddSyncResult
(
killPodSandboxResult
)
if
err
:=
m
.
runtimeService
.
StopPodSandbox
(
podSandboxID
);
err
!=
nil
{
killPodSandboxResult
.
Fail
(
kubecontainer
.
ErrKillPodSandbox
,
err
.
Error
())
glog
.
Errorf
(
"Kill sandbox %q failed for pod %q: %v"
,
podSandboxID
,
format
.
Pod
(
pod
),
err
)
}
return
}
podSandboxStatus
,
err
:=
m
.
runtimeService
.
PodSandboxStatus
(
podSandboxID
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to get pod sandbox status: %v; Skipping pod %q"
,
err
,
format
.
Pod
(
pod
))
result
.
Fail
(
err
)
return
}
// Overwrite the podIP passed in the pod status, since we just started the infra container.
podIP
=
m
.
determinePodSandboxIP
(
pod
.
Namespace
,
pod
.
Name
,
podSandboxStatus
)
glog
.
V
(
4
)
.
Infof
(
"Determined the ip %q for pod %q after sandbox changed"
,
podIP
,
format
.
Pod
(
pod
))
}
}
// Overwrite the podIP passed in the pod status, since we just started the pod sandbox.
podIP
=
m
.
determinePodSandboxIP
(
pod
.
Namespace
,
pod
.
Name
,
podSandboxStatus
)
glog
.
V
(
4
)
.
Infof
(
"Determined the ip %q for pod %q after sandbox changed"
,
podIP
,
format
.
Pod
(
pod
))
}
}
// Get podSandboxConfig for containers to start.
// Get podSandboxConfig for containers to start.
...
@@ -815,33 +790,6 @@ func (m *kubeGenericRuntimeManager) killPodWithSyncResult(pod *api.Pod, runningP
...
@@ -815,33 +790,6 @@ func (m *kubeGenericRuntimeManager) killPodWithSyncResult(pod *api.Pod, runningP
result
.
AddSyncResult
(
containerResult
)
result
.
AddSyncResult
(
containerResult
)
}
}
// Teardown network plugin
if
len
(
runningPod
.
Sandboxes
)
==
0
{
glog
.
V
(
4
)
.
Infof
(
"Can not find pod sandbox by UID %q, assuming already removed."
,
runningPod
.
ID
)
return
}
sandboxID
:=
runningPod
.
Sandboxes
[
0
]
.
ID
.
ID
isHostNetwork
,
err
:=
m
.
isHostNetwork
(
sandboxID
,
pod
)
if
err
!=
nil
{
result
.
Fail
(
err
)
return
}
if
!
isHostNetwork
{
teardownNetworkResult
:=
kubecontainer
.
NewSyncResult
(
kubecontainer
.
TeardownNetwork
,
runningPod
.
ID
)
result
.
AddSyncResult
(
teardownNetworkResult
)
// Tear down network plugin with sandbox id
if
err
:=
m
.
networkPlugin
.
TearDownPod
(
runningPod
.
Namespace
,
runningPod
.
Name
,
kubecontainer
.
ContainerID
{
Type
:
m
.
runtimeName
,
ID
:
sandboxID
,
});
err
!=
nil
{
message
:=
fmt
.
Sprintf
(
"Failed to teardown network for pod %s_%s(%s) using network plugins %q: %v"
,
runningPod
.
Name
,
runningPod
.
Namespace
,
runningPod
.
ID
,
m
.
networkPlugin
.
Name
(),
err
)
teardownNetworkResult
.
Fail
(
kubecontainer
.
ErrTeardownNetwork
,
message
)
glog
.
Error
(
message
)
}
}
// stop sandbox, the sandbox will be removed in GarbageCollect
// stop sandbox, the sandbox will be removed in GarbageCollect
killSandboxResult
:=
kubecontainer
.
NewSyncResult
(
kubecontainer
.
KillPodSandbox
,
runningPod
.
ID
)
killSandboxResult
:=
kubecontainer
.
NewSyncResult
(
kubecontainer
.
KillPodSandbox
,
runningPod
.
ID
)
result
.
AddSyncResult
(
killSandboxResult
)
result
.
AddSyncResult
(
killSandboxResult
)
...
...
pkg/kubelet/kuberuntime/kuberuntime_sandbox.go
View file @
7c2aeecd
...
@@ -18,13 +18,13 @@ package kuberuntime
...
@@ -18,13 +18,13 @@ package kuberuntime
import
(
import
(
"fmt"
"fmt"
"net"
"sort"
"sort"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
runtimeApi
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
runtimeApi
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/network"
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/kubelet/util/format"
)
)
...
@@ -180,27 +180,16 @@ func (m *kubeGenericRuntimeManager) getKubeletSandboxes(all bool) ([]*runtimeApi
...
@@ -180,27 +180,16 @@ func (m *kubeGenericRuntimeManager) getKubeletSandboxes(all bool) ([]*runtimeApi
}
}
// determinePodSandboxIP determines the IP address of the given pod sandbox.
// determinePodSandboxIP determines the IP address of the given pod sandbox.
// TODO: remove determinePodSandboxIP after networking is delegated to the container runtime.
func
(
m
*
kubeGenericRuntimeManager
)
determinePodSandboxIP
(
podNamespace
,
podName
string
,
podSandbox
*
runtimeApi
.
PodSandboxStatus
)
string
{
func
(
m
*
kubeGenericRuntimeManager
)
determinePodSandboxIP
(
podNamespace
,
podName
string
,
podSandbox
*
runtimeApi
.
PodSandboxStatus
)
string
{
ip
:=
""
if
podSandbox
.
Network
==
nil
{
glog
.
Warningf
(
"Pod Sandbox status doesn't have network information, cannot report IP"
)
if
podSandbox
.
Network
!=
nil
{
return
""
ip
=
podSandbox
.
Network
.
GetIp
()
}
}
ip
:=
podSandbox
.
Network
.
GetIp
()
if
m
.
networkPlugin
.
Name
()
!=
network
.
DefaultPluginName
{
if
net
.
ParseIP
(
ip
)
==
nil
{
// TODO: podInfraContainerID in GetPodNetworkStatus() interface should be renamed to sandboxID
glog
.
Warningf
(
"Pod Sandbox reported an unparseable IP %v"
,
ip
)
netStatus
,
err
:=
m
.
networkPlugin
.
GetPodNetworkStatus
(
podNamespace
,
podName
,
kubecontainer
.
ContainerID
{
return
""
Type
:
m
.
runtimeName
,
ID
:
podSandbox
.
GetId
(),
})
if
err
!=
nil
{
glog
.
Errorf
(
"NetworkPlugin %s failed on the status hook for pod '%s' - %v"
,
m
.
networkPlugin
.
Name
(),
kubecontainer
.
BuildPodFullName
(
podName
,
podNamespace
),
err
)
}
else
if
netStatus
!=
nil
{
ip
=
netStatus
.
IP
.
String
()
}
}
}
return
ip
return
ip
}
}
...
...
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