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

Problem with make load-data #80

Open
thiagoceano opened this issue Sep 11, 2024 · 1 comment
Open

Problem with make load-data #80

thiagoceano opened this issue Sep 11, 2024 · 1 comment

Comments

@thiagoceano
Copy link

Hello there,

I'm trying to install webportal but I cannot get past load-data. Everytime i get this error:

make: * [Makefile:188: build/html/zoo/load-timestamp.txt] Error 1

image

make build-all seems to work fine so I don't know what is going on.

Can somebody help me here?

Thanks.

@mcruz-umich
Copy link

mcruz-umich commented Sep 12, 2024

Hello! I think the issue is permissions related, however I am not sure. I typically build this with Docker. I also deploy with RedHat Openshift and Docker. I ran your issue through ChatGPT4.0 and got the following information. I hope it helps!

I would try this: chmod -R u+rwx build

Here is the chat with ChatGPT I did:

From GPT: Part 1 of 2

Question
Makefile expert;

I get this error when running the makefile below:
make: * [Makefile:188: build/html/zoo/load-timestamp.txt] Error 1

Can you determine what I need to do to fix it please?
{paste of entire makefile}

Answer
The error you're encountering is related to the Makefile target build/html/zoo/load-timestamp.txt. To diagnose and correct this problem, several checks and validations can be considered:

  1. Ensure Dependencies Are Met:
    Verify that the dependencies for build/html/zoo/load-timestamp.txt are correctly generated. Specifically, check the targets that build/html/zoo/load-timestamp.txt depends upon:

    build/html/%/load-timestamp.txt: build/col/%/PortalFiles
  2. Check Existence of Prerequisite Files:
    The prerequisite, in this case, is build/col/zoo/PortalFiles. Verify that specify_exports/zoo.zip exists (since build/col/%/PortalFiles depends on the extraction from this specicified exports). Also, ensure that unzip command is available and correctly set up in your environment.

  3. Debug the Command Execution:
    You can add debugging outputs directly within the Makefile to get more insights into the execution flow. Specifically, for the failing target:

    build/html/%/load-timestamp.txt: build/col/%/PortalFiles | build/html/%
        @printf "\n\n### Loading data into $*.\n\n"
        curl -X POST "http://localhost:8983/solr/$*/update" \
            -d '{ "delete": {"query":"*:*"} }' \
            -H 'Content-Type: application/json' \
            | grep '"status":0'
        curl "http://localhost:8983/solr/$*/update/csv?commit=true&encapsulator=\"&escape=\&header=true" \
            --data-binary @build/col/$*/PortalFiles/PortalData.csv \
            -H 'Content-type:application/csv' \
            | grep '"status":0'
        date > $@

    One way to do that is to add more echo statements (or printf) before commands to print the environment and variable states for debugging.

  4. Check Solr Server Availability:
    Ensure that the Solr server is running at localhost:8983. The curl commands interact with the running Solr server, and if the server is down or the endpoint is incorrect, it will result in an error.

    A simple way to check if Solr is running could be:

    curl http://localhost:8983/solr/
  5. Permissions:
    Ensure the Makefile has the necessary permissions to write and read within the directories and files it needs to manipulate.

  6. Debugging Output to Trace Failure:
    You might want to extend the debug level:

    build/html/%/load-timestamp.txt: build/col/%/PortalFiles | build/html/%
        @printf "\n\n### Loading data into $*.\n\n"
        set -x
        curl -X POST "http://localhost:8983/solr/$*/update" -d '{ "delete": {"query":"*:*"} }' -H 'Content-Type: application/json' | grep '"status":0'
        curl "http://localhost:8983/solr/$*/update/csv?commit=true&encapsulator=\"&escape=\&header=true" --data-binary @build/col/$*/PortalFiles/PortalData.csv -H 'Content-type:application/csv' | grep '"status":0'
        set +x
        date > $@
  7. Human Readable Errors:
    By running make with high verbosity, it might give more details on failure reasons:

    make -d

