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
9ba74cb5
Unverified
Commit
9ba74cb5
authored
Oct 09, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69251 from yue9944882/bugfix/pass-handler-context-to-nodegetter
Pass server handler context to storage nodeGetter
parents
4ba5db08
3370907f
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
25 deletions
+16
-25
BUILD
pkg/kubelet/client/BUILD
+1
-4
kubelet_client.go
pkg/kubelet/client/kubelet_client.go
+8
-7
kubelet_client_test.go
pkg/kubelet/client/kubelet_client_test.go
+0
-5
BUILD
pkg/registry/core/node/storage/BUILD
+0
-1
storage.go
pkg/registry/core/node/storage/storage.go
+2
-3
strategy.go
pkg/registry/core/node/strategy.go
+1
-1
strategy.go
pkg/registry/core/pod/strategy.go
+3
-3
strategy_test.go
pkg/registry/core/pod/strategy_test.go
+1
-1
No files found.
pkg/kubelet/client/BUILD
View file @
9ba74cb5
...
@@ -26,10 +26,7 @@ go_test(
...
@@ -26,10 +26,7 @@ go_test(
srcs = ["kubelet_client_test.go"],
srcs = ["kubelet_client_test.go"],
data = ["//pkg/client/testdata"],
data = ["//pkg/client/testdata"],
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = ["//staging/src/k8s.io/client-go/rest:go_default_library"],
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library",
],
)
)
filegroup(
filegroup(
...
...
pkg/kubelet/client/kubelet_client.go
View file @
9ba74cb5
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
client
package
client
import
(
import
(
"context"
"net/http"
"net/http"
"strconv"
"strconv"
"time"
"time"
...
@@ -62,7 +63,7 @@ type ConnectionInfo struct {
...
@@ -62,7 +63,7 @@ type ConnectionInfo struct {
// ConnectionInfoGetter provides ConnectionInfo for the kubelet running on a named node
// ConnectionInfoGetter provides ConnectionInfo for the kubelet running on a named node
type
ConnectionInfoGetter
interface
{
type
ConnectionInfoGetter
interface
{
GetConnectionInfo
(
nodeName
types
.
NodeName
)
(
*
ConnectionInfo
,
error
)
GetConnectionInfo
(
ctx
context
.
Context
,
nodeName
types
.
NodeName
)
(
*
ConnectionInfo
,
error
)
}
}
func
MakeTransport
(
config
*
KubeletClientConfig
)
(
http
.
RoundTripper
,
error
)
{
func
MakeTransport
(
config
*
KubeletClientConfig
)
(
http
.
RoundTripper
,
error
)
{
...
@@ -103,14 +104,14 @@ func (c *KubeletClientConfig) transportConfig() *transport.Config {
...
@@ -103,14 +104,14 @@ func (c *KubeletClientConfig) transportConfig() *transport.Config {
// NodeGetter defines an interface for looking up a node by name
// NodeGetter defines an interface for looking up a node by name
type
NodeGetter
interface
{
type
NodeGetter
interface
{
Get
(
name
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Node
,
error
)
Get
(
ctx
context
.
Context
,
name
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Node
,
error
)
}
}
// NodeGetterFunc allows implementing NodeGetter with a function
// NodeGetterFunc allows implementing NodeGetter with a function
type
NodeGetterFunc
func
(
name
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Node
,
error
)
type
NodeGetterFunc
func
(
ctx
context
.
Context
,
name
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Node
,
error
)
func
(
f
NodeGetterFunc
)
Get
(
name
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Node
,
error
)
{
func
(
f
NodeGetterFunc
)
Get
(
ctx
context
.
Context
,
name
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Node
,
error
)
{
return
f
(
name
,
options
)
return
f
(
ctx
,
name
,
options
)
}
}
// NodeConnectionInfoGetter obtains connection info from the status of a Node API object
// NodeConnectionInfoGetter obtains connection info from the status of a Node API object
...
@@ -153,8 +154,8 @@ func NewNodeConnectionInfoGetter(nodes NodeGetter, config KubeletClientConfig) (
...
@@ -153,8 +154,8 @@ func NewNodeConnectionInfoGetter(nodes NodeGetter, config KubeletClientConfig) (
},
nil
},
nil
}
}
func
(
k
*
NodeConnectionInfoGetter
)
GetConnectionInfo
(
nodeName
types
.
NodeName
)
(
*
ConnectionInfo
,
error
)
{
func
(
k
*
NodeConnectionInfoGetter
)
GetConnectionInfo
(
ctx
context
.
Context
,
nodeName
types
.
NodeName
)
(
*
ConnectionInfo
,
error
)
{
node
,
err
:=
k
.
nodes
.
Get
(
string
(
nodeName
),
metav1
.
GetOptions
{})
node
,
err
:=
k
.
nodes
.
Get
(
ctx
,
string
(
nodeName
),
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/kubelet/client/kubelet_client_test.go
View file @
9ba74cb5
...
@@ -19,14 +19,9 @@ package client
...
@@ -19,14 +19,9 @@ package client
import
(
import
(
"testing"
"testing"
v1core
"k8s.io/client-go/kubernetes/typed/core/v1"
restclient
"k8s.io/client-go/rest"
restclient
"k8s.io/client-go/rest"
)
)
// Ensure a node client can be used as a NodeGetter.
// This allows anyone with a node client to easily construct a NewNodeConnectionInfoGetter.
var
_
=
NodeGetter
(
v1core
.
NodeInterface
(
nil
))
func
TestMakeTransportInvalid
(
t
*
testing
.
T
)
{
func
TestMakeTransportInvalid
(
t
*
testing
.
T
)
{
config
:=
&
KubeletClientConfig
{
config
:=
&
KubeletClientConfig
{
EnableHttps
:
true
,
EnableHttps
:
true
,
...
...
pkg/registry/core/node/storage/BUILD
View file @
9ba74cb5
...
@@ -41,7 +41,6 @@ go_library(
...
@@ -41,7 +41,6 @@ go_library(
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library",
...
...
pkg/registry/core/node/storage/storage.go
View file @
9ba74cb5
...
@@ -25,7 +25,6 @@ import (
...
@@ -25,7 +25,6 @@ import (
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
genericapirequest
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/generic"
genericregistry
"k8s.io/apiserver/pkg/registry/generic/registry"
genericregistry
"k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/registry/rest"
...
@@ -104,8 +103,8 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client
...
@@ -104,8 +103,8 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client
proxyREST
:=
&
noderest
.
ProxyREST
{
Store
:
store
,
ProxyTransport
:
proxyTransport
}
proxyREST
:=
&
noderest
.
ProxyREST
{
Store
:
store
,
ProxyTransport
:
proxyTransport
}
// Build a NodeGetter that looks up nodes using the REST handler
// Build a NodeGetter that looks up nodes using the REST handler
nodeGetter
:=
client
.
NodeGetterFunc
(
func
(
nodeName
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Node
,
error
)
{
nodeGetter
:=
client
.
NodeGetterFunc
(
func
(
ctx
context
.
Context
,
nodeName
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Node
,
error
)
{
obj
,
err
:=
nodeREST
.
Get
(
genericapirequest
.
NewContext
()
,
nodeName
,
&
options
)
obj
,
err
:=
nodeREST
.
Get
(
ctx
,
nodeName
,
&
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/registry/core/node/strategy.go
View file @
9ba74cb5
...
@@ -200,7 +200,7 @@ func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGet
...
@@ -200,7 +200,7 @@ func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGet
return
nil
,
nil
,
errors
.
NewBadRequest
(
fmt
.
Sprintf
(
"invalid node request %q"
,
id
))
return
nil
,
nil
,
errors
.
NewBadRequest
(
fmt
.
Sprintf
(
"invalid node request %q"
,
id
))
}
}
info
,
err
:=
connection
.
GetConnectionInfo
(
types
.
NodeName
(
name
))
info
,
err
:=
connection
.
GetConnectionInfo
(
ctx
,
types
.
NodeName
(
name
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
...
pkg/registry/core/pod/strategy.go
View file @
9ba74cb5
...
@@ -352,7 +352,7 @@ func LogLocation(
...
@@ -352,7 +352,7 @@ func LogLocation(
// If pod has not been assigned a host, return an empty location
// If pod has not been assigned a host, return an empty location
return
nil
,
nil
,
nil
return
nil
,
nil
,
nil
}
}
nodeInfo
,
err
:=
connInfo
.
GetConnectionInfo
(
nodeName
)
nodeInfo
,
err
:=
connInfo
.
GetConnectionInfo
(
ctx
,
nodeName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
@@ -511,7 +511,7 @@ func streamLocation(
...
@@ -511,7 +511,7 @@ func streamLocation(
// If pod has not been assigned a host, return an empty location
// If pod has not been assigned a host, return an empty location
return
nil
,
nil
,
errors
.
NewBadRequest
(
fmt
.
Sprintf
(
"pod %s does not have a host assigned"
,
name
))
return
nil
,
nil
,
errors
.
NewBadRequest
(
fmt
.
Sprintf
(
"pod %s does not have a host assigned"
,
name
))
}
}
nodeInfo
,
err
:=
connInfo
.
GetConnectionInfo
(
nodeName
)
nodeInfo
,
err
:=
connInfo
.
GetConnectionInfo
(
ctx
,
nodeName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
@@ -546,7 +546,7 @@ func PortForwardLocation(
...
@@ -546,7 +546,7 @@ func PortForwardLocation(
// If pod has not been assigned a host, return an empty location
// If pod has not been assigned a host, return an empty location
return
nil
,
nil
,
errors
.
NewBadRequest
(
fmt
.
Sprintf
(
"pod %s does not have a host assigned"
,
name
))
return
nil
,
nil
,
errors
.
NewBadRequest
(
fmt
.
Sprintf
(
"pod %s does not have a host assigned"
,
name
))
}
}
nodeInfo
,
err
:=
connInfo
.
GetConnectionInfo
(
nodeName
)
nodeInfo
,
err
:=
connInfo
.
GetConnectionInfo
(
ctx
,
nodeName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
...
pkg/registry/core/pod/strategy_test.go
View file @
9ba74cb5
...
@@ -395,7 +395,7 @@ type mockConnectionInfoGetter struct {
...
@@ -395,7 +395,7 @@ type mockConnectionInfoGetter struct {
info
*
client
.
ConnectionInfo
info
*
client
.
ConnectionInfo
}
}
func
(
g
mockConnectionInfoGetter
)
GetConnectionInfo
(
nodeName
types
.
NodeName
)
(
*
client
.
ConnectionInfo
,
error
)
{
func
(
g
mockConnectionInfoGetter
)
GetConnectionInfo
(
ctx
context
.
Context
,
nodeName
types
.
NodeName
)
(
*
client
.
ConnectionInfo
,
error
)
{
return
g
.
info
,
nil
return
g
.
info
,
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