cancel
Showing results for 
Search instead for 
Did you mean: 

CF Deployment Error: Error getting tenant t0

maximilian_pfab
Explorer

Hello Community & Experts,

I have a problem related to the deployment of my service.

The Hana Cloud is already linked via the instance mapping and the deployment has already been deployed once.

Now I get sporadically the following error, no matter if it's a fresh deployment or just an update:

 

 

 

2024-04-19T07:54:11.965+0000 [APP/PROC/WEB/0] STDOUT [cds] - loaded model from 1 file(s):
2024-04-19T07:54:11.965+0000 [APP/PROC/WEB/0] STDOUT ../deps/0/node_modules/@sap/cds-mtxs/db/t0.cds
2024-04-19T07:54:11.970+0000 [APP/PROC/WEB/0] STDOUT [mtx] - retrieving { tenants: [ 't0' ] } { uncached: [ 't0' ] }
2024-04-19T07:54:12.176+0000 [APP/PROC/WEB/0] STDOUT [mtx] - GET https://service-manager.cfapps.eu10.hana.ondemand.com/v1/service_offerings { params: { fieldQuery: "catalog_name eq 'hana'" } }
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR /home/vcap/deps/0/node_modules/@sap/cds-mtxs/srv/plugins/hana/srv-mgr.js:70
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR cds.error(_errorMessage(e, 'getting', tenant), { status: e.status ?? 500 })
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR ^
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR Error: Error getting tenant t0: Could not find service offering with catalog_name eq 'hana'
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at get (/home/vcap/deps/0/node_modules/@sap/cds-mtxs/srv/plugins/hana/srv-mgr.js:70:9)
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at async Object.acquire (/home/vcap/deps/0/node_modules/@sap/cds-mtxs/srv/plugins/hana/srv-mgr.js:58:16)
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at async ApplicationService.<anonymous> (/home/vcap/deps/0/node_modules/@sap/cds-mtxs/srv/plugins/hana.js:63:38)
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at async next (/home/vcap/deps/0/node_modules/@sap/cds/lib/srv/srv-dispatch.js:68:17)
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at async ApplicationService.handle (/home/vcap/deps/0/node_modules/@sap/cds/lib/srv/srv-dispatch.js:66:10)
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at async /home/vcap/deps/0/node_modules/@sap/cds-mtxs/srv/plugins/common.js:67:23
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at async module.exports.resubscribeT0IfNeeded (/home/vcap/deps/0/node_modules/@sap/cds-mtxs/srv/plugins/common.js:65:5)
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at async cds.emit (/home/vcap/deps/0/node_modules/@sap/cds/lib/index.js:13:62)
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR at async cds_server (/home/vcap/deps/0/node_modules/@sap/cds/server.js:40:3) {
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR status: 500
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR }
2024-04-19T07:54:12.246+0000 [APP/PROC/WEB/0] STDERR Node.js v18.19.1

 

 

 

This is my configuration of the MTA YAML File:

 

 

 

_schema-version: "3.1"
ID: myservice
version: 0.0.5
description: "CAP: Message Master Data Service"

parameters:
  enable-parallel-deployments: true
build-parameters:
  before-all:
    - builder: custom
      commands:
        - npm install --include=dev
        - npx cds build --production

