Merge pull request #805 from eclipse-che/dashboard_sl

fix: Add common selector for che-dashboard
pull/808/head
Flavius Lacatusu 2021-04-29 08:45:59 +02:00 committed by GitHub
commit 7444b8c807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View File

@ -18,7 +18,7 @@ import (
const (
// DashboardComponent which is supposed to be used for the naming related objects
DashboardComponent = "dashboard"
DashboardComponent = "che-dashboard"
)
type Dashboard struct {

View File

@ -60,21 +60,21 @@ func TestDashboardAll(t *testing.T) {
// check service
service := &corev1.Service{}
err = cli.Get(context.TODO(), types.NamespacedName{Name: "dashboard", Namespace: "eclipse-che"}, service)
err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, service)
if err != nil {
t.Fatalf("Service not found: %v", err)
}
// check endpoint
route := &routev1.Route{}
err = cli.Get(context.TODO(), types.NamespacedName{Name: "dashboard", Namespace: "eclipse-che"}, route)
err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, route)
if err != nil {
t.Fatalf("Route not found: %v", err)
}
// check deployment
deployment := &appsv1.Deployment{}
err = cli.Get(context.TODO(), types.NamespacedName{Name: "dashboard", Namespace: "eclipse-che"}, deployment)
err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, deployment)
if err != nil {
t.Fatalf("Deployment not found: %v", err)
}

View File

@ -24,7 +24,8 @@ import (
func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
terminationGracePeriodSeconds := int64(30)
labels := deploy.GetLabels(p.deployContext.CheCluster, DashboardComponent)
labels, labelsSelector := deploy.GetLabelsAndSelector(p.deployContext.CheCluster, DashboardComponent)
dashboardImageAndTag := util.GetValue(p.deployContext.CheCluster.Spec.Server.DashboardImage, deploy.DefaultDashboardImage(p.deployContext.CheCluster))
pullPolicy := corev1.PullPolicy(util.GetValue(p.deployContext.CheCluster.Spec.Server.DashboardImagePullPolicy, deploy.DefaultPullPolicyFromDockerImage(dashboardImageAndTag)))
@ -39,7 +40,7 @@ func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
Labels: labels,
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels},
Selector: &metav1.LabelSelector{MatchLabels: labelsSelector},
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType,
},