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

cubejs/cube:v0.35.11 results in Model files not found errors #8213

Closed
alyssakelley opened this issue Apr 30, 2024 · 2 comments
Closed

cubejs/cube:v0.35.11 results in Model files not found errors #8213

alyssakelley opened this issue Apr 30, 2024 · 2 comments
Assignees
Labels
docs Issues that require a documentation improvement

Comments

@alyssakelley
Copy link

Describe the bug
When we use any version of cubejs/cube past v0.35.10, our cube deployment results in the following errors:

"error": "Error: Model files not found. Please make sure the "model" directory exists and contains model files.",
"stack": "Error: Model files not found. Please make sure the "model" directory exists and contains model files.\n at FileRepository.getFiles (/cube/node_modules/@cubejs-backend/shared/src/FileRepository.ts:31:13)\n at FileRepository.dataSchemaFiles (/cube/node_modules/@cubejs-backend/shared/src/FileRepository.ts:46:19)\n at DataSchemaCompiler.doCompile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:81:19)\n at CompilerApi.getCompilers (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:67:26)\n at CompilerApi.metaConfig (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:221:23)\n at ApiGateway.load (/cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:1597:30)\n at /cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:257:7"

We are deploying cube to aks following a similar chart structure as what is documented here: https://github.com/cube-js/cube/tree/master/examples/kubernetes/cluster

To Reproduce
Steps to reproduce the behavior:

  1. Use cubejs/cube:v0.35.11 or greater
  2. Have cube image deployed with cube.js file in root
  3. Port forward cube-api service: kubectl port-forward -n cube svc/cube-api 4000
  4. Make a test api call to http://localhost:4000/cubejs-api/v1/load with a valid query parameter included
  5. See the error in api output and cube-api pod logs

Expected behavior
Expect the api results to come back with valid data from our ConfigMap that was specified in the query parameter of the call.

Screenshots
If applicable, add screenshots to help explain your problem.
api_error

Version:
v0.35.11 through latest does not work

Example cube.js file in root

module.exports = {
    checkAuth: ({ securityContext }, token) => {
      if (token !== null) {
        return;
      }
      
      throw new Error(`Access denied - securityContext: ${securityContext} - token: ${token}`);
    },
    orchestratorOptions: {
      continueWaitTimeout: 15  
    }
  };
@paveltiunov paveltiunov added the docs Issues that require a documentation improvement label May 1, 2024
@paveltiunov
Copy link
Member

@alyssakelley schema path should be updated to be model indeed.

@alyssakelley
Copy link
Author

The solution is updating cube.js in the root of the image to be something similar to:


const path = require("path");
const fs = require("fs");

module.exports = {
  checkAuth: ({ securityContext }, token) => {
    if (token !== null) {
      return;
    }
    throw new Error(`Access denied - securityContext: ${securityContext} - token: ${token}`);
  },
  orchestratorOptions: {
    continueWaitTimeout: 15
  },
  repositoryFactory: () => ({
    dataSchemaFiles: async () => {
      const files = await fs.promises.readdir(
        path.join(process.cwd(), "model")
      );
      return await Promise.all(
        files
          .filter((file) => file.endsWith(".js") || file.endsWith(".yaml"))
          .map(async (file) => ({
            fileName: file,
            content: await fs.promises.readFile(
              path.join(process.cwd(), "model", file),
              "utf-8"
            ),
          }))
      );
    },
  })
};

and then making sure the volume mount is updated in the cube-api deployment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Issues that require a documentation improvement
Projects
None yet
Development

No branches or pull requests

3 participants