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

quick fix for https://issues.redhat.com/browse/RHIDP-1701 #273

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
20 changes: 16 additions & 4 deletions controllers/backstage_deployment.go
Expand Up @@ -195,11 +195,23 @@ func (r *BackstageReconciler) validateAndUpdatePsqlSecretRef(backstage bs.Backst

func (r *BackstageReconciler) setDefaultDeploymentImage(deployment *appsv1.Deployment) {
if envBackstageImage != "" {
visitContainers(&deployment.Spec.Template, func(container *v1.Container) {
container.Image = envBackstageImage

})
for _, c := range deployment.Spec.Template.Spec.Containers {
if c.Name == _defaultBackstageMainContainerName {
Copy link
Member

@rm3l rm3l Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest replacing based on a placeholder instead. Otherwise, if user changes the config to use their own images for the main and/or init containers, they will still be replaced here; so same issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that we have the same issue with the DB StatefulSet as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand about placeholder. Could you please elaborate?

For the database: Do you see any option for extension it's deployment in the Helm Chart?
(I just would keep this fix as simple as possible)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand about placeholder. Could you please elaborate?

I mean, use by default a placeholder like <RELATED_IMAGE_backstage> in the default deployment.yaml manifest, and perform replacements only for places where this placeholder is used explicitly. This way, it is clear that only these placeholders will be replaced, regardless of the container names.
I remember I saw something like this in a PR (83c7187 (#86)), but it was changed at some point later 😕

For the database: Do you see any option for extension it's deployment in the Helm Chart?
(I just would keep this fix as simple as possible)

Maybe not extend it with an extra-container (or why not actually?), but I was thinking of just trying to use a different DB image for example (which is possible in the Helm Chart). Right now, this is not configurable in the CR, so the only way to do this would be via the rawRuntimeConfig, but the image would end up being replaced.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand about placeholder. Could you please elaborate?

I mean, use by default a placeholder like <RELATED_IMAGE_backstage> in the default deployment.yaml manifest, and perform replacements only for places where this placeholder is used explicitly. This way, it is clear that only these placeholders will be replaced, regardless of the container names. I remember I saw something like this in a PR (83c7187 (#86)), but it was changed at some point later 😕

And here for the logic: https://github.com/janus-idp/operator/pull/86/files#diff-8e7e7c9a64394f1ee039417ef32b84b7122580096d39f293a8d976bd2af27f45R308-R314

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, if you use <RELATED_IMAGE_backstage> in deployment.yaml, what would be the value if I do not put env variable?

I remember I saw something like this in a PR (83c7187 (#86)), but it was changed at some point later

I guess, the changes you mentioned caused by the fact that in this case we have to use somehow hardcoded value which is not good.

Maybe not extend it with an extra-container (or why not actually?), but I was thinking of just trying to use a different DB image for example (which is possible in the Helm Chart). Right now, this is not configurable in the CR, so the only way to do this would be via the rawRuntimeConfig, but the image would end up being replaced.

OK, Let's move this discussion to the issue?
My point here is to fix concrete problem and so far I can not see it changed anything else but fix it :) . WDYT?

c.Image = envBackstageImage
}
}
for _, c := range deployment.Spec.Template.Spec.InitContainers {
if c.Name == _defaultBackstageInitContainerName {
c.Image = envBackstageImage
}
}
}
//if envBackstageImage != "" {
// visitContainers(&deployment.Spec.Template, func(container *v1.Container) {
// container.Image = envBackstageImage
//
// })
//}
}

func (r *BackstageReconciler) applyBackstageLabels(backstage bs.Backstage, deployment *appsv1.Deployment) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -50,7 +50,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sys v0.16.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -116,8 +116,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 h1:tnebWN09GYg9OLPss1KXj8txwZc6X6uMr6VFdcGNbHw=
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
Expand Down