PHOENIX-MEDIA / magento2-helm

Helm Chart to deploy Magento2 in Kubernetes
38 stars 11 forks source link

ERROR: Magento\MagentoCloud\Config\EnvironmentData::getVariables(): Return value must be of type array, null returned #17

Closed ullahsalik closed 8 months ago

ullahsalik commented 8 months ago

Summary:

I am trying to deploy magento2 on EKS, following Running Magento2 in Kubernetes article.

Issue:

Pod is not coming up healthy on deploying using this magento2-helm chart, getting error in pod logs:

Logs:

******************************
** nginx server_name SETUP ***
******************************
******************************
******* POSTFIX SETUP ********
******************************
******************************
******* PHP SETUP ************
******************************
2024-03-08 14:58:15,494 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2024-03-08 14:58:15,497 INFO supervisord started with pid 1
2024-03-08 14:58:16,500 INFO spawned: 'deploy' with pid 8
2024-03-08 14:58:16,502 INFO spawned: 'nginx' with pid 9
2024-03-08 14:58:16,505 INFO spawned: 'php-fpm' with pid 10
2024-03-08 14:58:16,507 INFO spawned: 'master' with pid 11
2024-03-08 14:58:16,553 INFO success: deploy entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2024-03-08 14:58:16,553 INFO success: master entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
[08-Mar-2024 14:58:16] NOTICE: fpm is running, pid 10
[08-Mar-2024 14:58:16] NOTICE: ready to handle connections
2024-03-08 14:58:16,842 INFO exited: master (exit status 0; expected)
[2024-03-08T14:58:17.536278+00:00] INFO: Starting scenario(s): scenario/deploy.xml, vendor/phoenix-media/magento2-ece-tools/scenario/deploy/custom-mode-config.xml, vendor/phoenix-media/magento2-ece-tools/scenario/deploy/no-upgrade.xml (magento/ece-tools version: 2002.1.17, magento/magento2-base version: 2.4.6)
2024-03-08 14:58:17,536 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-03-08 14:58:17,536 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
[2024-03-08T14:58:17.822184+00:00] INFO: Deleting flag: var/.deploy_is_failed
[2024-03-08T14:58:17.837451+00:00] INFO: Deleting flag: var/.env_file_absence
[2024-03-08T14:58:17.841442+00:00] NOTICE: Starting pre-deploy.
[2024-03-08T14:58:17.841552+00:00] INFO: Set "env_file_absence" flag
[2024-03-08T14:58:17.853429+00:00] INFO: Set flag: var/.env_file_absence
[2024-03-08T14:58:17.899376+00:00] INFO: Set flag: var/.deploy_is_failed
[2024-03-08T14:58:17.900394+00:00] ERROR: Magento\MagentoCloud\Config\EnvironmentData::getVariables(): Return value must be of type array, null returned

In Processor.php line 129:

  Magento\MagentoCloud\Config\EnvironmentData::getVariables(): Return value m
  ust be of type array, null returned

In EnvironmentData.php line 127:

  Magento\MagentoCloud\Config\EnvironmentData::getVariables(): Return value m
  ust be of type array, null returned

run <scenario>...

Deployment failed. Exiting.
2024-03-08 14:58:17,976 INFO exited: deploy (exit status 0; expected)

Steps followed:

  1. Followed Running Magento2 in Kubernetes — Part 2: Building the Docker Image for building the docker image.
  2. Configured the values.yaml file with default values and passed the env variables values in plain text in deployment manifest file.
  3. Deployed the helm chart with the values.yaml

Manifest file for the magento pod:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: '2024-03-08T14:47:12Z'
  generateName: magento-6b889f4984-
  labels:
    app.kubernetes.io/instance: magento
    app.kubernetes.io/name: magento
    pod-template-hash: 6b889f4984
  name: magento-6b889f4984-8zhs9
  namespace: magento
  ownerReferences:
    - apiVersion: apps/v1
      blockOwnerDeletion: true
      controller: true
      kind: ReplicaSet
      name: magento-6b889f4984
      uid: 064d7f6d-1a66-42f7-8ef2-892a5bfe86b9
  resourceVersion: '175772536'
  uid: 6e646925-d3f4-416b-ade7-f4268aa89c53
