File tree Expand file tree Collapse file tree 4 files changed +27
-8
lines changed Expand file tree Collapse file tree 4 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -26,17 +26,32 @@ func main() {
2626 os .Exit (1 )
2727 }
2828
29+ if err := ipamPlugin .Plugin .InitializeKeyValueStore (& config ); err != nil {
30+ fmt .Printf ("Failed to initialize key-value store of ipam plugin, err:%v.\n " , err )
31+ os .Exit (1 )
32+ }
33+
34+ defer func () {
35+ if errUninit := ipamPlugin .Plugin .UninitializeKeyValueStore (); errUninit != nil {
36+ fmt .Printf ("Failed to uninitialize key-value store of ipam plugin, err:%v.\n " , err )
37+ }
38+
39+ if recover () != nil {
40+ os .Exit (1 )
41+ }
42+ }()
43+
2944 err = ipamPlugin .Start (& config )
3045 if err != nil {
3146 fmt .Printf ("Failed to start IPAM plugin, err:%v.\n " , err )
32- os . Exit ( 1 )
47+ panic ( "ipam plugin fatal error" )
3348 }
3449
3550 err = ipamPlugin .Execute (cni .PluginApi (ipamPlugin ))
3651
3752 ipamPlugin .Stop ()
3853
3954 if err != nil {
40- os . Exit ( 1 )
55+ panic ( "ipam plugin fatal error" )
4156 }
4257}
Original file line number Diff line number Diff line change @@ -83,6 +83,12 @@ func main() {
8383
8484 netPlugin .SetReportManager (reportManager )
8585
86+ if err = netPlugin .Plugin .InitializeKeyValueStore (& config ); err != nil {
87+ log .Printf ("Failed to initialize key-value store of network plugin, err:%v.\n " , err )
88+ reportPluginError (reportManager , err )
89+ os .Exit (1 )
90+ }
91+
8692 defer func () {
8793 if errUninit := netPlugin .Plugin .UninitializeKeyValueStore (); errUninit != nil {
8894 log .Printf ("Failed to uninitialize key-value store of network plugin, err:%v.\n " , err )
@@ -93,12 +99,6 @@ func main() {
9399 }
94100 }()
95101
96- if err = netPlugin .Plugin .InitializeKeyValueStore (& config ); err != nil {
97- log .Printf ("Failed to initialize key-value store of network plugin, err:%v.\n " , err )
98- reportPluginError (reportManager , err )
99- panic ("network plugin fatal error" )
100- }
101-
102102 if err = netPlugin .Start (& config ); err != nil {
103103 log .Printf ("Failed to start network plugin, err:%v.\n " , err )
104104 reportPluginError (reportManager , err )
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ func (am *addressManager) Uninitialize() {
9696func (am * addressManager ) restore () error {
9797 // Skip if a store is not provided.
9898 if am .store == nil {
99+ log .Printf ("[ipam] ipam store is nil" )
99100 return nil
100101 }
101102
@@ -117,6 +118,7 @@ func (am *addressManager) restore() error {
117118 err = am .store .Read (storeKey , am )
118119 if err != nil {
119120 if err == store .ErrKeyNotFound {
121+ log .Printf ("[ipam] store key not found" )
120122 return nil
121123 } else {
122124 log .Printf ("[ipam] Failed to restore state, err:%v\n " , err )
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ func (nm *networkManager) Uninitialize() {
7272func (nm * networkManager ) restore () error {
7373 // Skip if a store is not provided.
7474 if nm .store == nil {
75+ log .Printf ("[net] network store is nil" )
7576 return nil
7677 }
7778
@@ -83,6 +84,7 @@ func (nm *networkManager) restore() error {
8384 err := nm .store .Read (storeKey , nm )
8485 if err != nil {
8586 if err == store .ErrKeyNotFound {
87+ log .Printf ("[net] network store key not found" )
8688 // Considered successful.
8789 return nil
8890 } else {
You can’t perform that action at this time.
0 commit comments