Skip to content

Commit

Permalink
Render: fail if no oauth image is found
Browse files Browse the repository at this point in the history
For some unknown reason, during upgrades from ACM 2.11, the template
image is briefly used, instead of the image from the openshift
imagestream. The template image is not available in disconnected
environments, and as a result causes the pods be unable to come up.

This is a problem especially for alertmanager. Because of it being a
statefulset when it gets into the bad state, with the wrong image, it
doesn't automatically recover on the next reconcile. This requires
manual intervention to fix.

Instead with this PR, we make the reconcile fail if we do not find the
oauth image. This will make it retry later, when the imagestream is able
to be found.

Signed-off-by: Jacob Baungard Hansen <[email protected]>
  • Loading branch information
jacobbaungard committed Nov 14, 2024
1 parent e5a5fbc commit 69fdfc9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func (r *MCORenderer) renderAlertManagerStatefulSet(res *resource.Resource, name
found, image = mcoconfig.GetOauthProxyImage(r.imageClient)
if found {
oauthProxyContainer.Image = image
} else {
return nil, fmt.Errorf("failed to get OAuth image for alertmanager")
}
oauthProxyContainer.ImagePullPolicy = imagePullPolicy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package rendering

import (
"fmt"
v1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -71,6 +72,8 @@ func (r *MCORenderer) renderGrafanaDeployments(res *resource.Resource,
found, image = config.GetOauthProxyImage(r.imageClient)
if found {
spec.Containers[2].Image = image
} else {
return nil, fmt.Errorf("failed to get OAuth image for Grafana")
}
spec.Containers[2].ImagePullPolicy = imagePullPolicy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package rendering

import (
"fmt"
"strings"

v1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -96,6 +97,8 @@ func (r *MCORenderer) renderProxyDeployment(res *resource.Resource,
found, image = mcoconfig.GetOauthProxyImage(r.imageClient)
if found {
spec.Containers[1].Image = image
} else {
return nil, fmt.Errorf("failed to get OAuth image for rbacqueryproxy")
}

for idx := range spec.Volumes {
Expand Down

0 comments on commit 69fdfc9

Please sign in to comment.