mirror of
				https://github.com/nitnelave/lldap.git
				synced 2023-04-12 14:25:13 +00:00 
			
		
		
		
	server: Fix healthcheck return code
The healthcheck was not returning a non-zero code when failing, due to an extra layer of Results
This commit is contained in:
		
							parent
							
								
									955a559c21
								
							
						
					
					
						commit
						f36e088125
					
				@ -99,6 +99,7 @@ fn get_tls_connector() -> Result<RustlsTlsConnector> {
 | 
				
			|||||||
#[instrument(skip_all, level = "info", err)]
 | 
					#[instrument(skip_all, level = "info", err)]
 | 
				
			||||||
pub async fn check_ldaps(ldaps_options: &LdapsOptions) -> Result<()> {
 | 
					pub async fn check_ldaps(ldaps_options: &LdapsOptions) -> Result<()> {
 | 
				
			||||||
    if !ldaps_options.enabled {
 | 
					    if !ldaps_options.enabled {
 | 
				
			||||||
 | 
					        info!("LDAPS not enabled");
 | 
				
			||||||
        return Ok(());
 | 
					        return Ok(());
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    let tls_connector = get_tls_connector()?;
 | 
					    let tls_connector = get_tls_connector()?;
 | 
				
			||||||
 | 
				
			|||||||
@ -158,6 +158,8 @@ fn run_healthcheck(opts: RunOpts) -> Result<()> {
 | 
				
			|||||||
        .enable_all()
 | 
					        .enable_all()
 | 
				
			||||||
        .build()?;
 | 
					        .build()?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    info!("Starting healthchecks");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    use tokio::time::timeout;
 | 
					    use tokio::time::timeout;
 | 
				
			||||||
    let delay = Duration::from_millis(3000);
 | 
					    let delay = Duration::from_millis(3000);
 | 
				
			||||||
    let (ldap, ldaps, api) = runtime.block_on(async {
 | 
					    let (ldap, ldaps, api) = runtime.block_on(async {
 | 
				
			||||||
@ -168,14 +170,18 @@ fn run_healthcheck(opts: RunOpts) -> Result<()> {
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let mut failure = false;
 | 
					    let failure = [ldap, ldaps, api]
 | 
				
			||||||
    [ldap, ldaps, api]
 | 
					 | 
				
			||||||
        .into_iter()
 | 
					        .into_iter()
 | 
				
			||||||
        .filter_map(Result::err)
 | 
					        .flat_map(|res| {
 | 
				
			||||||
        .for_each(|e| {
 | 
					            if let Err(e) = &res {
 | 
				
			||||||
            failure = true;
 | 
					                error!("Error running the health check: {:#}", e);
 | 
				
			||||||
            error!("{:#}", e)
 | 
					            }
 | 
				
			||||||
        });
 | 
					            res
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        .any(|r| r.is_err());
 | 
				
			||||||
 | 
					    if failure {
 | 
				
			||||||
 | 
					        error!("Healthcheck failed");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    std::process::exit(i32::from(failure))
 | 
					    std::process::exit(i32::from(failure))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user