Whamcloud - gitweb
EX-3612 lamigo: use system(2) instead of libssh for local agents
authorAlex Zhuravlev <bzzz@whamcloud.com>
Fri, 6 Aug 2021 05:59:51 +0000 (08:59 +0300)
committerJohn L. Hammond <jhammond@whamcloud.com>
Fri, 25 Mar 2022 19:57:59 +0000 (19:57 +0000)
In lamigo, interpret an agent host of '-' to mean the localhost using
system(2) instead of libssh.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I1211f2e43af06659c660fdd57496d09c5d5413fa
Reviewed-on: https://review.whamcloud.com/46902
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lipe/src/lamigo.c
lustre/tests/hot-pools.sh

index 6258766..60696c8 100644 (file)
@@ -184,6 +184,7 @@ struct resync_agent {
        int rag_maxjobs;
        int rag_jobs;
        bool rag_bad;
+       bool rag_is_local;
        int rag_check_in_progress;
        struct lipe_list_head rag_list;
        struct lipe_list_head rag_ssh_list;
@@ -652,7 +653,14 @@ static int lamigo_exec_cmd(struct resync_agent *a, const char *cmd, int *pstatus
        lipe_list_del(&rss->rss_list);
        pthread_mutex_unlock(&a->rag_ssh_lock);
 
-       rc = lipe_ssh_exec(&rss->rss_ctx, cmd, pstatus);
+       rc = a->rag_is_local ?
+               system(cmd) :
+               lipe_ssh_exec(&rss->rss_ctx, cmd, pstatus);
+       if (rc)
+               llapi_error(LLAPI_MSG_INFO, rc,
+                       "error executing ssh command '%s' on '%s'",
+                       cmd, a->rag_hostname);
+
        pthread_mutex_lock(&a->rag_ssh_lock);
        lipe_list_add(&rss->rss_list, &a->rag_ssh_list);
        pthread_cond_signal(&a->rag_ssh_cond);
@@ -1714,8 +1722,16 @@ static void lamigo_add_agent(const char *host, const char *mnt, char *jobs)
 
        a = xcalloc(1, sizeof(*a));
        a->rag_index = lamigo_agent_count;
-       a->rag_hostname = xstrdup(host);
+
+       if (strcmp(host, "-") == 0) {
+               a->rag_hostname = xstrdup("localhost");
+               a->rag_is_local = 1;
+       } else {
+               a->rag_hostname = xstrdup(host);
+       }
+
        a->rag_mountpoint = xstrdup(mnt);
+
        if (jobs) {
                char *endptr;
 
index caf4194..ee36fe4 100755 (executable)
@@ -104,7 +104,7 @@ create_ost_pools() {
        pool_add_targets $LAMIGO_TGT $((OSTCOUNT / 2)) $((OSTCOUNT - 1)) ||
                error "failed to add targets to OST pool '$LAMIGO_TGT'"
 
-       LAMIGO_AGT_NODES="$(osts_nodes_in_pool $LAMIGO_SRC)"
+       LAMIGO_AGT_NODES="${LAMIGO_AGT_NODES:-$(osts_nodes_in_pool $LAMIGO_SRC)}"
 }
 
 # initialize lamigo variables