modules:
  # --------------------- APP ROUTER ------------------------
  - name: myservice
  # ------------------------------------------------------------
    type: approuter.nodejs
    path: app/router
    build-parameters:
      builder: custom
      commands: []
      ignore: [ '.DS_Store', 'node_modules/', 'default-env.json', 'manifest*.yml' ]
    parameters:
      app-name: myservice-${space}
      app-domain: ${app-name}.${default-domain}
      keep-existing-routes: true
      disk-quota: 256M
      memory: 256M
    properties:
      TENANT_HOST_PATTERN: "^(.*)-${default-uri}"
    requires:
      - name: myservice-srv-api
        group: destinations
        properties:
          name: srv-api # must be used in xs-app.json as well
          url: ~{srv-url}
          forwardAuthToken: true
      - name: myservice-auth
      - name: myservice-destination
    provides:
      - name: myservice-router
        properties:
          app-protocol: ${protocol}
          app-url: ${default-url}
          app-uri: ${default-uri}
          app-domain: ${app-domain}
          application: ${app-name}

  # --------------------- SERVER MODULE ------------------------
  - name: myservice-srv
  # ------------------------------------------------------------
    type: nodejs
    path: gen/srv
    build-parameters:
      builder: npm
      ignore:
        - '.DS_Store'
        - 'node_modules/'
        - 'default-*.json'
        - 'manifest*.yml'
    parameters:
      app-name: myservice-srv-${space}
      app-domain: ${app-name}.${default-domain}
      buildpack: nodejs_buildpack
      memory: 256MB
      disk-quota: 2024MB
      keep-existing-routes: true
    requires:
      - name: myservice-auth
      - name: myservice-api-auth
      - name: myservice-db
      - name: myservice-destination
    provides:
      - name: myservice-srv-api # required by consumers of CAP services (e.g. approuter)
        properties:
          srv-url: ${default-url}
          srv-name: ${app-name}
          app-domain: ${app-domain}

  # ----------- MTX MODULE ----------
  - name: myservice-mtx
  # ------------------------------------------------------------
    type: nodejs
    path: gen/mtx/sidecar
    build-parameters:
      builder: npm-ci
      ignore:
        - '.DS_Store'
        - 'node_modules/'
        - 'default-*.json'
        - 'manifest*.yml'
    parameters:
      app-name: myservice-mtx-${space}
      memory: 128M
      disk-quota: 512MB
    properties:
      appName: ~{myservice-router/application}
      approuterUri: ~{myservice-router/app-uri}
      appDomain: ~{myservice-router/app-domain}
      brokerName: ~{myservice-sb-srv/app-name}
      brokerUrl: ~{myservice-sb-srv/srv-url}
      tenantSeparator: '-'
    requires:
      - name: myservice-srv-api
      - name: myservice-sb-srv
      - name: myservice-auth
      - name: myservice-db
      - name: myservice-registry
      - name: myservice-destination
      - name: myservice-service-manager-admin
      - name: myservice-router
    provides:
      - name: myservice-mtx-api
        properties:
          mtx-url: ${default-url}

  # ----------- BROKER MODULE (OSBAPI Implementation) ----------
  - name: myservice-sb
  # ------------------------------------------------------------
    type: nodejs
    path: broker
    build-parameters:
      builder: custom
      commands:
        []
      ignore:
        - '.DS_Store'
        - 'node_modules/'
        - 'default-*.json'
        - 'manifest*.yml'
    parameters:
      app-name: myservice-sb-${space}
      memory: 128MB
      disk-quota: 512MB
    properties:
      SBF_ENABLE_AUDITLOG: false
      SBF_CATALOG_FILE: ./catalog.json
      SBF_CATALOG_SUFFIX: ${space}-${org}
      SBF_SERVICE_CONFIG:
        myservice-api:
          extend_credentials:
            shared:
              apiUrl: ~{myservice-srv-api/srv-url}
          extend_xssecurity:
            per_plan:
              default:
                authorities:
                  - $XSMASTERAPPNAME.plan_default
          extend_catalog:
            metadata:
              displayName: Message Service API (${org} - ${space})
      SBF_BROKER_CREDENTIALS_HASH: >
        {
          "broker-user": "<Broker-Hash-PW>"
        }
    requires:
      - name: myservice-api-auth
      - name: myservice-srv-api
    provides:
      - name: myservice-sb-srv
        properties:
          app-name: ${app-name}
          srv-url: ${default-url}

