Why

What

bool success = false;
while (!success)
{
    _log.Information($"Attemp to login automatically to cluster {ClusterName}");
    var result = await (new RestClient()).ExecuteAsync(
        new RestRequest($"http://{instance.IPAdress}:5000/Owner/Login",Method.POST)
            .AddQueryParameter("ClusterName", ClusterName)
            .AddJsonBody(new LoginModel {
                UserName = user.UserName,
                Password = password
            })
    );

    if(result.StatusCode == HttpStatusCode.OK)
    {
        if(JsonConvert.DeserializeObject<AuthResponse>(result.Content).Token != null)
        {    
            _log.Information($"Login to cluster automatically success");
            success = true;
        }
        else
        {
						// if the username and password is wrong
            _log.Warning($"Unable to login to cluster automatically, result : {result.Content}");
            break;
        }
    }
    else
    {
			  // If the workermanager docker container is not ready
        Thread.Sleep(TimeSpan.FromSeconds(5));
    }
}