How to fix Error: OMSPatcher finds that previous patching session is not yet completed

When planning a patch for a client's OMS, I found the following:
OMSPatcher finds that previous patching session is not yet completed. Please refer log file "/u01/app/oracle/middleware/cfgtoollogs/omspatcher/28018178/omspatcher_2019-07-09_23-44-58PM_deploy.log" for the previous session and execute the script "/u01/app/oracle/middleware/.omspatcher_storage/oms_session/scripts_2019-07-09_23-44-39PM/run_script_singleoms_resume.sh" to complete the previous session. OMSPatcher can proceed to execute new operations only if previous session is completed successfully.Interesting, right? This means a patch executed in July failed and it wasn’t noticed. What to do? Well, the error itself already says what needs to be done. You just need to do it properly. How? Here is a quick action plan: Before doing this, however, it's important to check the Deploy log to understand the root cause for the failure on the previous patch and fix it. In my case, it happened because not all required components were down. A simple “stop oms” was performed. It stops only the OMS managed server, JVMD engine, and HTTP server, but leaves Node Manager and Administration Server running. On the other hand, a “stop oms -all” stops all Enterprise Manager processes including Administration Server, OMS, HTTP Server, Node Manager, Management Server, JVMD engine, and Oracle BI Publisher (if it is configured on the host). This investigation step is very important as this finding allowed me to map the steps to avoid errors from happening again and also map the steps required to fix it. So let's go to my Action Plan for fixing: Step-by-Step: 1. Blackout targets to avoid unwanted pages. – On OEM: Enterprise–>Monitoring–>Blackouts 2. Shut down OMS and AGENT
cd $AGENT_HOME/bin ./emctl stop agent cd $OMS_HOME/bin ./emctl stop oms -all3. Resume patching with issue (with provided command) (in my case):
/u01/app/oracle/middleware/.omspatcher_storage/oms_session/scripts_219-07-09_23-44-39PM/run_script_singleoms_resume.sh4. Verify patches got installed
$OMS_HOME/OPatch/opatch lsinventory $OMS_HOME/OMSPatcher/omspatcher lspatches5. Start the OMS and agent
cd $AGENT_HOME/bin ./emctl start agent cd $OMS_HOME/bin ./emctl start oms ./emctl status oms -details6. Sync EMCLI with server changes:
$OMS_HOME/bin/emcli login -username=sysman Enter password : <-- sysman password $OMS_HOME/bin/emcli syncThe output of a continued patch? Here it goes:
[oracle@oem13c ]$ /u01/app/oracle/middleware/.omspatcher_storage/oms_session/scripts_2019-07-09_23-44-39PM/run_script_singleoms_resume.sh Verifying embedded script host-address "oem13c" against the network interface for a match... Trying for a match with: fe80:0:0:0:250:56ff:febc:4399%2(fe80:0:0:0:250:56ff:febc:4399%2) Trying for a match with: oem13c(10.10.10.10) Script-host address matched with host network interface. Please provide credential for OMS repository SYSMAN user: Command to execute (Step 1): /u01/app/oracle/middleware/bin/emctl applypatch repos -patchHome /u01/app/oracle/middleware/.omspatcher_storage/27926184_July_09_2019_14_47_56/original_patch -pluginHome /u01/app/oracle/middleware/plugins/oracle.sysman.emas.oms.plugin_13.2.2.0.0 Oracle Enterprise Manager Cloud Control 13c Release 2 Copyright (c) 1996, 2016 Oracle Corporation. All rights reserved. *********************************************** Executing Patch Application Steps..... *********************************************** Enter the SYSMAN password: Please enter the database password(User:SYSMAN): Processing command line .... Repository_Patching_Utility - Checking Prerequisites Checking Global Prerequisites Repository_Patching_Utility - Checking Prerequisites Checking Component Prerequisites Repository_Patching_Utility - Creating Tablespaces Validating and Creating Tablespaces Repository_Patching_Utility - ApplyRepositoryPatch Repository ApplyRepositoryPatch in progress. Percent Complete: 55 Percent Complete: 58 Percent Complete: 61 Percent Complete: 64 Percent Complete: 75 Percent Complete: 100 Repository_Patching_Utility: ApplyRepositoryPatch - Completion Summary Database details: Connect Descriptor : (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=oem13c)(PORT=1521)))(CONNECT_DATA=(SID=oemdb))) Connected As : SYSMAN RCU Logfile : /u01/app/oracle/middleware/oracle_common/rcu/log/empatch/rcu_2019_09_7__11_10_49.log Component schemas created: Component Status Logfile EM Repository Patch Application Success /u01/app/oracle/middleware/oracle_common/rcu/log/empatch/em_patch_apply.log Repository_Patching_Utility - ApplyRepositoryPatch : Operation CompletedWith this, we have the previous patching session completed successfully and can start the next one. Hope it helps!