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
fac6318c
Commit
fac6318c
authored
Aug 29, 2016
by
Quinton Hoole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Federated Ingress: unify UID's across Cluster Ingress Controllers
Fixes #31180
parent
ac8aae58
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
52 deletions
+27
-52
ingress_controller.go
...n/pkg/federation-controller/ingress/ingress_controller.go
+0
-0
ingress_controller_test.go
.../federation-controller/ingress/ingress_controller_test.go
+0
-0
delaying_deliverer.go
...tion/pkg/federation-controller/util/delaying_deliverer.go
+1
-1
federated_informer.go
...tion/pkg/federation-controller/util/federated_informer.go
+17
-6
test_helper.go
...ration/pkg/federation-controller/util/test/test_helper.go
+6
-2
util.go
federation/pkg/federation-controller/util/util.go
+0
-43
watch.go
pkg/watch/watch.go
+3
-0
No files found.
federation/pkg/federation-controller/ingress/ingress_controller.go
View file @
fac6318c
This diff is collapsed.
Click to expand it.
federation/pkg/federation-controller/ingress/ingress_controller_test.go
View file @
fac6318c
This diff is collapsed.
Click to expand it.
federation/pkg/federation-controller/util/delaying_deliverer.go
View file @
fac6318c
...
...
@@ -162,7 +162,7 @@ func (d *DelayingDeliverer) DeliverAfter(key string, value interface{}, delay ti
d
.
DeliverAt
(
key
,
value
,
time
.
Now
()
.
Add
(
delay
))
}
// Gets target chanel of the deliverer.
// Gets target chan
n
el of the deliverer.
func
(
d
*
DelayingDeliverer
)
GetTargetChannel
()
chan
*
DelayingDelivererItem
{
return
d
.
targetChannel
}
...
...
federation/pkg/federation-controller/util/federated_informer.go
View file @
fac6318c
...
...
@@ -85,9 +85,9 @@ type FederationView interface {
ClustersSynced
()
bool
}
// A structure that combines an informer running agains federated api server and listening for cluster updates
// A structure that combines an informer running agains
t
federated api server and listening for cluster updates
// with multiple Kubernetes API informers (called target informers) running against federation members. Whenever a new
// cluster is added to the federation an informer is created for it using TargetInformerFactory. Info
mrers are sto
ped
// cluster is added to the federation an informer is created for it using TargetInformerFactory. Info
rmers are stop
ped
// when a cluster is either put offline of deleted. It is assumed that some controller keeps an eye on the cluster list
// and thus the clusters in ETCD are up to date.
type
FederatedInformer
interface
{
...
...
@@ -186,18 +186,22 @@ func NewFederatedInformer(
if
clusterLifecycle
.
ClusterAvailable
!=
nil
{
clusterLifecycle
.
ClusterAvailable
(
curCluster
)
}
}
else
{
glog
.
Errorf
(
"Cluster %v not added. Not of correct type, or cluster not ready."
,
cur
)
}
},
UpdateFunc
:
func
(
old
,
cur
interface
{})
{
oldCluster
,
ok
:=
old
.
(
*
federation_api
.
Cluster
)
if
!
ok
{
glog
.
Errorf
(
"Internal error: Cluster %v not updated. Old cluster not of correct type."
,
old
)
return
}
curCluster
,
ok
:=
cur
.
(
*
federation_api
.
Cluster
)
if
!
ok
{
glog
.
Errorf
(
"Internal error: Cluster %v not updated. New cluster not of correct type."
,
cur
)
return
}
if
isClusterReady
(
oldCluster
)
!=
isClusterReady
(
curCluster
)
||
!
reflect
.
DeepEqual
(
oldCluster
.
Spec
,
curCluster
.
Spec
)
{
if
isClusterReady
(
oldCluster
)
!=
isClusterReady
(
curCluster
)
||
!
reflect
.
DeepEqual
(
oldCluster
.
Spec
,
curCluster
.
Spec
)
||
!
reflect
.
DeepEqual
(
oldCluster
.
ObjectMeta
.
Annotations
,
curCluster
.
ObjectMeta
.
Annotations
)
{
var
data
[]
interface
{}
if
clusterLifecycle
.
ClusterUnavailable
!=
nil
{
data
=
getClusterData
(
oldCluster
.
Name
)
...
...
@@ -213,6 +217,8 @@ func NewFederatedInformer(
clusterLifecycle
.
ClusterAvailable
(
curCluster
)
}
}
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Cluster %v not updated to %v as ready status and specs are identical"
,
oldCluster
,
curCluster
)
}
},
},
...
...
@@ -258,11 +264,14 @@ type federatedStoreImpl struct {
}
func
(
f
*
federatedInformerImpl
)
Stop
()
{
glog
.
V
(
4
)
.
Infof
(
"Stopping federated informer."
)
f
.
Lock
()
defer
f
.
Unlock
()
glog
.
V
(
4
)
.
Infof
(
"... Closing cluster informer channel."
)
close
(
f
.
clusterInformer
.
stopChan
)
for
_
,
informer
:=
range
f
.
targetInformers
{
for
key
,
informer
:=
range
f
.
targetInformers
{
glog
.
V
(
4
)
.
Infof
(
"... Closing informer channel for %q."
,
key
)
close
(
informer
.
stopChan
)
}
}
...
...
@@ -291,14 +300,16 @@ func (f *federatedInformerImpl) GetClientsetForCluster(clusterName string) (kube
func
(
f
*
federatedInformerImpl
)
getClientsetForClusterUnlocked
(
clusterName
string
)
(
kube_release_1_4
.
Interface
,
error
)
{
// No locking needed. Will happen in f.GetCluster.
glog
.
V
(
4
)
.
Infof
(
"Getting clientset for cluster %q"
,
clusterName
)
if
cluster
,
found
,
err
:=
f
.
getReadyClusterUnlocked
(
clusterName
);
found
&&
err
==
nil
{
glog
.
V
(
4
)
.
Infof
(
"Got clientset for cluster %q"
,
clusterName
)
return
f
.
clientFactory
(
cluster
)
}
else
{
if
err
!=
nil
{
return
nil
,
err
}
}
return
nil
,
fmt
.
Errorf
(
"cluster %
s
not found"
,
clusterName
)
return
nil
,
fmt
.
Errorf
(
"cluster %
q
not found"
,
clusterName
)
}
// GetReadyClusers returns all clusters for which the sub-informers are run.
...
...
@@ -441,7 +452,7 @@ func (fs *federatedStoreImpl) GetFromAllClusters(key string) ([]FederatedObject,
return
result
,
nil
}
// GetKey
f
or returns the key under which the item would be put in the store.
// GetKey
F
or returns the key under which the item would be put in the store.
func
(
fs
*
federatedStoreImpl
)
GetKeyFor
(
item
interface
{})
string
{
// TODO: support other keying functions.
key
,
_
:=
framework
.
DeletionHandlingMetaNamespaceKeyFunc
(
item
)
...
...
federation/pkg/federation-controller/util/test/test_helper.go
View file @
fac6318c
...
...
@@ -64,10 +64,14 @@ func (wd *WatcherDispatcher) Add(obj runtime.Object) {
func
(
wd
*
WatcherDispatcher
)
Modify
(
obj
runtime
.
Object
)
{
wd
.
Lock
()
defer
wd
.
Unlock
()
glog
.
V
(
4
)
.
Infof
(
"->WatcherDispatcher.Modify(%v)"
,
obj
)
wd
.
eventsSoFar
=
append
(
wd
.
eventsSoFar
,
&
watch
.
Event
{
Type
:
watch
.
Modified
,
Object
:
obj
})
for
_
,
watcher
:=
range
wd
.
watchers
{
for
i
,
watcher
:=
range
wd
.
watchers
{
if
!
watcher
.
IsStopped
()
{
glog
.
V
(
4
)
.
Infof
(
"->Watcher(%d).Modify(%v)"
,
i
,
obj
)
watcher
.
Modify
(
obj
)
}
else
{
glog
.
V
(
4
)
.
Infof
(
"->Watcher(%d) is stopped. Not calling Modify(%v)"
,
i
,
obj
)
}
}
}
...
...
@@ -173,7 +177,7 @@ func GetObjectFromChan(c chan runtime.Object) runtime.Object {
select
{
case
obj
:=
<-
c
:
return
obj
case
<-
time
.
After
(
1
0
*
time
.
Second
)
:
case
<-
time
.
After
(
2
0
*
time
.
Second
)
:
pprof
.
Lookup
(
"goroutine"
)
.
WriteTo
(
os
.
Stderr
,
1
)
return
nil
}
...
...
federation/pkg/federation-controller/util/util.go
deleted
100644 → 0
View file @
ac8aae58
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
util
import
(
"reflect"
"k8s.io/kubernetes/pkg/api/v1"
)
/*
ObjectMetaIsEquivalent determines whether two ObjectMeta's (typically one from a federated API object,
and the other from a cluster object) are equivalent.
*/
func
ObjectMetaIsEquivalent
(
m1
,
m2
v1
.
ObjectMeta
)
bool
{
// First make all of the read-only fields equal, then perform a deep equality comparison
m1
.
SelfLink
=
m2
.
SelfLink
// Might be different in different cluster contexts.
m1
.
UID
=
m2
.
UID
// Definitely different in different cluster contexts
m1
.
ResourceVersion
=
m2
.
ResourceVersion
// Definitely different in different cluster contexts
m1
.
Generation
=
m2
.
Generation
// Might be different in different cluster contexts.
m1
.
CreationTimestamp
=
m2
.
CreationTimestamp
// Definitely different in different cluster contexts.
m1
.
DeletionTimestamp
=
m2
.
DeletionTimestamp
// Might be different in different cluster contexts.
m1
.
OwnerReferences
=
nil
// Might be different in different cluster contexts.
m2
.
OwnerReferences
=
nil
m1
.
Finalizers
=
nil
// Might be different in different cluster contexts.
m2
.
Finalizers
=
nil
return
reflect
.
DeepEqual
(
m1
,
m2
)
}
pkg/watch/watch.go
View file @
fac6318c
...
...
@@ -20,6 +20,8 @@ import (
"sync"
"k8s.io/kubernetes/pkg/runtime"
"github.com/golang/glog"
)
// Interface can be implemented by anything that knows how to watch and report changes.
...
...
@@ -100,6 +102,7 @@ func (f *FakeWatcher) Stop() {
f
.
Lock
()
defer
f
.
Unlock
()
if
!
f
.
Stopped
{
glog
.
V
(
4
)
.
Infof
(
"Stopping fake watcher."
)
close
(
f
.
result
)
f
.
Stopped
=
true
}
...
...
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