Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
postgres-operator
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
zalando
postgres-operator
Commits
1a4cff65
Commit
1a4cff65
authored
8 years ago
by
Murat Kabilov
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into feature/diagnostic-rest-api
# Conflicts: # pkg/controller/controller.go
parents
ed0db719
2fe22ff6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/controller/controller.go
+2
-3
2 additions, 3 deletions
pkg/controller/controller.go
pkg/controller/pod.go
+13
-29
13 additions, 29 deletions
pkg/controller/pod.go
pkg/spec/types.go
+0
-1
0 additions, 1 deletion
pkg/spec/types.go
with
15 additions
and
33 deletions
pkg/controller/controller.go
+
2
−
3
View file @
1a4cff65
...
...
@@ -175,10 +175,9 @@ func (c *Controller) initController() {
func
(
c
*
Controller
)
Run
(
stopCh
<-
chan
struct
{},
wg
*
sync
.
WaitGroup
)
{
c
.
initController
()
wg
.
Add
(
5
)
wg
.
Add
(
4
)
go
c
.
runPodInformer
(
stopCh
,
wg
)
go
c
.
runPostgresqlInformer
(
stopCh
,
wg
)
go
c
.
podEventsDispatcher
(
stopCh
,
wg
)
go
c
.
clusterResync
(
stopCh
,
wg
)
go
c
.
apiserver
.
Run
(
stopCh
,
wg
)
...
...
This diff is collapsed.
Click to expand it.
pkg/controller/pod.go
+
13
−
29
View file @
1a4cff65
package
controller
import
(
"sync"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
...
...
@@ -42,6 +40,16 @@ func (c *Controller) podWatchFunc(options metav1.ListOptions) (watch.Interface,
return
c
.
KubeClient
.
Pods
(
c
.
opConfig
.
Namespace
)
.
Watch
(
opts
)
}
func
(
c
*
Controller
)
dispatchPodEvent
(
clusterName
spec
.
NamespacedName
,
event
spec
.
PodEvent
)
{
c
.
clustersMu
.
RLock
()
cluster
,
ok
:=
c
.
clusters
[
clusterName
]
c
.
clustersMu
.
RUnlock
()
if
ok
{
c
.
logger
.
Debugf
(
"Sending %q event of pod %q to the %q cluster channel"
,
event
.
EventType
,
event
.
PodName
,
clusterName
)
cluster
.
ReceivePodEvent
(
event
)
}
}
func
(
c
*
Controller
)
podAdd
(
obj
interface
{})
{
pod
,
ok
:=
obj
.
(
*
v1
.
Pod
)
if
!
ok
{
...
...
@@ -49,14 +57,13 @@ func (c *Controller) podAdd(obj interface{}) {
}
podEvent
:=
spec
.
PodEvent
{
ClusterName
:
c
.
podClusterName
(
pod
),
PodName
:
util
.
NameFromMeta
(
pod
.
ObjectMeta
),
CurPod
:
pod
,
EventType
:
spec
.
EventAdd
,
ResourceVersion
:
pod
.
ResourceVersion
,
}
c
.
podCh
<-
podEvent
c
.
dispatchPodEvent
(
c
.
podClusterName
(
pod
),
podEvent
)
}
func
(
c
*
Controller
)
podUpdate
(
prev
,
cur
interface
{})
{
...
...
@@ -71,7 +78,6 @@ func (c *Controller) podUpdate(prev, cur interface{}) {
}
podEvent
:=
spec
.
PodEvent
{
ClusterName
:
c
.
podClusterName
(
curPod
),
PodName
:
util
.
NameFromMeta
(
curPod
.
ObjectMeta
),
PrevPod
:
prevPod
,
CurPod
:
curPod
,
...
...
@@ -79,7 +85,7 @@ func (c *Controller) podUpdate(prev, cur interface{}) {
ResourceVersion
:
curPod
.
ResourceVersion
,
}
c
.
podCh
<-
podEvent
c
.
dispatchPodEvent
(
c
.
podClusterName
(
curPod
),
podEvent
)
}
func
(
c
*
Controller
)
podDelete
(
obj
interface
{})
{
...
...
@@ -89,33 +95,11 @@ func (c *Controller) podDelete(obj interface{}) {
}
podEvent
:=
spec
.
PodEvent
{
ClusterName
:
c
.
podClusterName
(
pod
),
PodName
:
util
.
NameFromMeta
(
pod
.
ObjectMeta
),
CurPod
:
pod
,
EventType
:
spec
.
EventDelete
,
ResourceVersion
:
pod
.
ResourceVersion
,
}
c
.
podCh
<-
podEvent
}
func
(
c
*
Controller
)
podEventsDispatcher
(
stopCh
<-
chan
struct
{},
wg
*
sync
.
WaitGroup
)
{
defer
wg
.
Done
()
c
.
logger
.
Debugln
(
"Watching all pod events"
)
for
{
select
{
case
event
:=
<-
c
.
podCh
:
c
.
clustersMu
.
RLock
()
cluster
,
ok
:=
c
.
clusters
[
event
.
ClusterName
]
c
.
clustersMu
.
RUnlock
()
if
ok
{
c
.
logger
.
Debugf
(
"Sending %q event of pod %q to the %q cluster channel"
,
event
.
EventType
,
event
.
PodName
,
event
.
ClusterName
)
cluster
.
ReceivePodEvent
(
event
)
}
case
<-
stopCh
:
return
}
}
c
.
dispatchPodEvent
(
c
.
podClusterName
(
pod
),
podEvent
)
}
This diff is collapsed.
Click to expand it.
pkg/spec/types.go
+
0
−
1
View file @
1a4cff65
...
...
@@ -43,7 +43,6 @@ const (
// PodEvent describes the event for a single Pod
type
PodEvent
struct
{
ResourceVersion
string
ClusterName
NamespacedName
PodName
NamespacedName
PrevPod
*
v1
.
Pod
CurPod
*
v1
.
Pod
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment