Remove host mgmt mac address from maintenance

Node replacement is impacted by maintenance saving and doing error
handling if a nosts mac changes.

This update removes

1. mtcAgent  code that extracts/caches hosts management mac address.
2. mtcAgent  code that embeds host mgmt_mac in messages.
3. mtcClient code that checks the mgmt_mac on incoming messages.

Test Plan:

PEND: Verify Build and Install AIO DX Plus worker.
PEND: Verify maintenance messaging to all node types.
PASS: Verify mtcAgent and mtcClient logs with and without debug mode.

Closes-Bug: 2055440
Change-Id: I406bec57a06422a8c9579fb1ada54963bfdbab05
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric MacDonald 2024-02-29 17:10:14 +00:00
parent 880df77a25
commit cc228101c2
12 changed files with 12 additions and 119 deletions

View File

@ -418,7 +418,6 @@ int jsonUtil_inv_load ( char * json_str_ptr,
info.host[i].avail = _json_get_key_value_string ( node_obj, MTC_JSON_INV_AVAIL );
info.host[i].admin = _json_get_key_value_string ( node_obj, MTC_JSON_INV_ADMIN );
info.host[i].oper = _json_get_key_value_string ( node_obj, MTC_JSON_INV_OPER );
info.host[i].mac = _json_get_key_value_string ( node_obj, MTC_JSON_INV_HOSTMAC );
info.host[i].ip = _json_get_key_value_string ( node_obj, MTC_JSON_INV_HOSTIP );
info.host[i].type = _json_get_key_value_string ( node_obj, MTC_JSON_INV_TYPE );
info.host[i].func = _json_get_key_value_string ( node_obj, MTC_JSON_INV_FUNC );
@ -476,7 +475,6 @@ int jsonUtil_patch_load ( char * json_str_ptr,
info.avail = _json_get_key_value_string ( node_obj, MTC_JSON_INV_AVAIL );
info.admin = _json_get_key_value_string ( node_obj, MTC_JSON_INV_ADMIN );
info.oper = _json_get_key_value_string ( node_obj, MTC_JSON_INV_OPER );
info.mac = _json_get_key_value_string ( node_obj, MTC_JSON_INV_HOSTMAC );
info.ip = _json_get_key_value_string ( node_obj, MTC_JSON_INV_HOSTIP );
info.type = _json_get_key_value_string ( node_obj, MTC_JSON_INV_TYPE );
info.func = _json_get_key_value_string ( node_obj, MTC_JSON_INV_FUNC );
@ -528,7 +526,6 @@ int jsonUtil_load_host ( char * json_str_ptr, node_inv_type & info )
node_inv_init ( info );
/* Get all required fields */
info.mac = _json_get_key_value_string ( node_obj, MTC_JSON_INV_HOSTMAC);
info.ip = _json_get_key_value_string ( node_obj, MTC_JSON_INV_HOSTIP );
info.uuid = _json_get_key_value_string ( node_obj, MTC_JSON_INV_UUID );
info.name = _json_get_key_value_string ( node_obj, MTC_JSON_INV_NAME );

View File

@ -196,7 +196,6 @@ typedef enum
#define MTC_JSON_INV_UUID "uuid"
#define MTC_JSON_INV_NAME "hostname"
#define MTC_JSON_INV_HOSTIP "mgmt_ip"
#define MTC_JSON_INV_HOSTMAC "mgmt_mac"
#define MTC_JSON_INV_CLSTRIP "cluster_host_ip"
#define MTC_JSON_INV_AVAIL "availability"
#define MTC_JSON_INV_OPER "operational"
@ -470,7 +469,6 @@ typedef struct
std::string uuid ;
std::string name ;
std::string ip ;
std::string mac ;
std::string clstr_ip ;
std::string admin ;
std::string oper ;
@ -555,7 +553,6 @@ const char * get_heartbeat_ready_header( void ) ;
#define MTC_CMD_VERSION (1)
#define MTC_CMD_REVISION (0)
#define MTC_CMD_FEATURE_VER__MACADDR_IN_CMD (1)
#define MTC_CMD_FEATURE_VER__KEYVALUE_IN_BUF (2)
typedef struct

View File

@ -111,7 +111,6 @@ void node_inv_init (node_inv_type & inv)
inv.name.clear();
inv.ip.clear();
inv.clstr_ip.clear();
inv.mac.clear();
inv.admin.clear();
inv.oper.clear();
inv.avail.clear();
@ -142,7 +141,6 @@ void print_inv ( node_inv_type & info )
syslog ( LOG_INFO, "| task : %s\n", info.task.c_str());
syslog ( LOG_INFO, "| info : %s\n", info.mtce_info.c_str());
syslog ( LOG_INFO, "| ip : %s\n", info.ip.c_str());
syslog ( LOG_INFO, "| mac : %s\n", info.mac.c_str());
syslog ( LOG_INFO, "| uuid : %s\n", info.uuid.c_str());
syslog ( LOG_INFO, "| adminState: %s\n", info.admin.c_str());
syslog ( LOG_INFO, "| operState: %s\n", info.oper.c_str());

View File

@ -115,7 +115,7 @@
#define FAIL_BM_PROVISION_ERR (91)
#define FAIL_DUP_HOSTNAME (92)
#define FAIL_DUP_IPADDR (93)
#define FAIL_DUP_MACADDR (94)
#define FAIL____UNUSED____94 (94)
#define FAIL____UNUSED____95 (95)
#define FAIL_LOCATE_KEY_VALUE (96)
#define FAIL_JSON_OBJECT (97)

View File

@ -494,9 +494,7 @@ nodeLinkClass::node* nodeLinkClass::addNode( string hostname )
ptr->hostname = hostname ;
ptr->ip = "" ;
ptr->mac = "" ;
ptr->clstr_ip = "" ;
ptr->clstr_mac = "" ;
/* key value dictionary */
ptr->mtce_info = "" ;
@ -2407,15 +2405,6 @@ int nodeLinkClass::mod_host ( node_inv_type & inv )
modify = true ; /* we have a delta */
}
if ( node_ptr->mac.compare ( inv.mac ) )
{
plog ("%s Modify 'mgmt_mac' from %s -> %s\n",
node_ptr->hostname.c_str(),
node_ptr->mac.c_str(), inv.mac.c_str() );
node_ptr->mac = inv.mac ;
modify = true ; /* we have a delta */
}
if (( hostUtil_is_valid_ip_addr ( inv.clstr_ip )) &&
( node_ptr->clstr_ip != inv.clstr_ip ))
@ -2632,7 +2621,6 @@ string nodeLinkClass::get_host ( string uuid )
* uuid
* hostname
* ip address
* mac address
*
**/
int nodeLinkClass::add_host_precheck ( node_inv_type & inv )
@ -2694,11 +2682,6 @@ int nodeLinkClass::add_host_precheck ( node_inv_type & inv )
wlog ("ip address (%s) already used ; rejecting add / modify\n", inv.ip.c_str());
return(FAIL_DUP_IPADDR);
}
if ( !ptr->mac.compare(inv.mac))
{
wlog ("mac address (%s) already used ; rejecting add / modify\n", inv.mac.c_str());
return(FAIL_DUP_MACADDR);
}
}
if (( ptr->next == NULL ) || ( ptr == tail ))
break ;
@ -2736,7 +2719,7 @@ int nodeLinkClass::add_host ( node_inv_type & inv )
/* Ensure we don't add a host with critical info that is
* already used by other members of inventory like ;
* hostname, uuid, ip, mac, bm_ip */
* hostname, uuid, ip, bm_ip */
else if ( ( rc = add_host_precheck ( inv )) > RETRY )
{
return (rc);
@ -2818,7 +2801,6 @@ int nodeLinkClass::add_host ( node_inv_type & inv )
update_host_functions ( inv.name, inv.func );
node_ptr->ip = inv.ip ;
node_ptr->mac = inv.mac ;
node_ptr->uuid = inv.uuid ;
node_ptr->clstr_ip = inv.clstr_ip ;
node_ptr->mtce_info = inv.mtce_info ;
@ -3701,21 +3683,6 @@ string nodeLinkClass::get_clstr_hostaddr ( string & hostname )
return ( null_str );
}
string nodeLinkClass::get_hostIfaceMac ( string & hostname, int iface )
{
nodeLinkClass::node* node_ptr ;
node_ptr = nodeLinkClass::getNode ( hostname );
if ( node_ptr != NULL )
{
if ( iface == MGMNT_IFACE )
return ( node_ptr->mac );
if ( iface == CLSTR_IFACE )
return ( node_ptr->clstr_mac );
}
ilog ("%s has unknown mac address for %s interface\n", hostname.c_str(), get_iface_name_str(iface));
return ( null_str );
}
int nodeLinkClass::set_hostaddr ( string & hostname, string & ip )
{
int rc = FAIL ;
@ -9319,9 +9286,8 @@ void nodeLinkClass::mem_log_reset_info ( struct nodeLinkClass::node * node_ptr )
void nodeLinkClass::mem_log_network ( struct nodeLinkClass::node * node_ptr )
{
char str[MAX_MEM_LOG_DATA] ;
snprintf (&str[0], MAX_MEM_LOG_DATA, "%s\t%s %s cluster_host_ip: %s Uptime: %u\n",
snprintf (&str[0], MAX_MEM_LOG_DATA, "%s\t%s cluster_host_ip: %s Uptime: %u\n",
node_ptr->hostname.c_str(),
node_ptr->mac.c_str(),
node_ptr->ip.c_str(),
node_ptr->clstr_ip.c_str(),
node_ptr->uptime );

View File

@ -118,15 +118,9 @@ private:
/** The IP address of the host node */
std::string ip ;
/** The Mac address of the host node */
std::string mac ;
/** The cluster-host network IP address of the host node */
std::string clstr_ip ;
/** The Mac address of the host's cluster-host interface */
std::string clstr_mac ;
/** The type of node 'controller' or 'worker' node */
std::string type ;
@ -1442,9 +1436,6 @@ public:
int set_mtcInfo ( string hostname, string & mtc_info );
/** get mac address for any hostname and specified interface */
string get_hostIfaceMac ( string & hostname, int iface );
/** get cluster-host network ip address for any hostname */
string get_clstr_hostaddr ( string & hostname );
@ -1615,7 +1606,6 @@ public:
* uuid
* hostname
* ip address
* mac address
*
**/
int add_host_precheck ( node_inv_type & inv );

View File

@ -168,33 +168,9 @@ int mtc_service_command ( mtc_socket_type * sock_ptr, int interface )
}
rc = PASS ;
bool self = false ;
if (( hostaddr == ctrl_ptr->address ) ||
( hostaddr == ctrl_ptr->address_clstr ))
{
self = true ;
}
string interface_name = get_iface_name_str (interface) ;
string command_name = get_mtcNodeCommand_str(msg.cmd) ;
print_mtc_message ( get_hostname(), MTC_CMD_RX, msg, interface_name.data(), false );
/* Message version greater than zero have the hosts management
* mac address appended to the header string */
if (( !self ) && ( msg.ver >= MTC_CMD_FEATURE_VER__MACADDR_IN_CMD ))
{
/* the minus 1 is to back up from the null char that is accounted for in the hearder size */
if ( strncmp ( &msg.hdr[MSG_HEADER_SIZE-1], ctrl_ptr->macaddr.data(), MSG_HEADER_SIZE ))
{
wlog ("%s command not for this host (exp:%s det:%s) ; ignoring ...\n",
command_name.c_str(),
ctrl_ptr->macaddr.c_str(),
&msg.hdr[MSG_HEADER_SIZE-1]);
print_mtc_message ( get_hostname(), MTC_CMD_RX, msg, interface_name.data(), true );
return (FAIL_INVALID_DATA);
}
}
print_mtc_message ( hostaddr, MTC_CMD_RX, msg, get_iface_name_str(interface), rc );
if ( rc )
return rc;

View File

@ -743,10 +743,6 @@ int send_mtc_cmd ( string & hostname, int cmd , int interface, string json_dict
nodeLinkClass * obj_ptr = get_mtcInv_ptr ();
/* add the mac address of the target card to the header
* Note: the minus 1 is to overwrite the null */
snprintf ( &mtc_cmd.hdr[MSG_HEADER_SIZE-1], MSG_HEADER_SIZE, "%s", obj_ptr->get_hostIfaceMac(hostname, MGMNT_IFACE).data());
/* If data is empty then at least add where the message came from */
if ( data.empty() )
{

View File

@ -211,13 +211,6 @@ void _create_error_response ( int rc , string & resp_buffer , node_inv_type & in
resp_buffer.append (inv.ip.data());
resp_buffer.append ("' first and then retry or contact system administrator\"");
}
else if ( rc == FAIL_DUP_MACADDR )
{
resp_buffer.append (",\"reason\" : \"Rejecting host-edit with duplicate mac address\"");
resp_buffer.append (",\"action\" : \"Delete host with mac address '");
resp_buffer.append (inv.mac.data());
resp_buffer.append ("' first and then retry or contact system administrator\"");
}
else if (( rc == FAIL_POWER_CONTROL ) ||
( rc == FAIL_RESET_CONTROL ))
{

View File

@ -567,10 +567,6 @@ int mtcHttpUtil_api_request ( libEvent & event )
event.payload.append ( event.inv_info.ip );
event.payload.append ("\"");
event.payload.append (",\"mgmt_mac\":\"");
event.payload.append ( event.inv_info.mac );
event.payload.append ("\"");
event.payload.append (",\"hostname\":\"");
event.payload.append ( event.inv_info.name );
event.payload.append ("\"");

View File

@ -187,9 +187,7 @@ int mtcInvApi_add_host ( node_inv_type & info )
obj_ptr->sysinvEvent.operation = "add host" ;
obj_ptr->sysinvEvent.blocking = true ;
dlog ("%s ip:%s mac:%s\n", info.name.c_str(),
info.ip.c_str(),
info.mac.c_str());
dlog ("%s ip:%s", info.name.c_str(), info.ip.c_str());
return (mtcHttpUtil_api_request ( obj_ptr->sysinvEvent ));
}
@ -1501,7 +1499,6 @@ void nodeLinkClass::mtcInvApi_get_handler ( struct evhttp_request *req, void *ar
node.uuid = json_info.host[i].uuid ;
node.name = json_info.host[i].name ;
node.ip = json_info.host[i].ip ;
node.mac = json_info.host[i].mac ;
node.id = json_info.host[i].id ;
node.admin = json_info.host[i].admin;
node.oper = json_info.host[i].oper ;

View File

@ -1145,13 +1145,10 @@ int _self_provision ( void )
my_identity.name = mtcInv.my_hostname ;
my_identity.ip = mtcInv.my_local_ip ;
get_iface_macaddr ( mtc_config.mgmnt_iface , my_identity.mac );
/* Verify interface properties */
if ( my_identity.mac.empty() ||
( my_identity.mac.length() != COL_CHARS_IN_MAC_ADDR ) ||
my_identity.name.empty() ||
my_identity.ip.empty ())
if ( my_identity.name.empty() ||
my_identity.ip.empty ())
{
elog ("Failed to acquire mgmt interface (%s) properties\n", mtc_config.mgmnt_iface );
daemon_exit();
@ -1204,23 +1201,13 @@ int _self_provision ( void )
mtcInv.set_bm_type ( my_identity.name, record_info.bm_type );
mtcInv.set_mtcInfo ( my_identity.name, record_info.mtce_info );
if ( my_identity.name == record_info.name )
if (( my_identity.name == record_info.name ) &&
( my_identity.ip != record_info.ip ))
{
if ( my_identity.mac != record_info.mac )
{
wlog ("%s mac address mismatch (%s - %s)\n",
my_identity.name.c_str(),
my_identity.mac.c_str(),
record_info.mac.c_str());
}
if ( my_identity.ip != record_info.ip )
{
wlog ("%s ip address mismatch (%s - %s)\n",
my_identity.name.c_str(),
my_identity.ip.c_str(),
record_info.ip.c_str());
}
wlog ("%s ip address mismatch (%s - %s)\n",
my_identity.name.c_str(),
my_identity.ip.c_str(),
record_info.ip.c_str());
}
}
else