bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
9.02k stars 9.22k forks source link

[bitnami/magento] No possibility to run cron job when running in the non-root mode #23174

Closed crdev closed 8 months ago

crdev commented 9 months ago

Name and Version

bitnami/magento 25.2.3

What architecture are you using?

amd64

What steps will reproduce the bug?

Are you using any custom parameters or values?

magentoEmail: foo@bar.com
magentoDeployStaticContent: true
allowEmptyPassword: false

What is the expected behavior?

Cron job runs as expected.

What do you see instead?

A One or more indexers are invalid. Make sure your Magento cron job is running. error in the admin panel

$ kubectl logs magento-2-4-6-xyz-2xyzz | grep cron
magento 09:09:36.01 WARN  ==> Skipping cron configuration for Magento because of running as a non-root user

Additional information

github-actions[bot] commented 8 months ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

fevisera commented 8 months ago

Hi @crdev,

Sorry for the delay. I'm trying to reproduce the issue you reported. Could you please provide the details on how you get those logs? I could deploy the chart but none of the pods contains the cron log you described.

$ helm install -f my-values.yaml magento-2-4-6 oci://registry-1.docker.io/bitnamicharts/magento
$ k get po -w
NAME                                         READY   STATUS    RESTARTS   AGE
magento-2-4-6-elasticsearch-coordinating-0   1/1     Running   0          3m56s
magento-2-4-6-elasticsearch-data-0           1/1     Running   0          3m56s
magento-2-4-6-elasticsearch-ingest-0         1/1     Running   0          3m56s
magento-2-4-6-elasticsearch-master-0         1/1     Running   0          3m56s
magento-2-4-6-mariadb-0                      1/1     Running   0          3m56s

Thanks!

crdev commented 8 months ago

Hey @fevisera, it looks like you are actually missing the application pod, no? Only elasticsearch and maradb pods won't suffice. If you don't see the app pod, I guess you are running into a bigger problem.

fevisera commented 8 months ago

Hi @crdev,

I managed to resolve the local issue and successfully got Magento up and running. However, I am unable to identify the error in the Admin Panel. I navigated to "System > Index Management", and found that all indexes are showing as "Ready" status.

Image

Could you please specify the URL where you are encountering that error?

Related to the log warning, that comes from https://github.com/bitnami/containers/blob/main/bitnami/magento/2/debian-12/rootfs/opt/bitnami/scripts/libmagento.sh#L377-L382. You can disable the non-root behavior by setting the parameters containerSecurityContext.runAsUser to root.

crdev commented 8 months ago

I was seeing this message in a top bar across all pages in the Admin panel. Also, since the update mode is set to UPDATE ON SAVE, you don't in fact need Cron to update indices. Try switching indexers to the UPDATE ON SCHEDULE mode and changing various shop settings.

Regarding containerSecurityContext.runAsUser, I'm aware of this option, however running as a non-root user is specifically advertised as a higher-security setup.

fevisera commented 8 months ago

Hi @crdev,

I switched it to on schedule but I still do not see the indexers error message in the browsers.

I also ran the reindex command and it went successfully:

$ kubectl exec -it magento-2-4-6-748bd4f9b8-vtgzm -- /bin/bash
I have no name!@magento-2-4-6-748bd4f9b8-vtgzm:/$ magento indexer:reindex
Design Config Grid index has been rebuilt successfully in 00:00:00
Customer Grid index has been rebuilt successfully in 00:00:00
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:00
Stock index has been rebuilt successfully in 00:00:00
Inventory index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:00

After running that command the values in the "Updated" column were refreshed.

image

Additionally, I see some crontab configured too:

I have no name!@magento-2-4-6-748bd4f9b8-vtgzm:/$ magento config:show
...
crontab/default/jobs/analytics_subscribe/schedule/cron_expr - 0 * * * *
crontab/default/jobs/analytics_collect_data/schedule/cron_expr - 00 02 * * *
...
I have no name!@magento-2-4-6-748bd4f9b8-vtgzm:/$ magento cron:run
Ran jobs by schedule.

Do you have any other scenario in mind so I can try to reproduce the error?

github-actions[bot] commented 8 months ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] commented 8 months ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.