spec:
  affinity:
    nodeAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
        - preference:
            matchExpressions:
              - key: service
                operator: In
                values:
                  - devopsCommonService
          weight: 1
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
              - key: service
                operator: In
                values:
                  - devopsCommonService
  containers:
    - env:
        - name: MAGENTO_CLOUD_ROUTES
          value: >-
            {"http://localhost/":{"type":"upstream","original_url":"http://localhost/"}}
        - name: MAGENTO_CLOUD_RELATIONSHIPS
          value: >-
           {"database":[{"host":"mysql","path":"magento","password":"topSecret","username":"magento","port":"3306"}],"redis":[{"host":"redis", "port": "6379"}],"elasticsearch":[{"host":"elasticsearch", "port": "9200", "scheme":"http"}],"rabbitmq":[{"host":"rabbitmq", "username":"phoenix", "password":"Magento123", "scheme":"amqp", "port": "5672"}]}
        - name: MAGENTO_CLOUD_VARIABLES
          value: >-
            {"ADMIN_FIRSTNAME":"Your Firstname","ADMIN_LASTNAME":"Your Lastname","ADMIN_EMAIL":"account@mail.com","ADMIN_USERNAME":"administrator","ADMIN_PASSWORD":"top@Secre1","ADMIN_URL":"admin","CRYPT_KEY":"6fg37jc529e0d9f069665cbc9fe170b2"}
      image: '<ECR>/magento:latest1'
      imagePullPolicy: IfNotPresent
      lifecycle: {}
      name: magento
      ports:
        - containerPort: 80
          name: http
          protocol: TCP
      resources: {}
      securityContext: {}
      startupProbe:
        exec:
          command:
            - cat
            - /tmp/deployed
        failureThreshold: 20
        initialDelaySeconds: 20
        periodSeconds: 10
        successThreshold: 1
        timeoutSeconds: 3
      stdin: true
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      tty: true
      volumeMounts:
        - mountPath: /var/www/html/pub/media
          name: magento-data
          subPath: media
        - mountPath: /var/www/html/var
          name: magento-data
          subPath: var
        - mountPath: /var/www/html/pub/static/_cache
          name: magento-data
          subPath: static-cache
        - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
          name: kube-api-access-vbhgq
          readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  initContainers:
    - command:
        - sh
        - '-c'
        - >-
          while ! nc -z -v -w5 redis-headless 6379 2>&1| grep -q open; do echo
          \"waiting for redis\"; sleep 1s; done
      image: busybox
      imagePullPolicy: IfNotPresent
      name: check-redis
      resources: {}
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      volumeMounts:
        - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
          name: kube-api-access-vbhgq
          readOnly: true
    - command:
        - sh
        - '-c'
        - >-
          while ! nc -z -v -w5 elasticsearch-master 9200 2>&1| grep -q open; do
          echo \"waiting for elasticsearch-master\"; sleep 1s; done
      image: busybox
      imagePullPolicy: IfNotPresent
      name: check-elasticsearch
      resources: {}
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      volumeMounts:
        - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
          name: kube-api-access-vbhgq
          readOnly: true
  nodeName: ip-10-128-28-163.ap-south-1.compute.internal
  preemptionPolicy: PreemptLowerPriority
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  tolerations:
    - effect: NoSchedule
      key: dedicated
      operator: Equal
      value: devopsCommonService
    - effect: NoExecute
      key: node.kubernetes.io/not-ready
      operator: Exists
      tolerationSeconds: 300
    - effect: NoExecute
      key: node.kubernetes.io/unreachable
      operator: Exists
      tolerationSeconds: 300
  volumes:
    - name: magento-data
      persistentVolumeClaim:
        claimName: magento-data
    - name: kube-api-access-vbhgq
      projected:
        defaultMode: 420
        sources:
          - serviceAccountToken:
              expirationSeconds: 3607
              path: token
          - configMap:
              items:
                - key: ca.crt
                  path: ca.crt
              name: kube-root-ca.crt
          - downwardAPI:
              items:
                - fieldRef:
                    apiVersion: v1
                    fieldPath: metadata.namespace
                  path: namespace

Please let me know if any solution for this error. Thanks

ullahsalik commented 8 months ago

Got the fix for this error, tried couple of things:

  1. I tried to pass all the magento cloud variables via secrets.
  2. Also db host string that i was passing, magento application was not able to connect to it. Then tried to enable the helm chart mysql db and pass it's URL (svc name).
  3. Then i passed with the default params and corrected them as required.
{"database":[{"host":"mysql","path":"magento","password":"xxxxx","username":"magento","port":"3306"}],"redis":[{"host":"redis-master", "port": "6379"}],"elasticsearch":[{"host":"elasticsearch-master", "port": "9200", "scheme":"http"}],"rabbitmq":[{"host":"rabbitmq", "username":"phoenix", "password":"xxxxx", "scheme":"amqp", "port": "5672"}]}