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

Add logic to carma script to account for env var in carma-config #2408

Closed
wants to merge 5 commits into from

Conversation

MishkaMN
Copy link
Contributor

@MishkaMN MishkaMN commented Jun 14, 2024

PR Details

Description

This PR fixes the carma script to be able to run from any directory without relying on .env file to exist in the same directory.
Depends on this PR: usdot-fhwa-stol/carma-config#352

The proposed change on a high level:

  • Bake the .env file into the carma-config container. (previously it didn't exist inside carma config edit for example).
  • Whenever carma * script is run, parse all variables inside the .env file from the carma-config image set through volume
  • use that parsed variables to sed change all instances found in the docker-compose.yml to run the individual services. This should work for any environment variables specified, not just DOCKER_TAG or DOCKER_ORG since some services require different org/tagging such as OPS or v2xhub etc.

Resulting behavior:

  • Since the change is made by sed command to get hardcoded image names as before, the local .env file in host dir where carma is called will no longer work unless the .env file in carma-config was NOT able to replace. Then the local .env file will takeover using docker's native functionality and the variables in the docker-compose.yml wil be replaced. This is desirable for simulation runs for example where multiple variables such as ROUTE_FILE are specified in .env file
  • If the user wants to change the image name/tags, they can simply modify the .env file and rebuild or carma config edit and modify the /opt/carma/vehicle/config/.env file and restart. The change should persist as how carma config edit normally works. Or even hardcoding as before in the docker-compose.yml work as well.

Related GitHub Issue

NA

Related Jira Key

https://usdot-carma.atlassian.net/browse/ARC-82

Motivation and Context

During 4.5.0 release, we modifed the way DOCKER_ORG and DOCKER_TAG are specified by centralizing them into a single .env file in each carma-config folder for docker-compose.yml to load. However, currnently, when a carma-config image is built by our GitHub Actions CI processes, the resulting image still contains the {DOCKER_ORG} and {DOCKER_TAG} environment variable placeholders in the docker-compose.yml and docker-compose-background.yml files. This breaks the carma config install functionality of the carma shell script. The carma start all functionality breaks with this as well.

Workaround: If .env file exists in the same directory from where carma is called, then everything works fine. However, this is not a desired functionality as we want to call carma from anywhere.

How Has This Been Tested?

locally in VM. Results of each commands working:

file:
carma command results.txt
in colored:
image
image

Types of changes

  • Defect fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that cause existing functionality to change)

Checklist:

  • I have added any new packages to the sonar-scanner.properties file
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@MishkaMN MishkaMN requested a review from JonSmet June 14, 2024 20:34
@MishkaMN MishkaMN self-assigned this Jun 14, 2024
@MishkaMN MishkaMN added the anomaly Something isn't working label Jun 14, 2024
Copy link

sonarcloud bot commented Jun 14, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@MishkaMN
Copy link
Contributor Author

After writing a whole lot of helper functions and sed operations. I realized I could have just done the same thing with a simple method... 🤦‍♂️ Here: #2409
So probably we don't need this PR...

@MishkaMN MishkaMN closed this Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
anomaly Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant