Skip to content

Commit

Permalink
Merge pull request #2893 from a-dsouza/match-label
Browse files Browse the repository at this point in the history
fix(ho): Restore match label selector behavior
  • Loading branch information
openshift-merge-robot committed Aug 22, 2023
2 parents 9b25e74 + 027332a commit e6c6892
Showing 1 changed file with 8 additions and 25 deletions.
Expand Up @@ -487,7 +487,9 @@ func reconcileDeployment(deployment *appsv1.Deployment,
// it got also silently included in MatchLabels. This made any additional additionalLabel to break reconciliation because MatchLabels is an immutable field.
// So now we leave Selector.MatchLabels if it has something already and use a different var from .Labels so the former is not impacted by additionalLabels changes.
selectorLabels := ignitionServerLabels
isSelectorSet := false
if deployment.Spec.Selector != nil && deployment.Spec.Selector.MatchLabels != nil {
isSelectorSet = true
selectorLabels = deployment.Spec.Selector.MatchLabels
}

Expand Down Expand Up @@ -528,18 +530,6 @@ func reconcileDeployment(deployment *appsv1.Deployment,
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
{
Name: "bootstrap-manifests",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
{
Name: "manifests",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
},
Containers: []corev1.Container{
{
Expand Down Expand Up @@ -609,14 +599,6 @@ func reconcileDeployment(deployment *appsv1.Deployment,
Name: "payloads",
MountPath: "/payloads",
},
{
Name: "bootstrap-manifests",
MountPath: "/usr/share/bootkube/manifests/bootstrap-manifests",
},
{
Name: "manifests",
MountPath: "/usr/share/bootkube/manifests/manifests",
},
},
},
},
Expand All @@ -632,15 +614,16 @@ func reconcileDeployment(deployment *appsv1.Deployment,
}
}

deploymentConfig := config.DeploymentConfig{
AdditionalLabels: map[string]string{
config.NeedManagementKASAccessLabel: "true",
},
}
deploymentConfig := config.DeploymentConfig{}
deploymentConfig.Scheduling.PriorityClass = config.DefaultPriorityClass
deploymentConfig.SetRestartAnnotation(hcp.ObjectMeta)
deploymentConfig.SetDefaults(hcp, ignitionServerLabels, nil)
deploymentConfig.ApplyTo(deployment)
// Intentionally syncing selector matchLabels and pod template Labels
// to preserve existing 4.9 and 4.10 reconciliation behavior.
if !isSelectorSet {
deployment.Spec.Selector.MatchLabels = deployment.Spec.Template.ObjectMeta.Labels
}

return nil
}
Expand Down

0 comments on commit e6c6892

Please sign in to comment.