openvswitch / ovs-issues

Issue tracker repo for Open vSwitch
10 stars 3 forks source link

construct /var/log disk full,ovs and ovsdb-server can not startup #257

Closed coolMarlon closed 2 years ago

coolMarlon commented 2 years ago

OVS‘s ’default log is /var/log/openvswitch. If i construct the /var/log full ,ovsdb-server and ovs-vswitchd start failed. image

because VLOG_OPTION_HANDLERS exit because vlog_set_log_faile exit with errno 1ENOSPC (No space left on device)

/* Sets the name of the log file used by VLF_FILE to 'file_name', or to the
 * default file name if 'file_name' is null.  Returns 0 if successful,
 * otherwise a positive errno value. */
int
vlog_set_log_file(const char *file_name)
{
    ...
    /* Open new log file and update min_levels[] to reflect whether we actually
     * have a log_file. */
    log_fd = open(log_file_name, O_WRONLY | O_CREAT | O_APPEND, 0666);
    ...
    /* Log success or failure. */
    if (log_fd < 0) {
        VLOG_WARN("failed to open %s for logging: %s",
                  log_file_name, strerror(errno));
        error = errno;
    } 
    ...
    return error;
}
#define VLOG_OPTION_HANDLERS                    \
...                  
        case OPT_LOG_FILE: {                    \
            int err = vlog_set_log_file(optarg);\
            /* Exit if logfile explicitly given \
             * but cannot be opened. */         \
            if (err && optarg) {                \
                exit(EXIT_FAILURE);             \
            }                                   \
            break;                              \
        }                                       \
...

I think this problem can be optimized. If OVS open log file failed, it continues to start. When /var/log has free space, OVS restore logging.