Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsubprocess: pass flags to remote subprocess #5968

Open
chu11 opened this issue May 14, 2024 · 2 comments
Open

libsubprocess: pass flags to remote subprocess #5968

chu11 opened this issue May 14, 2024 · 2 comments

Comments

@chu11
Copy link
Member

chu11 commented May 14, 2024

It appears that subprocess flags cannot be passed to remote sub processes.

Originally only the flags FLUX_SUBPROCESS_FLAGS_STDIO_FALLTHROUGH and FLUX_SUBPROCESS_FLAGS_SETPGRP were supported. The former flag has no purpose with remote subprocesses and it appears the latter is hard coded for the server.

    if (!(p = flux_local_exec_ex (flux_get_reactor (s->h),
                                  FLUX_SUBPROCESS_FLAGS_SETPGRP,
                                  cmd,
                                  &ops,
                                  NULL,
                                  s->llog,
                                  s->llog_data))) {
        errprintf (&error, "error launching process: %s", strerror (errno));
        errmsg = error.text;
        goto error;
    }

B/c of this, I'm guessing passing flags along didn't matter much, so it wasn't supported or was just outright missed.

With the addition of the FLUX_SUBPROCESS_FLAGS_FORK_EXEC flag (force fork() even if posix_spawn() is available), this is something we may want to pass along some day. As well as future flags.

This doesn't appear to be a problem at the moment, but its something to eventually support.

@chu11
Copy link
Member Author

chu11 commented May 14, 2024

related to this

flux_future_t *subprocess_rexec (flux_t *h,                                                                                              
                                 const char *service_name,                                                                               
                                 uint32_t rank,                                                                                          
                                 flux_cmd_t *cmd,                                                                                        
                                 int flags);    

we should probably rename "flags" here, as these are rexec specific flags that are internal to the implementation, they aren't the subprocess flags from the API.

Unfortunately the rexec server uses flags generically

    if (!(f = flux_rpc_pack (h,                                                                                                          
                             topic,                                                                                                      
                             rank,                                                                                                       
                             FLUX_RPC_STREAMING,                                                                                         
                             "{s:O s:i}",                                                                                                
                             "cmd", ctx->cmd,                                                                                            
                             "flags", ctx->flags))                                                                                       
        || flux_future_aux_set (f,                                                                                                       
                                "flux::rexec",                                                                                           
                                ctx,                                                                                                     
                                (flux_free_f)rexec_ctx_destroy) < 0) {                                                                   
        rexec_ctx_destroy (ctx);                                                                                                         
        goto error;                                                                                                                      
    }                                                     

so to maintain backwards compatibility we wouldn't want to rename the key in the RPC if we pass along subprocess flags in some way.

@garlick
Copy link
Member

garlick commented May 14, 2024

For background the protocol was simplified in #5004 and that is when the flags were added as a replacement for three explicit booleans that told whether some of the callbacks had been registered. See also RFC 42. (The current flags are a little bit strange and might need an audit - I was trying not to change too much)

The point of switching to a flags integer from the booleans was to make it easier to add more possibly server dependent flags. So we could add that one you mentioned if there were a need. I don't think so at the moment though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants