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
4fa3aba0
Commit
4fa3aba0
authored
Jul 05, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of DeleteAllEtcdKeys
parent
5e7c309b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
44 deletions
+17
-44
log.go
pkg/httplog/log.go
+1
-1
controller.go
pkg/master/controller.go
+9
-1
client_test.go
test/integration/client_test.go
+4
-5
etcd_utils.go
test/integration/framework/etcd_utils.go
+0
-18
master_utils.go
test/integration/framework/master_utils.go
+0
-5
master_test.go
test/integration/master_test.go
+2
-13
metrics_test.go
test/integration/metrics_test.go
+1
-1
No files found.
pkg/httplog/log.go
View file @
4fa3aba0
...
...
@@ -71,7 +71,7 @@ type passthroughLogger struct{}
// Addf logs info immediately.
func
(
passthroughLogger
)
Addf
(
format
string
,
data
...
interface
{})
{
glog
.
InfoDepth
(
1
,
fmt
.
Sprintf
(
format
,
data
...
))
glog
.
V
(
2
)
.
Info
(
fmt
.
Sprintf
(
format
,
data
...
))
}
// DefaultStacktracePred is the default implementation of StacktracePred.
...
...
pkg/master/controller.go
View file @
4fa3aba0
...
...
@@ -294,6 +294,14 @@ func (r *masterCountEndpointReconciler) ReconcileEndpoints(serviceName string, i
},
}
}
if
errors
.
IsNotFound
(
err
)
{
// Simply create non-existing endpoints for the service.
e
.
Subsets
=
[]
api
.
EndpointSubset
{{
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
ip
.
String
()}},
Ports
:
endpointPorts
,
}}
return
r
.
endpointRegistry
.
UpdateEndpoints
(
ctx
,
e
)
}
// First, determine if the endpoint is in the format we expect (one
// subset, ports matching endpointPorts, N IP addresses).
...
...
@@ -304,7 +312,7 @@ func (r *masterCountEndpointReconciler) ReconcileEndpoints(serviceName string, i
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
ip
.
String
()}},
Ports
:
endpointPorts
,
}}
glog
.
Warningf
(
"Resetting endpoints for master service %q to %v"
,
serviceName
,
e
)
glog
.
Warningf
(
"Resetting endpoints for master service %q to %
#
v"
,
serviceName
,
e
)
return
r
.
endpointRegistry
.
UpdateEndpoints
(
ctx
,
e
)
}
if
ipCorrect
&&
portsCorrect
{
...
...
test/integration/client_test.go
View file @
4fa3aba0
...
...
@@ -791,14 +791,13 @@ func runSelfLinkTestOnNamespace(t *testing.T, c *client.Client, namespace string
}
func
TestSelfLinkOnNamespace
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
_
,
s
:=
framework
.
RunAMaster
(
nil
)
defer
s
.
Close
()
ns
:=
framework
.
CreateTestingNamespace
(
"selflink"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
c
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
runSelfLinkTestOnNamespace
(
t
,
c
,
api
.
NamespaceDefault
)
runSelfLinkTestOnNamespace
(
t
,
c
,
"other-namespace"
)
runSelfLinkTestOnNamespace
(
t
,
c
,
ns
.
Name
)
}
test/integration/framework/etcd_utils.go
View file @
4fa3aba0
...
...
@@ -62,21 +62,3 @@ func WithEtcdKey(f func(string)) {
defer
etcd
.
NewKeysAPI
(
NewEtcdClient
())
.
Delete
(
context
.
TODO
(),
prefix
,
&
etcd
.
DeleteOptions
{
Recursive
:
true
})
f
(
prefix
)
}
// DeleteAllEtcdKeys deletes all keys from etcd.
// TODO: Instead of sprinkling calls to this throughout the code, adjust the
// prefix in etcdtest package; then just delete everything once at the end
// of the test run.
func
DeleteAllEtcdKeys
()
{
glog
.
Infof
(
"Deleting all etcd keys"
)
keysAPI
:=
etcd
.
NewKeysAPI
(
NewEtcdClient
())
keys
,
err
:=
keysAPI
.
Get
(
context
.
TODO
(),
"/"
,
nil
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Unable to list root etcd keys: %v"
,
err
)
}
for
_
,
node
:=
range
keys
.
Node
.
Nodes
{
if
_
,
err
:=
keysAPI
.
Delete
(
context
.
TODO
(),
node
.
Key
,
&
etcd
.
DeleteOptions
{
Recursive
:
true
});
err
!=
nil
{
glog
.
Fatalf
(
"Unable delete key: %v"
,
err
)
}
}
}
test/integration/framework/master_utils.go
View file @
4fa3aba0
...
...
@@ -91,8 +91,6 @@ type Config struct {
// If nil, a default is used, partially filled configs will not get populated.
MasterConfig
*
master
.
Config
StartReplicationManager
bool
// If true, all existing etcd keys are purged before starting master components
DeleteEtcdKeys
bool
// Client throttling qps
QPS
float32
// Client burst qps, also burst replicas allowed in rc manager
...
...
@@ -105,9 +103,6 @@ func NewMasterComponents(c *Config) *MasterComponents {
m
,
s
:=
startMasterOrDie
(
c
.
MasterConfig
)
// TODO: Allow callers to pipe through a different master url and create a client/start components using it.
glog
.
Infof
(
"Master %+v"
,
s
.
URL
)
if
c
.
DeleteEtcdKeys
{
DeleteAllEtcdKeys
()
}
// TODO: caesarxuchao: remove this client when the refactoring of client libraray is done.
restClient
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()},
QPS
:
c
.
QPS
,
Burst
:
c
.
Burst
})
clientset
:=
clientset
.
NewForConfigOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()},
QPS
:
c
.
QPS
,
Burst
:
c
.
Burst
})
...
...
test/integration/master_test.go
View file @
4fa3aba0
...
...
@@ -24,7 +24,6 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
...
...
@@ -36,7 +35,6 @@ import (
"k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/pkg/client/restclient"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/integration/framework"
)
...
...
@@ -392,21 +390,12 @@ func countEndpoints(eps *api.Endpoints) int {
}
func
TestMasterService
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
m
,
err
:=
master
.
New
(
framework
.
NewIntegrationTestMasterConfig
())
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
framework
.
NewIntegrationTestMasterConfig
())
defer
s
.
Close
()
client
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
err
=
wait
.
Poll
(
time
.
Second
,
time
.
Minute
,
func
()
(
bool
,
error
)
{
err
:
=
wait
.
Poll
(
time
.
Second
,
time
.
Minute
,
func
()
(
bool
,
error
)
{
svcList
,
err
:=
client
.
Services
(
api
.
NamespaceDefault
)
.
List
(
api
.
ListOptions
{})
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
...
test/integration/metrics_test.go
View file @
4fa3aba0
...
...
@@ -67,7 +67,7 @@ func scrapeMetrics(s *httptest.Server) ([]*prometheuspb.MetricFamily, error) {
if
err
:=
proto
.
UnmarshalText
(
scanner
.
Text
(),
&
metric
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to unmarshal line of metrics response: %v"
,
err
)
}
glog
.
Infof
(
"Got metric %q"
,
metric
.
GetName
())
glog
.
V
(
4
)
.
Infof
(
"Got metric %q"
,
metric
.
GetName
())
metrics
=
append
(
metrics
,
&
metric
)
}
return
metrics
,
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