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
0baae91a
Commit
0baae91a
authored
8 years ago
by
Murat Kabilov
Browse files
Options
Downloads
Patches
Plain Diff
pass error from process event function to the PopProcessFunc func
parent
8f5a8e21
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/controller/postgresql.go
+21
-12
21 additions, 12 deletions
pkg/controller/postgresql.go
with
21 additions
and
12 deletions
pkg/controller/postgresql.go
+
21
−
12
View file @
0baae91a
...
...
@@ -74,7 +74,7 @@ func (c *Controller) clusterWatchFunc(options api.ListOptions) (watch.Interface,
return
req
.
Watch
()
}
func
(
c
*
Controller
)
processAddEvent
(
workerID
uint32
,
clusterName
spec
.
NamespacedName
,
spec
*
spec
.
Postgresql
)
{
func
(
c
*
Controller
)
processAddEvent
(
workerID
uint32
,
clusterName
spec
.
NamespacedName
,
spec
*
spec
.
Postgresql
)
error
{
log
:=
c
.
logger
.
WithField
(
"worker"
,
workerID
)
log
.
Infof
(
"Creation of the '%s' cluster started"
,
clusterName
)
...
...
@@ -92,13 +92,14 @@ func (c *Controller) processAddEvent(workerID uint32, clusterName spec.Namespace
cl
.
Error
=
fmt
.
Errorf
(
"could not create cluster: %v"
,
err
)
log
.
Errorf
(
"%v"
,
cl
.
Error
)
return
return
nil
}
log
.
Infof
(
"Cluster '%s' has been created"
,
clusterName
)
return
nil
}
func
(
c
*
Controller
)
processUpdateEvent
(
workerID
uint32
,
clusterName
spec
.
NamespacedName
,
cl
*
cluster
.
Cluster
,
newSpec
*
spec
.
Postgresql
)
{
func
(
c
*
Controller
)
processUpdateEvent
(
workerID
uint32
,
clusterName
spec
.
NamespacedName
,
cl
*
cluster
.
Cluster
,
newSpec
*
spec
.
Postgresql
)
error
{
log
:=
c
.
logger
.
WithField
(
"worker"
,
workerID
)
log
.
Infof
(
"Update of the '%s' cluster started"
,
clusterName
)
...
...
@@ -107,14 +108,16 @@ func (c *Controller) processUpdateEvent(workerID uint32, clusterName spec.Namesp
cl
.
Error
=
fmt
.
Errorf
(
"could not update cluster: %s"
,
err
)
log
.
Errorf
(
"%v"
,
cl
.
Error
)
return
return
nil
}
cl
.
Error
=
nil
log
.
Infof
(
"Cluster '%s' has been updated"
,
clusterName
)
return
nil
}
func
(
c
*
Controller
)
processDeleteEvent
(
workerID
uint32
,
clusterName
spec
.
NamespacedName
,
cl
*
cluster
.
Cluster
)
{
func
(
c
*
Controller
)
processDeleteEvent
(
workerID
uint32
,
clusterName
spec
.
NamespacedName
,
cl
*
cluster
.
Cluster
)
error
{
log
:=
c
.
logger
.
WithField
(
"worker"
,
workerID
)
log
.
Infof
(
"Deletion of the '%s' cluster started"
,
clusterName
)
...
...
@@ -122,7 +125,7 @@ func (c *Controller) processDeleteEvent(workerID uint32, clusterName spec.Namesp
if
err
:=
cl
.
Delete
();
err
!=
nil
{
log
.
Errorf
(
"could not delete cluster '%s': %s"
,
clusterName
,
err
)
return
return
nil
}
close
(
c
.
stopChs
[
clusterName
])
...
...
@@ -132,9 +135,11 @@ func (c *Controller) processDeleteEvent(workerID uint32, clusterName spec.Namesp
c
.
clustersMu
.
Unlock
()
log
.
Infof
(
"Cluster '%s' has been deleted"
,
clusterName
)
return
nil
}
func
(
c
*
Controller
)
processSyncEvent
(
workerID
uint32
,
cl
*
cluster
.
Cluster
,
clusterFound
bool
,
clusterName
spec
.
NamespacedName
,
newSpec
*
spec
.
Postgresql
)
{
func
(
c
*
Controller
)
processSyncEvent
(
workerID
uint32
,
cl
*
cluster
.
Cluster
,
clusterFound
bool
,
clusterName
spec
.
NamespacedName
,
newSpec
*
spec
.
Postgresql
)
error
{
log
:=
c
.
logger
.
WithField
(
"worker"
,
workerID
)
log
.
Infof
(
"Syncing of the '%s' cluster started"
,
clusterName
)
...
...
@@ -155,11 +160,13 @@ func (c *Controller) processSyncEvent(workerID uint32, cl *cluster.Cluster, clus
cl
.
Error
=
fmt
.
Errorf
(
"could not sync cluster '%s': %s"
,
clusterName
,
err
)
log
.
Errorf
(
"%v"
,
cl
)
return
return
nil
}
cl
.
Error
=
nil
log
.
Infof
(
"Cluster '%s' has been synced"
,
clusterName
)
return
nil
}
func
(
c
*
Controller
)
processEvent
(
obj
interface
{})
error
{
...
...
@@ -188,25 +195,27 @@ func (c *Controller) processEvent(obj interface{}) error {
return
nil
}
c
.
processAddEvent
(
event
.
WorkerID
,
clusterName
,
event
.
NewSpec
)
return
c
.
processAddEvent
(
event
.
WorkerID
,
clusterName
,
event
.
NewSpec
)
case
spec
.
EventUpdate
:
if
!
clusterFound
{
log
.
Warnf
(
"Cluster '%s' does not exist"
,
clusterName
)
return
nil
}
c
.
processUpdateEvent
(
event
.
WorkerID
,
clusterName
,
cl
,
event
.
NewSpec
)
return
c
.
processUpdateEvent
(
event
.
WorkerID
,
clusterName
,
cl
,
event
.
NewSpec
)
case
spec
.
EventDelete
:
if
!
clusterFound
{
log
.
Errorf
(
"Unknown cluster: %s"
,
clusterName
)
return
nil
}
c
.
processDeleteEvent
(
event
.
WorkerID
,
clusterName
,
cl
)
return
c
.
processDeleteEvent
(
event
.
WorkerID
,
clusterName
,
cl
)
case
spec
.
EventSync
:
c
.
processSyncEvent
(
event
.
WorkerID
,
cl
,
clusterFound
,
clusterName
,
event
.
NewSpec
)
return
c
.
processSyncEvent
(
event
.
WorkerID
,
cl
,
clusterFound
,
clusterName
,
event
.
NewSpec
)
}
c
.
logger
.
Errorf
(
"unknown event type: %v"
,
event
.
EventType
)
return
nil
}
...
...
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