Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ho): Restore match label selector behavior #2893

Merged
merged 2 commits into from Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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