This holistic approach will identify any missing dependencies, misconfigurations, server issues, and various other possible interruptions causing the error encountered during the execution of the Makefile.

From GPT Part 2 of 2: PERMISSIONS

Question
Can you address this part of your answer in greater detail please? Permissions: Ensure the Makefile has the necessary permissions to write and read within the directories and files it needs to manipulate.

Answer
Certainly! Permissions can be a common issue when working with Makefiles, especially if the commands within the Makefile need to read from, write to, or execute files and directories. Here's a more detailed step-by-step approach to ensuring appropriate permissions:

1. Verify File and Directory Ownership

Ensure that the user running the make command has ownership of the files and directories being manipulated. This is crucial because even if you have read and write permissions, certain operations might fail if you are not the owner.

You can check the ownership using the ls -l command:

ls -l specify_exports/
ls -l build/

2. Check and Set File Permissions

Make sure the necessary files and directories have correct read, write, and (sometimes) execute permissions.

Key Permissions:

  • Read (r): Needed to read files or list directory contents.
  • Write (w): Needed to modify file contents or create/delete files in a directory.
  • Execute (x): Needed to execute files (e.g., scripts) or traverse directories.

You can check current permissions using:

ls -l specify_exports/*.zip
ls -lR build/

To correct permissions, you might use:

chmod u+rwx specify_exports/*.zip
chmod -R u+rwx build/

3. Ensure Directory Write Permissions

If the Makefile creates or modifies files in a directory, the directory itself needs to be writable.

Ensure directories are writable by using:

chmod -R u+rwx build

4. Look for Permissions Issues in Specific Directories

Particularly, the following directories are being used for file operations:

  • Build directories (such as build/, build/col/, build/html/)
  • The source of zipped files (specify_exports/)

Examples:

Grant Write Permissions to the build/ Directory:

chmod -R u+rwx build/

Grant Read and Write Permissions to specify_exports:

chmod u+r specify_exports/*.zip

5. Check Script Execution Permissions

Make sure scripts you are executing, for example, files like patch_web_xml.py, patch_solrconfig_xml.py, and other Python scripts, have execute permissions:

chmod +x patch_web_xml.py patch_solrconfig_xml.py

6. Ensure Correct User Context

Sometimes, the build process might be run under different user contexts (like a system service or CI/CD pipeline). Ensure that the user context under which make is run has the necessary permissions.

Detailed Steps to Ensure Permissions:

  1. Check Ownership:

    ls -l specify_exports/*.zip
    ls -lR build/
  2. Set Directory Permissions:

    chmod -R u+rwx build
    chmod u+rwx specify_exports/*.zip
  3. Set Execution Permissions for Scripts:

    chmod +x patch_web_xml.py patch_solrconfig_xml.py
  4. Verify Script Invocation:
    Run the scripts manually to ensure there are no permission errors:

    python2 patch_web_xml.py
    python2 patch_solrconfig_xml.py
  5. File Paths in Makefile:
    Ensure paths specified in the Makefile are correct and referential paths correctly point to files/directories:

    build/html/%/load-timestamp.txt: build/col/%/PortalFiles | build/html/%
  6. Set Permissions Recursively:
    Permissions can often be set recursively:

    chmod -R u+rwx build/
    chmod -R u+rwx specify_exports/

Conclusion

Having the correct file and directory permissions ensures that all operations defined in the Makefile can execute smoothly. By ensuring the Makefile and all files and directories it interacts with have the correct permissions, you minimize the risk of permission-related errors during the build process. If you continue to experience issues, consider running make with elevated permissions (sudo make, if appropriate), but use this with caution to avoid potential security risks.

ME to GPT:
Thanks for the help!

GPT:
You're welcome! I'm glad I could help. If you have any more questions or need further assistance with your Makefile or anything else, feel free to ask. Happy building! 🚀

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