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

backend and Ngins errors on ingest of new repo. Patches website down. #30

Open
bryanh1969 opened this issue Jan 24, 2024 · 11 comments
Open
Assignees

Comments

@grantcurell
Copy link
Collaborator

Check logs - your permissions are wrong:

WARNING: SERVER_CERT or SERVER_KEY environment variable is missing. Generating self-signed certificate and key...
node:internal/fs/watchers:255
    throw error;
    ^

Error: EACCES: permission denied, watch '/patches/xml/1242024'
    at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
    at Object.watch (node:fs:2418:34)
    at /home/node/app/server/util.js:406:12
    at FSReqCallback.oncomplete (node:fs:211:5) {
  errno: -13,
  syscall: 'watch',
  code: 'EACCES',
  path: '/patches/xml/1242024',
  filename: '/patches/xml/1242024'
}

Node.js v18.18.2
WARNING: SERVER_CERT or SERVER_KEY environment variable is missing. Generating self-signed certificate and key...
node:internal/fs/watchers:255
    throw error;
    ^

Error: EACCES: permission denied, watch '/patches/xml/1242024'
    at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
    at Object.watch (node:fs:2418:34)
    at /home/node/app/server/util.js:406:12
    at FSReqCallback.oncomplete (node:fs:211:5) {
  errno: -13,
  syscall: 'watch',
  code: 'EACCES',
  path: '/patches/xml/1242024',
  filename: '/patches/xml/1242024'
}

Node.js v18.18.2

@grantcurell
Copy link
Collaborator

This is the relevant code from patches.sh:

  import-repository)

    while true; do
      patches_read "Enter the location of the repository you would like to import. This should be a directory containing a catalog file and associated repository files."
      import_directory=${RETURN_VALUE}

      patches_echo "Setting directory permissions and ownership for ${import_directory}. \`chmod -R 775 ${import_directory}\`. This will fail if your user does not have the ability to run chmod against this directory."
      chmod -R 775 ${import_directory}
      chown "$(whoami)": -R ${import_directory}

      if validate_directory "$import_directory"; then
        if [[ -n $(find "$import_directory" -maxdepth 1 -type f -name "*.xml") ]]; then
          patches_echo "Directory validation complete..."
          break
        else
          patches_echo "There are no XML files found in the directory ${import_directory}. The catalog XML must be present - are you sure you got the path correct? Exiting." --error >&2  # Redirect error message to stderr
          exit 1
        fi
      else
        patches_echo "The specified location is not valid. Please try again." --error
      fi
    done

    if check_images; then
      if ! ask_yes_no "Patches will import $import_directory. When it does this it will remove the original directory to conserve space after the import. Patches will also be stopped during the import and then started afterwards. This should only take a few seconds to complete. Would you like to continue?"; then
        patches_echo "Terminating." --error
        exit 1
      fi
      patches_stop
      mv "$import_directory" "${TOP_DIR}/repos/xml"
      patches_start
    else
      mv "$import_directory" "${TOP_DIR}/repos/xml"
      if ask_yes_no "It looks like the Patches images are not yet configured. Do you want to run setup now?"; then
        patches_setup
      else
        patches_echo "Exiting."
        exit 0
      fi
    fi

    ;;

the directory permissions should be 775. Are they something different? If so, did you use import-repository and did it finish running? It should be that chmod line that checks against this.

@bryanh1969
Copy link
Collaborator Author

I did....and I saw that.
I think the path is wrong. the path there is /patches/xml/1242024' The path should be /opt/patches/repos/xml/.

Where do I change that?

@grantcurell
Copy link
Collaborator

I did....and I saw that. I think the path is wrong. the path there is /patches/xml/1242024' The path should be /opt/patches/repos/xml/.

Where do I change that?

/patches/xml/1242024 is a mount inside the container not on your host. That path looks correct. You can check it by exec'ing into the container if you want:

From Debugging the Backend

