Why
- User can enter the wrong name they already register to the system ⇒ server recognize server as self-managed cluster.
- The information needed while register to cluster is redundant ⇒ it take more step to setup
- User have to redirect to cluster UI to setup cluster ⇒ take more time to setup
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));
}
}