Skip to content

Commit

Permalink
Merge pull request #543 from tchughesiv/runtimeFixes7.9.0
Browse files Browse the repository at this point in the history
[RHPAM-3296] console ownerRef fix for ocp 4.6.1+
  • Loading branch information
openshift-merge-robot authored Nov 9, 2020
2 parents 3f4db70 + df3f2d4 commit b13db2d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/controller/kieapp/deploy_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

var consoleName = "console-cr-form"
Expand All @@ -54,11 +55,12 @@ func deployConsole(reconciler *Reconciler, operator *appsv1.Deployment) {
pod := getPod(namespace, image, sa.Name, reconciler.OcpVersion, operator)
service := getService(namespace, reconciler.OcpVersion)
route := getRoute(namespace)
scheme := reconciler.Service.GetScheme()
// `inject-trusted-cabundle` ConfigMap only supported in OCP 4.2+
if semver.Compare(reconciler.OcpVersion, "v4.2") >= 0 || reconciler.OcpVersion == "" {
existing := &corev1.ConfigMap{}
new := getCaConfigMap(namespace)
new.SetOwnerReferences(operator.GetOwnerReferences())
controllerutil.SetOwnerReference(operator, new, scheme)
if err := reconciler.Service.Get(context.TODO(), types.NamespacedName{Name: new.Name, Namespace: new.Namespace}, existing); err != nil {
if errors.IsNotFound(err) {
log.Info("Creating ConfigMap ", new.Name)
Expand All @@ -71,7 +73,7 @@ func deployConsole(reconciler *Reconciler, operator *appsv1.Deployment) {
} else {
if !reflect.DeepEqual(existing.Labels, new.Labels) {
existing.Labels = new.Labels
existing.SetOwnerReferences(operator.GetOwnerReferences())
controllerutil.SetOwnerReference(operator, existing, scheme)
log.Info("Updating ConfigMap ", existing.Name)
if err := reconciler.Service.Update(context.TODO(), existing); err != nil {
log.Error("failed to update configmap", err)
Expand All @@ -87,7 +89,7 @@ func deployConsole(reconciler *Reconciler, operator *appsv1.Deployment) {
}
comparator := compare.NewMapComparator()
deltas := comparator.Compare(deployed, requested)
writer := write.New(reconciler.Service).WithOwnerReferences(operator.GetOwnerReferences()...)
writer := write.New(reconciler.Service).WithOwnerController(operator, scheme)
var hasUpdates bool
for resourceType, delta := range deltas {
if !delta.HasChanges() {
Expand Down

0 comments on commit b13db2d

Please sign in to comment.