@@ -11,29 +11,26 @@ set -o xtrace
1111# Keep track of the number of service failures
1212touch /tmp/devcontainer-failure-count
1313
14- # Fetch and cache workspace metadata
15- source /home/core/service-utils.sh
14+ # Fetch and cache workspace_id
1615source /home/core/metadata-utils.sh
17-
18- WORKSPACE_USER_FACING_ID=" $( get_metadata_value " terra-workspace-id" " " ) "
19- RESOURCE_ID=" $( get_metadata_value " wb-resource-id" " " ) "
20- WSM_SERVICE_URL=" $( get_service_url " wsm" ) "
21-
22- # Cache workspace_id if not already cached
16+ source /home/core/service-utils.sh
17+ MONITORING_UTILS_FILE=" /home/core/monitoring-utils.sh"
2318WORKSPACE_ID_CACHE_FILE=" /tmp/workspace_id_cache"
24- if [[ ! -f " ${WORKSPACE_ID_CACHE_FILE} " ]]; then
19+ FIRST_BOOT_START_FILE=" /home/core/first-boot-start"
20+ if [[ -f " ${MONITORING_UTILS_FILE} " && ! -f " ${FIRST_BOOT_START_FILE} " ]]; then
21+ # First boot file does not exist
22+ # # Cache workspace id to be used by probe-proxy-readiness.sh
23+ WORKSPACE_USER_FACING_ID=" $( get_metadata_value " terra-workspace-id" " " ) "
24+ SERVER=" $( get_metadata_value " terra-cli-server" " prod" ) "
25+ WSM_SERVICE_URL=" $( get_service_url " wsm" " ${SERVER} " ) "
2526 RESPONSE=$( curl -s -X GET " ${WSM_SERVICE_URL} /api/workspaces/v1/workspaceByUserFacingId/${WORKSPACE_USER_FACING_ID} " \
2627 -H " Authorization: Bearer $( /home/core/wb.sh auth print-access-token) " )
27- WORKSPACE_ID=$( echo " ${RESPONSE} " | jq -r ' .id' )
28+ WORKSPACE_ID=$( echo " ${RESPONSE} " | jq -r ' .id' ) ;
2829 echo " ${WORKSPACE_ID} " > " ${WORKSPACE_ID_CACHE_FILE} "
29- else
30- WORKSPACE_ID=$( cat " ${WORKSPACE_ID_CACHE_FILE} " )
31- fi
3230
33- # Record startup begin for monitoring on first boot
34- FIRST_BOOT_START_FILE=" /home/core/first-boot-start"
35- if [[ ! -f " ${FIRST_BOOT_START_FILE} " ]]; then
36- source /home/core/monitoring-utils.sh
31+ # # Record devcontainer begin for monitoring
32+ source " ${MONITORING_UTILS_FILE} "
33+ RESOURCE_ID=" $( get_metadata_value " wb-resource-id" " " ) "
3734 record_devcontainer_start " ${WSM_SERVICE_URL} " " ${WORKSPACE_ID} " " ${RESOURCE_ID} "
3835fi
3936touch " ${FIRST_BOOT_START_FILE} "
0 commit comments