Rachit Gupta
Rachit Gupta

Reputation: 11

CAP srv component fails to start upon deployment to BTP

I am refactoring my CAP project to upgrade the cds and other dependenices to the latest version but when trying to deploy the application onto BTP the srv component fails to start. All the other dependencies get staged and started except SRV component which gets staged but fails to start.

Service component deployment Logs:

2024-06-05T19:17:32.35+1000 [APP/PROC/WEB/0] ERR Debugger listening on ws://127.0.0.1:9229/987ae289-9b90-4e18-8488-c3488068c468
   2024-06-05T19:17:32.35+1000 [APP/PROC/WEB/0] ERR For help, see: https://nodejs.org/en/docs/inspector
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR node:internal/modules/cjs/loader:1143
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR throw err;
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR ^
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR Error: Cannot find module '/home/vcap/app/node_modules/@sap/cds/bin/cds.js'
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR at Module._load (node:internal/modules/cjs/loader:981:27)
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR at Function.executeUserEntryPoint [as runMain] 
(node:internal/modules/run_main:128:12)
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR at node:internal/main/run_main_module:28:49 {  
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR code: 'MODULE_NOT_FOUND',
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR requireStack: []
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR }
   2024-06-05T19:17:32.36+1000 [APP/PROC/WEB/0] ERR Node.js v18.20.2
   2024-06-05T19:17:32.37+1000 [APP/PROC/WEB/0] ERR npm ERR! code ELIFECYCLE
   2024-06-05T19:17:32.37+1000 [APP/PROC/WEB/0] ERR npm ERR! errno 1
   2024-06-05T19:17:32.37+1000 [APP/PROC/WEB/0] ERR npm ERR! [email protected] start: `node --inspect ./node_modules/@sap/cds/bin/cds.js serve gen/srv/csn.json`
   2024-06-05T19:17:32.37+1000 [APP/PROC/WEB/0] ERR npm ERR! Exit status 1
   2024-06-05T19:17:32.37+1000 [APP/PROC/WEB/0] ERR npm ERR!
   2024-06-05T19:17:32.37+1000 [APP/PROC/WEB/0] ERR npm ERR! Failed at the *emphasized text*[email protected] start script.
   2024-06-05T19:17:32.37+1000 [APP/PROC/WEB/0] ERR npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
   2024-06-05T19:17:32.39+1000 [APP/PROC/WEB/0] ERR npm ERR! A complete log of this run can be found in:
   2024-06-05T19:17:32.39+1000 [APP/PROC/WEB/0] ERR npm ERR!     /home/vcap/app/.npm/_logs/2024-06-05T09_17_32_379Z-debug.log

Main Package.json

{
    "name": "<app-name>",
    "version": "0.0.1",
    "description": "Generated by cds init",
    "license": "UNLICENSED",
    "dependencies": {
        "@sap/cds": "7.9.2",
        "@sap/hana-client": "^2.20.20",
        "@sap/xsenv": "^5.1",
        "@sap/xssec": "^3.6",
        "axios": "1.6.8",
        "dotenv": "^16.4.5",
        "express": "^4.19.2",
        "fiscal-year": "1.0.0",
        "fs-extra": "^11.2.0",
        "hdb": "^0.19.8",
        "moment": "2.30.1",
        "optionator": "^0.9.3",
        "passport": "^0.7.0",
        "replace-in-file": "^7.1.0",
        "shelljs": "^0.8.5",
        "uuid": "^9.0.1",
        "xlsx": "^0.18.5"
    },
    "engines": {
        "node": "^18"
    },
    "scripts": {
        "all:der:develop": "npm i && npm run submodule:develop && npm run build:der && npm run deploy:der",
        "submodule:develop": "git submodule foreach \"git checkout develop\" && git submodule foreach \"git pull origin develop\"",
        "submodule:master": "git submodule foreach \"git checkout master\" && git submodule foreach \"git pull origin master\"",
        "submodule:DER": "git submodule foreach \"git checkout DER\" && git submodule foreach \"git pull origin DER\"",
        "build:all": "npm run build:der && npm run build:ter && npm run build:zer",
        "build:der": "node setup.js -d DER -b",
        "deploy:der": "node setup.js -d DER -u",
        "build": "cds build"
    },
    "cds": {
        "hana": {
            "deploy-format": "hdbtable"
        },
        "requires": {
            "db": {
                "kind": "hana",
                "model": [
                    "db",
                    "srv"
                ]
            }
        },
        "auth": "xsuaa",
        "odata": {
            "version": "v4"
        }
    },
    "files": [
        "db",
        "srv"
    ],
    "devDependencies": {
        "appdata-path": "^1.0.0",
        "ncp": "^2.0.0",
        "rimraf": "^5.0.5"
    }
}

srv/package.json

{
    "name": "<app-name>",
    "description": "Generated from ../package.json, do not change!",
    "version": "1.0.0",
    "dependencies": {
        "@sap/cds": "7.8.1",
        "@sap/hana-client": "2.20.20",
        "@sap/xsenv": "^5.1.0",
        "@sap/xssec": "^3.6.1",
        "axios": "1.6.8",
        "currency-symbol": "1.0.6",
        "dotenv": "^16.4.5",
        "express": "^4.19.2",
        "fiscal-year": "1.0.0",
        "helmet": "^7.1.0",
        "moment": "^2.30.1",
        "passport": "^0.7.0",
        "uuid": "^9.0.1",
        "xlsx": "^0.18.5"
    },
    "engines": {
        "node": "^18",
        "npm": "^6"
    },
    "devDependencies": {},
    "scripts": {
        "postinstall": "npm dedupe && node .build.js",
        "start": "node --inspect ./node_modules/@sap/cds/bin/cds.js serve gen/srv/csn.json",
        "watch": "nodemon -w . -i node_modules/**,.git/** -e cds -x npm run build"
    },
    "private": true,
    "cds": {
        "requires": {
            "db": {
                "kind": "hana",
                "model": "gen/srv/csn.json"
            },
            "auth": {
                "kind": "xsuaa"
            }
        },
        "auth":"jwt"
    }
}

MTA.yaml of the project:

ID: <app-name>
_schema-version: "2.1"
parameters:
  deploy_mode: html5-repo
  enable-parallel-deployments: true
version: 1.1.0
modules:
  - name: <app-name>-approuter
    type: approuter.nodejs
    path: approuter
    parameters:
      routes:
          - route: <client-name>-<app-name>.cfapps.ap10.hana.ondemand.com
      disk-quota: 256M
      memory: 256M
      buildpack: nodejs_buildpack
      stack: cflinuxfs4 
    requires:
      - name: <app-name>_html5_repo_runtime
      - name: dest_<app-name>
      - name: srv_api
        group: destinations
        properties:
          forwardAuthToken: true
          name: srv_api
          strictSSL: false
          url: "~{url}"
          timeout: 300000
      - name: uaa_<app-name>
    properties:
      SAP_JWT_TRUST_ACL:
        - clientid: "*"
          identityzone: "*"
  - name: <app-name>-ui-deployer
    type: com.sap.html5.application-content
    path: ui_deployer
    parameters:
      disk-quota: 256M
      memory: 256M
      buildpack: nodejs_buildpack
      stack: cflinuxfs4 
    requires:
      - name: <app-name>_html5_repo_host
    build-parameters:
      requires:
        - name: forecasts
          artifacts:
            - "./*"
          target-path: resources/forecasts
        - name: customerSettings
          artifacts:
            - "./*"
          target-path: resources/customerSettings
        - name: users
          artifacts:
            - "./*"
          target-path: resources/users
        - name: reports
          artifacts:
            - "./*"
          target-path: resources/reports
  - name: forecasts
    type: html5
    path: forecasts
    build-parameters:
      builder: custom
      commands:
        - npm install
        - npm run build
      supported-platforms: []
      build-result: dist
  - name: customerSettings
    type: html5
    path: customerSettings
    build-parameters:
      builder: custom
      commands:
        - npm install
        - npm run build
      supported-platforms: []
      build-result: dist
  - name: users
    type: html5
    path: users
    build-parameters:
      builder: custom
      commands:
        - npm install
        - npm run build
      supported-platforms: []
      build-result: dist
  - name: reports
    type: html5
    path: reports
    build-parameters:
      builder: custom
      commands:
        - npm install
        - npm run build
      supported-platforms: []
      build-result: dist
  - name: <app-name>-db
    type: hdb
    path: db
    parameters:
      memory: 128M
      disk-quota: 512M
      buildpack: nodejs_buildpack
      stack: cflinuxfs4 
    requires:
      - name: <app-name>-db-hdi-container
        properties:
          TARGET_CONTAINER: "~{hdi-container-name}"
      - name: external_access
        group: SERVICE-REPLACEMENTS
        properties:
          external_access: "~[ups-service-name}"
  - name: <app-name>-srv
    type: nodejs
    path: srv
    parameters:
      memory: 1664M
      disk-quota: 512M
      buildpack: nodejs_buildpack
      stack: cflinuxfs4 
    provides:
      - name: srv_api
        properties:
          url: "${default-url}"
    requires:
      - name: <app-name>-db-hdi-container
      - name: uaa_<app-name>
      - name: autoscaler_<app-name>
        parameters:
            path: ./autoscaler-config.json      
    properties:
      SAP_JWT_TRUST_ACL:
        - clientid: "*"
          identityzone: "*"
resources:
  - name: <app-name>_html5_repo_runtime
    parameters:
      service: html5-apps-repo
      service-plan: app-runtime
      service-name: <app-name>_html5_repo_runtime
    type: org.cloudfoundry.managed-service
  - name: <app-name>_html5_repo_host
    parameters:
      service: html5-apps-repo
      service-plan: app-host
      service-name: <app-name>_html5_repo_host
    type: org.cloudfoundry.managed-service
  - name: uaa_<app-name>
    parameters:
      path: ./xs-security.json
      service-plan: application
      service: xsuaa
      config:
        xsappname: "<app-name>"
        tenant-mode: dedicated
    type: org.cloudfoundry.managed-service
  - name: dest_<app-name>
    parameters:
      service-plan: lite
      service: destination
    type: org.cloudfoundry.managed-service
  - name: <app-name>-db-hdi-container
    type: com.sap.xs.hdi-container
    properties:
      hdi-container-name: "${service-name}"
  - name: external_access
    type: org.cloudfoundry.user-provided-service
    parameters:
      service-name: <app-name>-HDIGrantService
      config:
        driver: com.sap.db.jdbc.Driver
        tags: ["hana"]
        schema: <schema_name>
        user: userid
        password: password
    properties:
      ups-service-name: "${service-name}"
  - name: autoscaler_<app-name>
    parameters:
      service: autoscaler
      service-plan: standard
    type: org.cloudfoundry.managed-service

I would appreciate any help to resolve this issue. Thanks!

My workflow:

  1. Clone the project on VS Code.
  2. Check each and every package.json file in the project run ncu and ncu -u to upgrade dependencies.
  3. Tried testing the changes locally using default-env.json runs fine without issues, able to test it out on approuter on localhost.
  4. Trying to deploy the project onto BTP all the components gets staged except srv, srv deployment fails, mtar gets build successfully. logs provided, checked quota plenty of memory available.
  5. CDS build command sucessfully generates all the artifiacts including csn.json and places it inside srv -->gen folder.

Upvotes: 0

Views: 239

Answers (0)

Related Questions