Bug 1412150

Summary: activation returns 0 even if it fails
Product: Red Hat Satellite 5 Reporter: Jan Hutař <jhutar>
Component: Satellite SynchronizationAssignee: Jan Dobes <jdobes>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Studeník <pstudeni>
Severity: low Docs Contact:
Priority: unspecified    
Version: 580CC: galtukho, pstudeni, rdrazny, tlestach
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-backend-2.5.3-120 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-21 12:13:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1340444    

Description Jan Hutař 2017-01-11 12:02:24 UTC
Description of problem:
Activation returns 0 even if it fails


Version-Release number of selected component (if applicable):
spacewalk-backend-cdn-2.5.3-48.el6sat.noarch
spacewalk-backend-tools-2.5.3-48.el6sat.noarch


How reproducible:
always


Steps to Reproduce:
1. Have a buggy certificate in a manifest (specifying negative quantity) or
   maybe just register 2 RHELs and attempt to reactivate with manifest which
   only allows 1 would be sufficient


Actual results:
[Wed Jan 11 12:53:17 CET 2017] RUNNING rhn-satellite-activate -vv --manifest 'manifest_c8b26514-96db-4083-9682-3abf332eb8e9.zip'
  Checking cert XML sanity and GPG signature: '/usr/bin/validate-sat-cert.pl --keyring /etc/webapp-keyring.gpg /etc/sysconfig/rhn/rhsm-manifest.zip-cert-APj0Wy'
  Database connectioned initialized: refer to /etc/rhn/rhn.conf
  Attempting local RHN Certificate push (and therefore activation)
  Certificate specifies -39 of rhel-client-7-fastrack non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-client-7-fastrack-debug non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-client-7-rh-common non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-client-7-rh-common-beta non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-client-7-rh-common-beta-debug non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-client-7-rh-common-debug non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-workstation-7-fastrack non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-workstation-7-fastrack-debug non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-workstation-7-rh-common non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-workstation-7-rh-common-beta non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-workstation-7-rh-common-beta-debug non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -39 of rhel-workstation-7-rh-common-debug non-flex entitlements.
      There are    You might need to .
      You need to free 39 entitlements to match the new certificate.
  Certificate specifies -17 of rhel-server-7-oracle-java-beta non-flex entitlements.
      There are    You might need to .
      You need to free 17 entitlements to match the new certificate.
  Certificate specifies -16 of rhel-server-7-fastrack non-flex entitlements.
      There are    You might need to .
      You need to free 16 entitlements to match the new certificate.
  Certificate specifies -16 of rhel-server-7-fastrack-debug non-flex entitlements.
      There are    You might need to .
      You need to free 16 entitlements to match the new certificate.
  Activation failed, will now exit with no changes.
[Wed Jan 11 12:53:44 CET 2017] EXIT CODE 0


Expected results:
Should exit with 1 or so.


Additional info:
Maybe exiting with 0 is expected here. Just wanted to share the concern.

Comment 3 Jan Dobes 2017-05-04 13:24:39 UTC
I can't reproduce it on newer version, this case was probably fixed in different BZ, switching to MODIFIED.

# rpm -q spacewalk-backend
spacewalk-backend-2.5.3-120.el6sat.noarch

# rhn-satellite-activate --manifest manifest_c8b26514-96db-4083-9682-3abf332eb8e9.zip 
09:23:34 Populating channel families...
09:23:34 Updating certificates...
09:23:35 WARNING: 'CDN-CLIENT-CERT-8a99f99e596553270159741b1363080f' certificate is not valid.
09:23:36 WARNING: 'CDN-CLIENT-CERT-8a99f9845958a3cb01597406caed08e9' certificate is not valid.
09:23:37 Updating manifest repositories...

ERROR: unhandled exception occurred:
Traceback (most recent call last):
  File "/usr/bin/rhn-satellite-activate", line 38, in <module>
    sys.exit(abs(mod.main() or 0))
  File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/rhn_satellite_activate.py", line 549, in main
    localUpdateChannels(cdn_activate.manifest.get_satellite_certificate())
  File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/rhn_satellite_activate.py", line 290, in localUpdateChannels
    sync_handlers.populate_channel_family_permissions(sat_cert)
  File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/sync_handlers.py", line 706, in populate_channel_family_permissions
    importer.run()
  File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/importLib.py", line 675, in run
    self.submit()
  File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/channelImport.py", line 301, in submit
    self.backend.processChannelFamilyPermissions(self.batch)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backend.py", line 1119, in processChannelFamilyPermissions
    cfp['channel_family'], cfp['max_members'], cfp['max_flex'])
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 116, in __call__
    result = Function.__call__(self, *args)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 92, in __call__
    raise sql_base.SQLSchemaError(error_code, e.pgerror, e)
spacewalk.common.rhnException.rhnFault: (23, 'ERROR:  -20290 : (not_enough_entitlements_in_base_org) - You do not have enough entitlements in the base org.: org_id [1] family [rhel-client-7-rh-common-debug] max [-39]', 'Could not update database entry.')

# echo $?
1

Comment 5 Pavel Studeník 2017-05-17 11:50:39 UTC
Verified with spacewalk-backend-tools-2.5.3-131.el6sat.noarch

>> rhn-satellite-activate --manifest manifest.zip 
Certificate specifies 1 of enterprise_entitled entitlements.
    There are 8 entitlements used by systems in the base (id 1) organization.
    You might need to unentitle some systems in the base organization.
    You need to free 7 entitlements to match the new certificate.
    In the WebUI, the entitlement is named Management.
Certificate specifies 1 of provisioning_entitled entitlements.
    There are 8 entitlements used by systems in the base (id 1) organization.
    You might need to unentitle some systems in the base organization.
    You need to free 7 entitlements to match the new certificate.
    In the WebUI, the entitlement is named Provisioning.
Activation failed, will now exit with no changes.
>> echo $?
1


>> rhn-satellite-activate --manifest manifest_fail.zip 

ERROR: Red Hat Satellite Entitlement Certificate failed to validate.
MORE INFORMATION:
  Return value: 255
  Standard-out: 
  Standard-error: RHN::Exception: Required field slots not found in RHN::SatelliteCert=HASH(0x21a7f38)
  RHN::Cert /usr/share/perl5/vendor_perl/RHN/Cert.pm 218 RHN::Exception::throw
  main /usr/bin/validate-sat-cert.pl 60 RHN::Cert::check_required_fields

ERROR: RHN Entitlement Certificate failed to validate.

>> echo $?
10