resources:
  # ----------------- XSUAA - Service  -------------------------
  - name: myservice-auth
  # ------------------------------------------------------------
    type: org.cloudfoundry.managed-service
    properties:
      xsuaa-app: ${xsuaa-app}
      XSAPPNAME: ${xsuaa-app}
    parameters:
      service: xsuaa
      service-name: ${space}-myservice-auth
      service-plan: application
      path: ./xs-security.json
      xsuaa-app: myservice-${space}-${org}
      config:
        xsappname: ${xsuaa-app}
        tenant-mode: shared
    requires:
      - name: myservice-router

  # ----------------- XSUAA - Broker ----------------------------
  - name: myservice-api-auth
  # -------------------------------------------------------------
    type: org.cloudfoundry.managed-service
    properties:
      xsuaa-app: ${xsuaa-app}
    parameters:
      service: xsuaa
      service-name: ${space}-myservice-api-auth
      service-plan: broker
      xsuaa-app: myservice-api-${space}-${org}
      config:
        xsappname: ${xsuaa-app}

  # ----------------------- HDI SERVICE ------------------------
  - name: myservice-db
  # ------------------------------------------------------------
    type: org.cloudfoundry.managed-service
    parameters:
       service: service-manager
       service-name: ${space}-myservice-db
       service-plan: container
       service-tags:
        - "hana"
    properties:
      hdi-service-name: ${service-name}

  # ----------------- DESTINATION SERVICE ----------------------
  - name: myservice-destination
  # ------------------------------------------------------------
    type: org.cloudfoundry.managed-service
    parameters:
      service-plan: lite
      service-name: ${space}-myservice-destination
      service: destination

  # -------------- SERVICE MANAGER SERVICE ADMIN ---------------
  - name: myservice-service-manager-admin
  # ------------------------------------------------------------
    type: org.cloudfoundry.managed-service
    parameters:
      service: service-manager
      service-name: ${space}-myservice-service-manager-admin
      service-plan: subaccount-admin

  # ----------------------- MTX SERVICE ------------------------
  - name: myservice-registry
  # ------------------------------------------------------------
    type: org.cloudfoundry.managed-service
    requires:
      - name: myservice-auth
      - name: myservice-mtx-api
      - name: myservice-router
    parameters:
      service: saas-registry
      service-name: ${space}-myservice-registry
      service-plan: application
      config:
        xsappname: ~{myservice-auth/xsuaa-app}
        appName: ~{myservice-auth/xsuaa-app}
        displayName: 'Message Service (${org} - ${space})'
        description: >
          A service to get the Message + Texts.
        category: 'Custom'
        appUrls:
          getDependencies: ~{myservice-mtx-api/mtx-url}/-/cds/saas-provisioning/dependencies
          onSubscription: ~{myservice-mtx-api/mtx-url}/-/cds/saas-provisioning/tenant/{tenantId}
          onSubscriptionAsync: true
          onUnSubscriptionAsync: true
          onUpdateDependenciesAsync: true
          callbackTimeoutMillis: 300000 # Increase if your deployments are taking longer than that
        appPlans:
          - name: default
            description: Default plan

 

 

 

Did anybody had those type of issue yet?

Dinu
Contributor
0 Kudos
What is the version of cds and mtx in the installation? Command "cds -v" would tell you the version installed.
Dinu
Contributor
0 Kudos
Do you see this error in the sidecar or in the main app?
sjain511
Explorer
0 Kudos
I have the same issue, i have two service managers and the deployment is very flaky.
View Entire Topic
Dinu
Contributor
0 Kudos

The issue may be that you have two service-manager instances bound to the sidecar app. CAP is not consistent in choosing one or the other for db service. You could tag the right one as db or hana to make the choice clear to CAP. 

maximilian_pfab
Explorer
0 Kudos

I already did that but still get the issue 😞

maximilian_pfab
Explorer
0 Kudos

I update the MTA for you above.

Dinu
Contributor
0 Kudos

Since vcap.label is set, I guess tags are not used for filtering. Try setting vcap.plan as container. 

"db": { 
 "vcap": { "plan": "container" } 
}

 

maximilian_pfab
Explorer
0 Kudos

Where do I have to add it?
In the package.json?
If yes in the one from the sidecar or the one directly from the service?

Is the structure then like that?

"cds": {
		"profile": "mtx-sidecar",
		"requires": {
			"[production]": {
				"auth": "xsuaa",
				"db": {
					"kind": "hana",
					"vcap": {
						"plan": "container"
					}
				},
				"multitenancy": true
			}
		}
	}
}

 

Dinu
Contributor
0 Kudos

Yes. There is only one package.json. Is it not? The change is needed only for sidecar as only this has two bindings to service manager. 

maximilian_pfab
Explorer
0 Kudos
Tried it, but still the same problem. I also did a full undeployment and then deployed it once more.
Dinu
Contributor
0 Kudos

Perhaps you can confirm that the issue is indeed the second service-manager instance. Selecting between multiple bound service instances is currently not straight forward in CAP. But when I tried, both tag and plan appeared to yield the desired result. Before spending time on fixing that it would be good to confirm that the that problem to solve is indeed that. For example, does the error disappear if you unbind the second instance from sidecar and restart it? What is the order of bound services in VCAP_SERVICES, which plan comes first?

maximilian_pfab
Explorer
0 Kudos

Yes the service manager with plan subaccount-admin is in front of the service manager with plan container:

maximilian_pfab_0-1714108707445.png

And I will test it and give an update.

maximilian_pfab
Explorer
0 Kudos

I guess you are right, if there are two service-managers the service sometimes hangs up.
I deployed it now 3 times completly new and also tried to update the service and I had no problems overall.
So I think that this could be a possible solution.

Maybe I should open a ticket on this point.
What do you think?

Dinu
Contributor
0 Kudos
Im not sure I understood. Do you have a solution?
maximilian_pfab
Explorer
0 Kudos

The solution would be to omit the second Service Manager, but this is not an option for me as I use it to register the Service Broker on the BTP.

So I will probably have to open a ticket.