Skip to content

Commit

Permalink
Exclude machine controller health check when edge provider is used (#…
Browse files Browse the repository at this point in the history
…6551)

* exclude machine controller health check when edge is used

Signed-off-by: Moath Qasim <moad.qassem@gmail.com>

* document machine controller health check exclusion
Signed-off-by: Moath Qasim <moad.qassem@gmail.com>

Signed-off-by: Moath Qasim <moad.qassem@gmail.com>

---------

Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
  • Loading branch information
moadqassem committed Feb 26, 2024
1 parent 7c58a2b commit 140d3a4
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions modules/api/pkg/provider/kubernetes/cluster.go
Expand Up @@ -281,8 +281,19 @@ func (p *ClusterProvider) Get(ctx context.Context, userInfo *provider.UserInfo,
return nil, err
}
if options.CheckInitStatus {
if !cluster.Status.ExtendedHealth.AllHealthy() {
return nil, apierrors.NewServiceUnavailable("Cluster components are not ready yet")
healthCheck := cluster.Status.ExtendedHealth
// If the edge provider is used, machine controller is not deployed as part of the cluster control plane which means
// the health checks for machine controller is not needed thus we skip it.
if cluster.Spec.Cloud.ProviderName == string(kubermaticv1.EdgeCloudProvider) {
if !healthCheck.ControlPlaneHealthy() ||
healthCheck.CloudProviderInfrastructure != kubermaticv1.HealthStatusUp ||
healthCheck.UserClusterControllerManager != kubermaticv1.HealthStatusUp {
return nil, apierrors.NewServiceUnavailable("Cluster components are not ready yet")
}
} else {
if !healthCheck.AllHealthy() {
return nil, apierrors.NewServiceUnavailable("Cluster components are not ready yet")
}
}
}

Expand Down Expand Up @@ -470,10 +481,22 @@ func (p *ClusterProvider) GetUnsecured(ctx context.Context, project *kubermaticv
}
if cluster.Labels[kubermaticv1.ProjectIDLabelKey] == project.Name {
if options.CheckInitStatus {
if !cluster.Status.ExtendedHealth.AllHealthy() {
return nil, apierrors.NewServiceUnavailable("Cluster components are not ready yet")
healthCheck := cluster.Status.ExtendedHealth
// If the edge provider is used, machine controller is not deployed as part of the cluster control plane which means
// the health checks for machine controller is not needed thus we skip it.
if cluster.Spec.Cloud.ProviderName == string(kubermaticv1.EdgeCloudProvider) {
if !healthCheck.ControlPlaneHealthy() ||
healthCheck.CloudProviderInfrastructure != kubermaticv1.HealthStatusUp ||
healthCheck.UserClusterControllerManager != kubermaticv1.HealthStatusUp {
return nil, apierrors.NewServiceUnavailable("Cluster components are not ready yet")
}
} else {
if !healthCheck.AllHealthy() {
return nil, apierrors.NewServiceUnavailable("Cluster components are not ready yet")
}
}
}

return cluster, nil
}

Expand Down

0 comments on commit 140d3a4

Please sign in to comment.