cd /opt/patches
TOP_DIR=./
SCRIPT_DIR=./podman-build/
CERT_DIRECTORY=./server_certs/
podman rm -f -t 0 patches-backend && \
podman run \
  --name patches-backend \
  --env-file ${TOP_DIR}/.patches-backend \
  --volume ${TOP_DIR}/server/data:/home/node/app/data:Z \
  --volume ${TOP_DIR}/server/config.js:/home/node/app/server/config.js:Z \
  --volume ${TOP_DIR}/server/routes:/home/node/app/server/routes:Z \
  --volume ${TOP_DIR}/server/logger.js:/home/node/app/server/logger.js:Z \
  --volume ${TOP_DIR}/server/db.js:/home/node/app/server/db.js:Z \
  --volume ${TOP_DIR}/server/index.js:/home/node/app/server/index.js:Z \
  --volume ${TOP_DIR}/server/knexfile.js:/home/node/app/server/knexfile.js:Z \
  --volume ${TOP_DIR}/server/rebuild_database.js:/home/node/app/server/rebuild_database.js:Z \
  --volume ${TOP_DIR}/server/util.js:/home/node/app/server/util.js:Z \
  --volume ${TOP_DIR}/server/seeds/:/home/node/app/server/seeds:Z \
  --volume ${TOP_DIR}/package.json:/home/node/app/package.json:Z \
  --volume ${TOP_DIR}/${CERT_DIRECTORY}:/patches/${CERT_DIRECTORY}:z \
  --volume ${SCRIPT_DIR}/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:Z \
  --volume ${TOP_DIR}/migrations:/home/node/app/migrations:Z \
  --volume ${TOP_DIR}/repos/xml:/patches/xml:z \
  --volume ${TOP_DIR}/repos/xml/parsed:/patches/xml/parsed:z \
  --publish "9229:9229" \
  --network host-bridge-net \
  -it \
  localhost/dell/patches-base:latest \
  /bin/bash

Note the line --volume ${TOP_DIR}/repos/xml:/patches/xml:z \. This is where the volume mount occurs.

The source cause of that though is the folder on the host /opt/patches/repos/xml/1242024 probably has the wrong permissions.

@bryanh1969
Copy link
Collaborator Author

i used import-repository

@bryanh1969
Copy link
Collaborator Author

[devuser@localhost ~]$ cd /opt/patches/repos/xml/
[devuser@localhost xml]$ ls -lah
total 172K
drwxrwxr-x. 5 devuser devuser 49 Jan 24 07:36 .
drwxrwxr-x. 3 devuser devuser 17 Dec 22 14:40 ..
drwxrwxr-x. 1681 devuser devuser 56K Jan 2 12:00 122024
drwxrwxr-x. 1775 devuser devuser 60K Jan 24 07:30 1242024
drwxrwxr-x. 2 devuser devuser 164 Jan 5 15:13 parsed

@grantcurell
Copy link
Collaborator

It has to be the entire path. Maybe something is wrong with repos or xml. If those are normal try debugging as mentioned above - exec into the container and try touching a file in the folder.

@grantcurell
Copy link
Collaborator

Try reading the file with cat and see if it works. If it doesn't you know you have a read probably and can focus in on that permission. Make sure everything starting at /opt/patches down is owned by devuser. Maybe ownership changed somewhere on one of the folders in the chain /opt/patches/repos/xml chain

@bryanh1969
Copy link
Collaborator Author

reading the file with cat work swimmingly.

for some reason the backend just does not want to start even with a re setup

@grantcurell
Copy link
Collaborator

Try /home/node/app/node_modules/knex/bin/cli.js migrate:rollback --knexfile /home/node/app/server/knexfile.js && node /home/node/app/node_modules/knex/bin/cli.js migrate:latest --knexfile /home/node/app/server/knexfile.js && node --inspect-brk=0.0.0.0:9229 server/index.js in the container

See: https://github.com/dell/patches/blob/main/DEBUGGING.md#debugging-the-backend

That manually runs the backend. See what the output is.

@grantcurell
Copy link
Collaborator

reading the file with cat work swimmingly.

for some reason the backend just does not want to start even with a re setup

Also, just to confirm, reading the file with cat in the container works swimmingly? It's in the container that matters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants