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

Rollback 12.1.0.2.5 PSU #86

Open
anthonyman opened this Issue Jan 25, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@anthonyman

anthonyman commented Jan 25, 2016

Hi Biemond,

I tried to apply 12.1.0.2.5 PSU like this.

oradb::opatch{'21555660_db_patch':
ensure => 'present',
oracle_product_home => '/u01/sq/ora_1/db/12.1.0.2',
patch_id => '21520444',
patch_file => 'p21520444_121020_Linux-x86-64.zip',
bundle_sub_patch_id => '21555660',
bundle_sub_folder => '21555660',
user => 'oracle',
group => 'oinstall',
download_dir => '/spare/psu',
ocmrf => true,
require => Oradb::Opatchupgrade['121010_opatch_upgrade'],
puppet_download_mnt_point => '/spare/psu_source',
}

oradb::opatch{'21359755_db_patch':
ensure => 'present',
oracle_product_home => '/u01/sq/ora_1/db/12.1.0.2',
patch_id => '21520444',
patch_file => 'p21520444_121020_Linux-x86-64.zip',
bundle_sub_patch_id => '21359755',
bundle_sub_folder => '21359755',
user => 'oracle',
group => 'oinstall',
download_dir => '/spare/psu',
ocmrf => true,
require => Oradb::Opatchupgrade['121010_opatch_upgrade'],
puppet_download_mnt_point => '/spare/psu_source',
}

The PSU was appiled successfully.

However, when it comes to rollback the PSU.

oradb::opatch{'21555660_db_patch':
ensure => 'absent',
oracle_product_home => '/u01/sq/ora_1/db/12.1.0.2',
patch_id => '21520444',
patch_file => 'p21520444_121020_Linux-x86-64.zip',
bundle_sub_patch_id => '21555660',
bundle_sub_folder => '21555660',
user => 'oracle',
group => 'oinstall',
download_dir => '/spare/psu',
ocmrf => true,
require => Oradb::Opatchupgrade['121010_opatch_upgrade'],
puppet_download_mnt_point => '/spare/psu_source',
}

oradb::opatch{'21359755_db_patch':
ensure => 'absent',
oracle_product_home => '/u01/sq/ora_1/db/12.1.0.2',
patch_id => '21520444',
patch_file => 'p21520444_121020_Linux-x86-64.zip',
bundle_sub_patch_id => '21359755',
bundle_sub_folder => '21359755',
user => 'oracle',
group => 'oinstall',
download_dir => '/spare/psu',
ocmrf => true,
require => Oradb::Opatchupgrade['121010_opatch_upgrade'],
puppet_download_mnt_point => '/spare/psu_source',
}

It fails to rollback the PSU because it should rollback <bundle_sub_patch_id> rather than <21520444>.

Info: search for patchid 21555660
Info: opatch_status for patch 21520444 command: /u01/sq/ora_1/db/12.1.0.2/OPatch/opatch lsinventory -patch_id -oh /u01/sq/ora_1/db/12.1.0.2 -invPtrLoc /etc/oraInst.loc
Info: opatch_status output 21555660 for patchId 21555660
Info: opatch action: absent with command /u01/sq/ora_1/db/12.1.0.2/OPatch/opatch rollback -id 21520444 -silent -oh /u01/sq/ora_1/db/12.1.0.2
Argument(s) Error... Patch not present in the Oracle Home, Rollback cannot proceed
If the patch was applied using -no_inventory option, use -ph option
to specify the patch shiphome location. Use 'opatch rollback -help'
to get more information.

Info: opatch result: Oracle Interim Patch Installer version 12.1.0.1.9
Copyright (c) 2016, Oracle Corporation. All rights reserved.

Please check the arguments and try again.

OPatch failed with error code 135

Error: Oracle Interim Patch Installer version 12.1.0.1.9
Copyright (c) 2016, Oracle Corporation. All rights reserved.

Please check the arguments and try again.

OPatch failed with error code 135

Error: /Stage[main]/test_ora/Oradb::Opatch[21555660_db_patch]/Db_opatch[21520444 21555660_db_patch]/ensure: change from present to absent failed: Oracle Interim Patch Installer version 12.1.0.1.9
Copyright (c) 2016, Oracle Corporation. All rights reserved.

Please check the arguments and try again.

OPatch failed with error code 135

Info: search for patchid 21359755
Info: opatch_status for patch 21520444 command: /u01/sq/ora_1/db/12.1.0.2/OPatch/opatch lsinventory -patch_id -oh /u01/sq/ora_1/db/12.1.0.2 -invPtrLoc /etc/oraInst.loc
Info: opatch_status output 21359755 for patchId 21359755
Info: opatch action: absent with command /u01/sq/ora_1/db/12.1.0.2/OPatch/opatch rollback -id 21520444 -silent -oh /u01/sq/ora_1/db/12.1.0.2
Argument(s) Error... Patch not present in the Oracle Home, Rollback cannot proceed
If the patch was applied using -no_inventory option, use -ph option
to specify the patch shiphome location. Use 'opatch rollback -help'
to get more information.

