From 8e00611a51a3cb90066a776d274a88fe0e56854e Mon Sep 17 00:00:00 2001 From: prasebha Date: Tue, 2 Apr 2024 19:42:15 +0530 Subject: [PATCH 1/4] add upsert prop --- .../latest/container-scripts/watchdog.sh | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh b/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh index f003111035..11c2a672cf 100755 --- a/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh +++ b/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh @@ -194,6 +194,27 @@ function is_agent_alive() return 1 } +########################################################### +# Upsert properties with its overriding configMap +function agent_prop_upsert() +{ + log "invoking agent property upsert" + # while upgrading from previous binary, the script will not be available + # before the upgrade completes + if [ ! -f $MGMTAGENT_HOME/agent_inst/bin/agent_prop_upsert.sh ]; then + log "skipping property upsert" + else + # if the agent is alive then stop it first and then do the property update + if is_agent_alive; then + stop_agent + fi + + # upsert emd.properties + prop_file=$MGMTAGENT_HOME/agent_inst/config/emd.properties + config_map=$BASE_DIR/mgmtagent_agent_config/emd.properties + eval "/bin/sh $MGMTAGENT_HOME/agent_inst/bin/agent_prop_upsert.sh $prop_file $config_map 'Modifiable Properties'" + fi +} ########################################################### # Start Management Agent and wait for startup to complete @@ -255,6 +276,9 @@ function start_watchdog() while true; do if ! is_agent_alive; then attempt_agent_upgrade + # previous binary will not consist the agent_prop_upsert.sh, + # so the upgrade needs to happen first + agent_prop_upsert fi start_agent || stop_agent @@ -279,6 +303,9 @@ if ! is_agent_configured; then configure_agent fi +# for fresh install +agent_prop_upsert + start_watchdog sleep 10 -wait # for trap to work +wait # for trap to work \ No newline at end of file From c04de21338aff81d7469ed776a0b5f6549428037 Mon Sep 17 00:00:00 2001 From: prasebha Date: Fri, 5 Apr 2024 19:39:26 +0530 Subject: [PATCH 2/4] add cleanup code for old deployment --- .../latest/container-scripts/watchdog.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh b/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh index 11c2a672cf..788c22719b 100755 --- a/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh +++ b/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh @@ -216,6 +216,33 @@ function agent_prop_upsert() fi } +########################################################### +# cleans up mgmt_agent dir if a new cleanup id is provided +function cleanup_agent_dir() +{ + log "initiating mgmt_agent dir cleanup" + + if [ -v POD_CLEANUP_ID ]; then + # create the cleanup dir to maintain the marker files + cleanup_id_dir="$BASE_DIR/cleanup_ids" + mkdir -p $cleanup_id_dir + + cleanup_id_file="$cleanup_id_dir/$POD_CLEANUP_ID.txt" + + if [ ! -f $cleanup_id_file ]; then + log "$cleanup_id_file not found" + rm -rf $MGMTAGENT_HOME + echo "cleanup successfully done" > $cleanup_id_file + log "cleanup completed" + else + log "$cleanup_id_file found. skipping cleanup" + fi + + else + log "cleanup id not set. skipping cleanup" + fi +} + ########################################################### # Start Management Agent and wait for startup to complete # Returns: 0 if agent successfully started otherwise 1 @@ -289,6 +316,8 @@ function start_watchdog() ########################################################### # Main script execution +cleanup_agent_dir + if ! is_agent_installed; then if [ ! -f "$CONFIG_FILE" ]; then log "$APPNAME install key (input.rsp) value [$CONFIG_FILE] is invalid or does not exist" From 78cb5854f69ee3d27cde737f554b2ae6ab11c2d2 Mon Sep 17 00:00:00 2001 From: prasebha Date: Mon, 15 Apr 2024 08:36:58 +0530 Subject: [PATCH 3/4] fix lint issues --- .../dockerfiles/latest/container-scripts/watchdog.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh b/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh index 788c22719b..ad6b095ac4 100755 --- a/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh +++ b/OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh @@ -229,10 +229,10 @@ function cleanup_agent_dir() cleanup_id_file="$cleanup_id_dir/$POD_CLEANUP_ID.txt" - if [ ! -f $cleanup_id_file ]; then + if [ ! -f "$cleanup_id_file" ]; then log "$cleanup_id_file not found" rm -rf $MGMTAGENT_HOME - echo "cleanup successfully done" > $cleanup_id_file + echo "cleanup successfully done" > "$cleanup_id_file" log "cleanup completed" else log "$cleanup_id_file found. skipping cleanup" From 4542d6a4cc3a2bb5f637a2b4df4edbf9d49a91ad Mon Sep 17 00:00:00 2001 From: prasebha Date: Tue, 30 Apr 2024 18:43:13 +0530 Subject: [PATCH 4/4] add disable JRE default properties file env --- OracleManagementAgent/dockerfiles/latest/docker-compose.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OracleManagementAgent/dockerfiles/latest/docker-compose.yml b/OracleManagementAgent/dockerfiles/latest/docker-compose.yml index d415fbc5ff..4e39adfd9e 100644 --- a/OracleManagementAgent/dockerfiles/latest/docker-compose.yml +++ b/OracleManagementAgent/dockerfiles/latest/docker-compose.yml @@ -26,6 +26,10 @@ services: # Image name reported by container images listing image: oracle/mgmtagent-container + # Environment properties + environment: + - DISABLE_JRE_DEFAULT_SECURITY_PROPERTIES_FILE=${DISABLE_JRE_DEFAULT_SECURITY_PROPERTIES_FILE} + # Internal hostname identifier for the container hostname: ${mgmtagent_hostname}