Add node locked gate to SM enable

Service Management (SM) sometimes selects and activates services on a
locked controller following a dead office recovery.

This update adds a node locked check to SM's enable handler to
block enable if present much like the existing goenabled check
blocks enable if not present in the same function.

The enable gate file is /etc/mtc/tmp/.node_locked on the local host.

Maintenance manages the presence or absence of this file based on
the node's administrative state.

This update also cleans up some extra whitespace in the changed file.

Test Plan:

PASS: Verify system build and AIO DX install.
PEND: Verify SM does not activate on a locked controller.
      ... DOR case
      ... Uncontrolled Swact case
      ... Manual swact case

PEND: Verify behavior when both controllers are locked.
PEND: Verify AIO DX behavior over DOR with one locked controller
      while the only unlocked controller does not recover.
PEND: Verify behavior after above test case once the only unlocked
      controller does recover.
PEND: Verify lock of the standby controller and its sm logs

PROG: Verify manually creating the new Nv locked file on the active
      controller will cause SM to go disabled and shut down all
      services on that controller.
      ... If there is another unlocked controller then verify it
          takes over as an uncontrolled swact.
      ... If there is no unklocked standy controller then verify SM
          remains shutdown until the maually created Nv node locked
          file is removed. At which point SM proceeds to activate
          services on that controller again.

Closes-Bug: 2051578
Change-Id: I0f0e3d199586513ddce484fdcc056e1b2562b45f
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric MacDonald 2024-02-02 16:52:50 +00:00
parent 2fd5ebc6e6
commit 27e7764a56
1 changed files with 33 additions and 8 deletions

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2014-2023 Wind River Systems, Inc.
// Copyright (c) 2014-2024 Wind River Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
@ -18,6 +18,7 @@
#include "sm_types.h"
#include "sm_debug.h"
#define SM_NODE_LOCKED_FILE "/etc/mtc/tmp/.node_locked"
#define SM_NODE_GO_ENABLE_FILE "/var/run/goenabled"
#define SM_NODE_GO_ENABLE_FILE_SIMPLEX "/var/run/.goenabled"
#define SM_NODE_UNHEALTHY_FILE "/var/run/.sm_node_unhealthy"
@ -50,7 +51,7 @@ static SmErrorT sm_node_utils_read_platform_config( const char key[],
char format[1024];
char line[1024];
char val[1024];
value[0] = '\0';
fp = fopen( SM_NODE_PLATFORM_CONFIG_FILE, "r" );
@ -156,7 +157,7 @@ SmErrorT sm_node_utils_is_aio( bool* is_aio )
else
{
*is_aio = ( IsTrue == _is_aio );
}
}
return SM_OKAY;
}
@ -346,7 +347,7 @@ SmErrorT sm_node_utils_get_hostname( char node_name[] )
// ****************************************************************************
// ****************************************************************************
// Node Utilities - Configuration Complete
// Node Utilities - Configuration Complete
// =======================================
SmErrorT sm_node_utils_config_complete( bool* complete )
{
@ -369,7 +370,7 @@ SmErrorT sm_node_utils_config_complete( bool* complete )
*complete = true;
return( SM_OKAY );
return( SM_OKAY );
}
// ****************************************************************************
@ -381,6 +382,7 @@ typedef enum
NODE_UNHEALTHY_FILE_EXISTS,
NODE_DISABLED_LICENSE_INVALID,
NODE_DISABLED_FAILOVER,
NODE_IS_LOCKED,
NODE_ENABLED
}SmNodeEnabledBlockingStateT;
static SmNodeEnabledBlockingStateT blocking_state = BLOCKING_STATE_INIT;
@ -394,6 +396,7 @@ SmErrorT sm_node_utils_enabled( bool* enabled, char reason_text[] )
*enabled = false;
reason_text[0] = '\0';
const char* goenabled_file = SM_NODE_GO_ENABLE_FILE;
const char* node_locked_file = SM_NODE_LOCKED_FILE;
bool is_aio_simplex = false;
SmErrorT error = sm_node_utils_is_aio_simplex(&is_aio_simplex);
@ -409,6 +412,28 @@ SmErrorT sm_node_utils_enabled( bool* enabled, char reason_text[] )
goenabled_file = SM_NODE_GO_ENABLE_FILE_SIMPLEX;
}
if(0 == access( node_locked_file, F_OK ))
{
if( ENOENT == errno )
{
if(blocking_state != NODE_IS_LOCKED)
{
blocking_state = NODE_IS_LOCKED;
DPRINTFI("Node enable: blocked. Node is locked ; the %s file is present", node_locked_file);
}
snprintf( reason_text, SM_LOG_REASON_TEXT_MAX_CHAR,
"node is locked" );
return( SM_OKAY );
} else {
DPRINTFE( "Node Locked file (%s) access failed, error=%s.",
SM_NODE_GO_ENABLE_FILE, strerror( errno ) );
return( SM_FAILED );
}
}
if(0 > access( goenabled_file, F_OK ))
{
if( ENOENT == errno )
@ -518,7 +543,7 @@ bool sm_node_utils_set_failover( bool to_disable )
// ****************************************************************************
// Node Utilities - Set Unhealthy
// ==============================
SmErrorT sm_node_utils_set_unhealthy( void )
SmErrorT sm_node_utils_set_unhealthy( void )
{
int fd = open( SM_NODE_UNHEALTHY_FILE,
O_RDWR | O_CREAT, S_IRUSR | S_IRGRP | S_IROTH);
@ -563,13 +588,13 @@ SmErrorT sm_node_utils_is_aio_duplex( bool* is_aio_duplex )
if( IsUnknown == _is_aio_duplex )
{
SmErrorT error;
bool is_aio = false;
bool is_aio = false;
error = sm_node_utils_is_aio( &is_aio );
if( SM_OKAY != error)
{
return error;
}
if ( !is_aio )
{
*is_aio_duplex = false;