Info: opatch result: Oracle Interim Patch Installer version 12.1.0.1.9
Copyright (c) 2016, Oracle Corporation. All rights reserved.

Please check the arguments and try again.

OPatch failed with error code 135

Error: Oracle Interim Patch Installer version 12.1.0.1.9
Copyright (c) 2016, Oracle Corporation. All rights reserved.

Please check the arguments and try again.

OPatch failed with error code 135

Error: /Stage[main]/test_ora/Oradb::Opatch[21359755_db_patch]/Db_opatch[21520444 21359755_db_patch]/ensure: change from present to absent failed: Oracle Interim Patch Installer version 12.1.0.1.9
Copyright (c) 2016, Oracle Corporation. All rights reserved.

Please check the arguments and try again.

OPatch failed with error code 135

Thanks and regards,
Anthony

@biemond

This comment has been minimized.

Owner

biemond commented Jan 25, 2016

Thanks for reporting.

Strange it should work because patch 21555660 should be part of 21520444 or be inside the zip. So will it try to apply the patch for the 2nd time when you run puppet again. If so then sub patchid 21555660 is not correct.
and rollback should work for only that patch 21555660 and not for the others.

Yeah, rollback of a bundle is a problem because I use opatch lsinventory to check if the patch is applied else it will do it on every puppet run.
and bundle patches are not registered in the inventory only its sub patches. Maybe we need to use an array of all the included patches as subpatch id and use that for the rollback.

thanks Edwin

@anthonyman

This comment has been minimized.

anthonyman commented Feb 1, 2016

I guess the issue here is that patch_id is used when opatch rollback is done. However, bundle_sub_patch_id should be used when bundle_sub_patch_id exists.

def opatch(action)
user = resource[:os_user]
patchName = resource[:patch_id]
oracle_product_home_dir = resource[:oracle_product_home_dir]
extracted_patch_dir = resource[:extracted_patch_dir]
ocmrf_file = resource[:ocmrf_file]
opatch_auto = resource[:opatch_auto]
use_opatchauto_utility = resource[:use_opatchauto_utility]

Puppet.debug "opatch auto result: #{opatch_auto}"

unless ocmrf_file.nil?
  ocmrf = ' -ocmrf ' + ocmrf_file
else
  ocmrf = ''
end

if opatch_auto == false
  if action == :present
    command = "#{oracle_product_home_dir}/OPatch/opatch apply -silent #{ocmrf} -oh #{oracle_product_home_dir} #{extracted_patch_dir}"
  else
    command = "#{oracle_product_home_dir}/OPatch/opatch rollback -id #{patchName} -silent -oh #{oracle_product_home_dir}"
  end
else
  if use_opatchauto_utility == false
    if action == :present
      command = "#{oracle_product_home_dir}/OPatch/opatch auto #{extracted_patch_dir} #{ocmrf} -oh #{oracle_product_home_dir}"
    else
      command = "#{oracle_product_home_dir}/OPatch/opatch auto -rollback #{extracted_patch_dir} #{ocmrf} -oh #{oracle_product_home_dir}"
    end
  else
    if action == :present
      command = "#{oracle_product_home_dir}/OPatch/opatchauto apply #{extracted_patch_dir} #{ocmrf} -oh #{oracle_product_home_dir}"
    else
      command = "#{oracle_product_home_dir}/OPatch/opatchauto rollback #{extracted_patch_dir} #{ocmrf} -oh #{oracle_product_home_dir}"
    end
  end

It works fine for opatch_status query because bundle_sub_patch_id is used.

def opatch_status
user = resource[:os_user]
patchName = resource[:patch_id]
oracle_product_home_dir = resource[:oracle_product_home_dir]
orainst_dir = resource[:orainst_dir]
bundle_sub_patch_id = resource[:bundle_sub_patch_id]
# opatch_auto = resource[:opatch_auto]

unless bundle_sub_patch_id.nil?

* patchId = bundle_sub_patch_id*
else
patchId = patchName
end

Puppet.info "search for patchid #{patchId}"

command  = oracle_product_home_dir + '/OPatch/opatch lsinventory -patch_id -oh ' + oracle_product_home_dir + ' -invPtrLoc ' + orainst_dir + '/oraInst.loc'
Puppet.info "opatch_status for patch #{patchName} command: #{command}"

output = `su - #{user} -c '#{command}'`
Puppet.debug "#{output}"
# output = execute command, :failonfail => true ,:uid => user
output.each_line do |li|
  opatch = li[5, li.index(':') - 5].strip + ';' if (li['Patch'] and li[': applied on'])
  unless opatch.nil?
    Puppet.debug "line #{opatch}"
    if opatch.include? patchId
      Puppet.debug 'found patch'
      return patchId
    end
  end
end
'NotFound'

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment