summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-02-06 22:26:49 +0000
committerGerrit Code Review <review@openstack.org>2019-02-06 22:26:49 +0000
commitbeda852ec8dd87da4a401095a19f8ba7d744a13e (patch)
tree8287644caf7d1af52f254eb02189726f6f52ba9a
parent714ee5db84f6f85cb459c7382790448489696d70 (diff)
parent1066d26e9e150d4f93f404740b526d00d7255062 (diff)
Merge "Fixed host-swact failed"
-rw-r--r--service-mgmt/sm-1.0.0/src/sm_failover.c33
-rw-r--r--service-mgmt/sm-1.0.0/src/sm_service_domain_backup_state.c29
-rw-r--r--service-mgmt/sm-1.0.0/src/sm_service_domain_fsm.c7
-rw-r--r--service-mgmt/sm-1.0.0/src/sm_service_domain_initial_state.c4
-rw-r--r--service-mgmt/sm-1.0.0/src/sm_service_domain_leader_state.c29
-rw-r--r--service-mgmt/sm-1.0.0/src/sm_service_domain_other_state.c4
-rw-r--r--service-mgmt/sm-1.0.0/src/sm_service_domain_waiting_state.c4
-rw-r--r--service-mgmt/sm-common-1.0.0/centos/build_srpm.data2
-rw-r--r--service-mgmt/sm-common-1.0.0/src/sm_types.c1
-rw-r--r--service-mgmt/sm-common-1.0.0/src/sm_types.h1
-rw-r--r--service-mgmt/sm-db-1.0.0/centos/build_srpm.data2
11 files changed, 109 insertions, 7 deletions
diff --git a/service-mgmt/sm-1.0.0/src/sm_failover.c b/service-mgmt/sm-1.0.0/src/sm_failover.c
index 37a25c2..6e2f130 100644
--- a/service-mgmt/sm-1.0.0/src/sm_failover.c
+++ b/service-mgmt/sm-1.0.0/src/sm_failover.c
@@ -810,14 +810,37 @@ static SmErrorT sm_ensure_leader_scheduler()
810{ 810{
811 char controller_domain[] = "controller"; 811 char controller_domain[] = "controller";
812 char reason_text[SM_LOG_REASON_TEXT_MAX_CHAR] = "Loss of heartbeat"; 812 char reason_text[SM_LOG_REASON_TEXT_MAX_CHAR] = "Loss of heartbeat";
813 SmServiceDomainT* domain;
813 814
814 SmErrorT error = sm_service_domain_fsm_set_state( 815 domain = sm_service_domain_table_read( controller_domain );
816 if( NULL == domain )
817 {
818 DPRINTFE( "Failed to read service domain (%s), error=%s.",
819 controller_domain, sm_error_str(SM_NOT_FOUND) );
820 return( SM_NOT_FOUND );
821 }
822
823 if(0 == strncmp(domain->leader, _host_name, sizeof(domain->leader)))
824 {
825 //Already leader. Nothing to do
826 return SM_OKAY;
827 }
828
829 SmServiceDomainEventT event = SM_SERVICE_DOMAIN_EVENT_CHANGING_LEADER;
830 void* event_data[] = {
831 _host_name //new leader
832 };
833 SmErrorT error = sm_service_domain_fsm_event_handler(
815 controller_domain, 834 controller_domain,
816 SM_SERVICE_DOMAIN_STATE_LEADER, 835 event,
817 reason_text ); 836 event_data, reason_text );
818 if(SM_OKAY != error) 837
838 if( SM_OKAY != error )
819 { 839 {
820 DPRINTFE("Failed to ensure leader scheduler. Error %s", sm_error_str(error)); 840 DPRINTFE( "Service domain (%s) failed to handle event (%s), error=%s.",
841 controller_domain, sm_service_domain_event_str(event),
842 sm_error_str( error ) );
843 return( error );
821 } 844 }
822 return error; 845 return error;
823} 846}
diff --git a/service-mgmt/sm-1.0.0/src/sm_service_domain_backup_state.c b/service-mgmt/sm-1.0.0/src/sm_service_domain_backup_state.c
index e4471ae..cf58066 100644
--- a/service-mgmt/sm-1.0.0/src/sm_service_domain_backup_state.c
+++ b/service-mgmt/sm-1.0.0/src/sm_service_domain_backup_state.c
@@ -58,6 +58,7 @@ SmErrorT sm_service_domain_backup_state_event_handler( SmServiceDomainT* domain,
58 char* neighbor_name = NULL; 58 char* neighbor_name = NULL;
59 char leader[SM_NODE_NAME_MAX_CHAR]; 59 char leader[SM_NODE_NAME_MAX_CHAR];
60 char hostname[SM_NODE_NAME_MAX_CHAR]; 60 char hostname[SM_NODE_NAME_MAX_CHAR];
61 const char* new_leader;
61 int generation = 0; 62 int generation = 0;
62 char reason_text[SM_LOG_REASON_TEXT_MAX_CHAR] = ""; 63 char reason_text[SM_LOG_REASON_TEXT_MAX_CHAR] = "";
63 SmServiceDomainStateT state = SM_SERVICE_DOMAIN_STATE_NIL; 64 SmServiceDomainStateT state = SM_SERVICE_DOMAIN_STATE_NIL;
@@ -188,6 +189,34 @@ SmErrorT sm_service_domain_backup_state_event_handler( SmServiceDomainT* domain,
188 // Ignore. 189 // Ignore.
189 break; 190 break;
190 191
192 case SM_SERVICE_DOMAIN_EVENT_CHANGING_LEADER:
193 new_leader = (const char*) event_data[0];
194 error = sm_node_api_get_hostname(hostname);
195 if(SM_OKAY != error )
196 {
197 DPRINTFE("Failed to get hostname. Error %s", sm_error_str(error));
198 return SM_FAILED;
199 }
200
201 if(0 != strncmp(hostname, new_leader, SM_NODE_NAME_MAX_CHAR))
202 {
203 //Ignore
204 }else
205 {
206 strncpy(domain->leader, new_leader, SM_NODE_NAME_MAX_CHAR);
207 state = SM_SERVICE_DOMAIN_STATE_LEADER;
208 error = sm_service_domain_fsm_set_state( domain->name, state,
209 "leader change");
210 if( SM_OKAY != error )
211 {
212 DPRINTFE( "Set state (%s) of service domain (%s) failed, "
213 "error=%s.", sm_service_domain_state_str( state ),
214 domain->name, sm_error_str( error ) );
215 return( error );
216 }
217 }
218 break;
219
191 default: 220 default:
192 DPRINTFD( "Service Domain (%s) ignoring event (%s).", 221 DPRINTFD( "Service Domain (%s) ignoring event (%s).",
193 domain->name, 222 domain->name,
diff --git a/service-mgmt/sm-1.0.0/src/sm_service_domain_fsm.c b/service-mgmt/sm-1.0.0/src/sm_service_domain_fsm.c
index 8919892..c2c57da 100644
--- a/service-mgmt/sm-1.0.0/src/sm_service_domain_fsm.c
+++ b/service-mgmt/sm-1.0.0/src/sm_service_domain_fsm.c
@@ -340,6 +340,13 @@ SmErrorT sm_service_domain_fsm_set_state( char service_domain_name[],
340 snprintf( _reason_text, sizeof(_reason_text), "%s", reason_text ); 340 snprintf( _reason_text, sizeof(_reason_text), "%s", reason_text );
341 } 341 }
342 342
343 error = sm_service_domain_table_persist( domain );
344 if( SM_OKAY != error )
345 {
346 DPRINTFE( "Failed to persist service domain (%s), error=%s.",
347 domain->name, sm_error_str( error ) );
348 }
349
343 return( SM_OKAY ); 350 return( SM_OKAY );
344 351
345STATE_CHANGE_ERROR: 352STATE_CHANGE_ERROR:
diff --git a/service-mgmt/sm-1.0.0/src/sm_service_domain_initial_state.c b/service-mgmt/sm-1.0.0/src/sm_service_domain_initial_state.c
index 051d507..740f556 100644
--- a/service-mgmt/sm-1.0.0/src/sm_service_domain_initial_state.c
+++ b/service-mgmt/sm-1.0.0/src/sm_service_domain_initial_state.c
@@ -198,6 +198,10 @@ SmErrorT sm_service_domain_initial_state_event_handler(
198 // Ignore. 198 // Ignore.
199 break; 199 break;
200 200
201 case SM_SERVICE_DOMAIN_EVENT_CHANGING_LEADER:
202 DPRINTFE("Received unexpected %s event", sm_service_domain_event_str(event));
203 break;
204
201 default: 205 default:
202 DPRINTFD( "Service Domain (%s) ignoring event (%s).", 206 DPRINTFD( "Service Domain (%s) ignoring event (%s).",
203 domain->name, sm_service_domain_event_str( event ) ); 207 domain->name, sm_service_domain_event_str( event ) );
diff --git a/service-mgmt/sm-1.0.0/src/sm_service_domain_leader_state.c b/service-mgmt/sm-1.0.0/src/sm_service_domain_leader_state.c
index 99e439f..7259bfd 100644
--- a/service-mgmt/sm-1.0.0/src/sm_service_domain_leader_state.c
+++ b/service-mgmt/sm-1.0.0/src/sm_service_domain_leader_state.c
@@ -57,6 +57,7 @@ SmErrorT sm_service_domain_leader_state_event_handler( SmServiceDomainT* domain,
57 char* neighbor_name = NULL; 57 char* neighbor_name = NULL;
58 char* leader_name = NULL; 58 char* leader_name = NULL;
59 char hostname[SM_NODE_NAME_MAX_CHAR]; 59 char hostname[SM_NODE_NAME_MAX_CHAR];
60 const char* new_leader;
60 int generation = 0; 61 int generation = 0;
61 int priority = 0; 62 int priority = 0;
62 SmServiceDomainStateT state = SM_SERVICE_DOMAIN_STATE_NIL; 63 SmServiceDomainStateT state = SM_SERVICE_DOMAIN_STATE_NIL;
@@ -189,6 +190,34 @@ SmErrorT sm_service_domain_leader_state_event_handler( SmServiceDomainT* domain,
189 // Ignore. 190 // Ignore.
190 break; 191 break;
191 192
193 case SM_SERVICE_DOMAIN_EVENT_CHANGING_LEADER:
194 new_leader = (const char*) event_data[0];
195 error = sm_node_api_get_hostname(hostname);
196 if(SM_OKAY != error )
197 {
198 DPRINTFE("Failed to get hostname. Error %s", sm_error_str(error));
199 return SM_FAILED;
200 }
201
202 if(0 == strncmp(hostname, new_leader, SM_NODE_NAME_MAX_CHAR))
203 {
204 //Ignore
205 }else
206 {
207 strncpy(domain->leader, new_leader, SM_NODE_NAME_MAX_CHAR);
208 state = SM_SERVICE_DOMAIN_STATE_BACKUP;
209 error = sm_service_domain_fsm_set_state( domain->name, state,
210 "leader change");
211 if( SM_OKAY != error )
212 {
213 DPRINTFE( "Set state (%s) of service domain (%s) failed, "
214 "error=%s.", sm_service_domain_state_str( state ),
215 domain->name, sm_error_str( error ) );
216 return( error );
217 }
218 }
219 break;
220
192 default: 221 default:
193 DPRINTFD( "Service Domain (%s) ignoring event (%s).", 222 DPRINTFD( "Service Domain (%s) ignoring event (%s).",
194 domain->name, sm_service_domain_event_str( event ) ); 223 domain->name, sm_service_domain_event_str( event ) );
diff --git a/service-mgmt/sm-1.0.0/src/sm_service_domain_other_state.c b/service-mgmt/sm-1.0.0/src/sm_service_domain_other_state.c
index 5d5c219..e7e9783 100644
--- a/service-mgmt/sm-1.0.0/src/sm_service_domain_other_state.c
+++ b/service-mgmt/sm-1.0.0/src/sm_service_domain_other_state.c
@@ -98,6 +98,10 @@ SmErrorT sm_service_domain_other_state_event_handler( SmServiceDomainT* domain,
98 // Ignore. 98 // Ignore.
99 break; 99 break;
100 100
101 case SM_SERVICE_DOMAIN_EVENT_CHANGING_LEADER:
102 DPRINTFE("Received unexpected %s event", sm_service_domain_event_str(event));
103 break;
104
101 default: 105 default:
102 DPRINTFD( "Service Domain (%s) ignoring event (%s).", 106 DPRINTFD( "Service Domain (%s) ignoring event (%s).",
103 domain->name, sm_service_domain_event_str( event ) ); 107 domain->name, sm_service_domain_event_str( event ) );
diff --git a/service-mgmt/sm-1.0.0/src/sm_service_domain_waiting_state.c b/service-mgmt/sm-1.0.0/src/sm_service_domain_waiting_state.c
index c2ccc59..7c79fb9 100644
--- a/service-mgmt/sm-1.0.0/src/sm_service_domain_waiting_state.c
+++ b/service-mgmt/sm-1.0.0/src/sm_service_domain_waiting_state.c
@@ -287,6 +287,10 @@ SmErrorT sm_service_domain_waiting_state_event_handler(
287 } 287 }
288 break; 288 break;
289 289
290 case SM_SERVICE_DOMAIN_EVENT_CHANGING_LEADER:
291 DPRINTFE("Received unexpected %s event", sm_service_domain_event_str(event));
292 break;
293
290 default: 294 default:
291 DPRINTFD( "Service Domain (%s) ignoring event (%s).", 295 DPRINTFD( "Service Domain (%s) ignoring event (%s).",
292 domain->name, sm_service_domain_event_str( event ) ); 296 domain->name, sm_service_domain_event_str( event ) );
diff --git a/service-mgmt/sm-common-1.0.0/centos/build_srpm.data b/service-mgmt/sm-common-1.0.0/centos/build_srpm.data
index 857d6ad..6a17877 100644
--- a/service-mgmt/sm-common-1.0.0/centos/build_srpm.data
+++ b/service-mgmt/sm-common-1.0.0/centos/build_srpm.data
@@ -1,2 +1,2 @@
1SRC_DIR=$PKG_BASE 1SRC_DIR=$PKG_BASE
2TIS_PATCH_VER=19 2TIS_PATCH_VER=20
diff --git a/service-mgmt/sm-common-1.0.0/src/sm_types.c b/service-mgmt/sm-common-1.0.0/src/sm_types.c
index b3bfdc6..e59a8cd 100644
--- a/service-mgmt/sm-common-1.0.0/src/sm_types.c
+++ b/service-mgmt/sm-common-1.0.0/src/sm_types.c
@@ -151,6 +151,7 @@ _sm_service_domain_event_mappings[SM_SERVICE_DOMAIN_EVENT_MAX] =
151 { SM_SERVICE_DOMAIN_EVENT_INTERFACE_ENABLED, "interface-enabled" }, 151 { SM_SERVICE_DOMAIN_EVENT_INTERFACE_ENABLED, "interface-enabled" },
152 { SM_SERVICE_DOMAIN_EVENT_INTERFACE_DISABLED, "interface-disabled" }, 152 { SM_SERVICE_DOMAIN_EVENT_INTERFACE_DISABLED, "interface-disabled" },
153 { SM_SERVICE_DOMAIN_EVENT_WAIT_EXPIRED, "wait-expired" }, 153 { SM_SERVICE_DOMAIN_EVENT_WAIT_EXPIRED, "wait-expired" },
154 { SM_SERVICE_DOMAIN_EVENT_CHANGING_LEADER, "change-leader" },
154}; 155};
155 156
156static SmValueStrMappingT 157static SmValueStrMappingT
diff --git a/service-mgmt/sm-common-1.0.0/src/sm_types.h b/service-mgmt/sm-common-1.0.0/src/sm_types.h
index 074a4fc..5af3d03 100644
--- a/service-mgmt/sm-common-1.0.0/src/sm_types.h
+++ b/service-mgmt/sm-common-1.0.0/src/sm_types.h
@@ -267,6 +267,7 @@ typedef enum
267 SM_SERVICE_DOMAIN_EVENT_INTERFACE_ENABLED, 267 SM_SERVICE_DOMAIN_EVENT_INTERFACE_ENABLED,
268 SM_SERVICE_DOMAIN_EVENT_INTERFACE_DISABLED, 268 SM_SERVICE_DOMAIN_EVENT_INTERFACE_DISABLED,
269 SM_SERVICE_DOMAIN_EVENT_WAIT_EXPIRED, 269 SM_SERVICE_DOMAIN_EVENT_WAIT_EXPIRED,
270 SM_SERVICE_DOMAIN_EVENT_CHANGING_LEADER,
270 SM_SERVICE_DOMAIN_EVENT_MAX 271 SM_SERVICE_DOMAIN_EVENT_MAX
271} SmServiceDomainEventT; 272} SmServiceDomainEventT;
272 273
diff --git a/service-mgmt/sm-db-1.0.0/centos/build_srpm.data b/service-mgmt/sm-db-1.0.0/centos/build_srpm.data
index a0b16ae..03342ca 100644
--- a/service-mgmt/sm-db-1.0.0/centos/build_srpm.data
+++ b/service-mgmt/sm-db-1.0.0/centos/build_srpm.data
@@ -2,4 +2,4 @@ SRC_DIR=`pwd`
2COPY_LIST="$PKG_BASE/LICENSE" 2COPY_LIST="$PKG_BASE/LICENSE"
3TAR_NAME=sm-db 3TAR_NAME=sm-db
4VERSION=1.0.0 4VERSION=1.0.0
5TIS_PATCH_VER=27 5TIS_PATCH_VER=28