Skip to content

Commit 1a14928

Browse files
authored
Close the controller when state not synchronized (#49)
* Close the controller when state not synchronized * Bump version to v0.7.3
1 parent 9a8f0a4 commit 1a14928

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION_MAJOR ?= 0
22
VERSION_MINOR ?= 7
3-
VERSION_BUILD ?= 2
3+
VERSION_BUILD ?= 3
44
VERSION ?= v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD)
55

66
GOOS ?= $(shell go env GOOS)

cmd/main.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,27 +134,32 @@ func main() {
134134
active := false
135135
callbacks := &ha.Callbacks{
136136
OnActive: func(status *util.HighAvailability) {
137+
stateSync := status.Group.Local.StateSync
138+
syncEnabled := status.Group.RunningSyncEnabled
139+
runningSync := status.Group.RunningSync
137140
switch {
138-
case status.Group.Local.StateSync == "Complete":
139-
if status.Group.RunningSyncEnabled == "yes" && status.Group.RunningSync == "synchronized" {
140-
glog.V(3).Infof("PAN firewall on active, and synchronized.")
141-
if !active {
142-
if err := op.Run(ctx); err != nil {
143-
glog.Fatalf("Error to run the operator: %s.", err)
144-
}
145-
active = true
141+
case stateSync == "Complete" && syncEnabled == "yes" && runningSync == "synchronized":
142+
glog.V(3).Infof("PAN firewall on active, and synchronized.")
143+
if !active {
144+
if err := op.Run(ctx); err != nil {
145+
glog.Fatalf("Error to run the operator: %s.", err)
146146
}
147+
active = true
147148
}
148149
default:
149150
glog.V(3).Infof("PAN firewall on active, but not synchronized.")
151+
if active {
152+
op.Stop()
153+
glog.Fatalf("The active state lost and not synchronized, exiting...")
154+
}
150155
}
151156
},
152157
OnPassive: func() {
153158
glog.V(3).Infof("PAN firewall on passive.")
154159
if active {
155160
op.Stop()
156161
active = false
157-
glog.Fatalf("Active state lost, exiting...")
162+
glog.Fatalf("The active state lost, exiting...")
158163
}
159164
},
160165
OnFail: func(err error) {

deploy/deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
serviceAccountName: pa-controller
2525
containers:
2626
- name: pa-controller
27-
image: inwinstack/pa-controller:v0.7.2
27+
image: inwinstack/pa-controller:v0.7.3
2828
args:
2929
- --logtostderr=true
3030
- --v=2

0 commit comments

Comments
 (0)