Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-16627

The default "Katello Sync" webhook template has @object.task.action_output defined which is not a valid safemode method in Satellite 6.12

XMLWordPrintable

    • Moderate

      Description of problem:

      The <%= @object.task.action_output %> option cannot be used as mentioned in "Katello Sync" webhook template.

      Version-Release number of selected component (if applicable):

      Satellite 6.12
      Satellite 6.11

      How reproducible:

      Always

      Steps to Reproduce:

      1. Have a Satellite 6.12 built.

      2. Import a manifest and enable any small repo

      3. Enable shellhooks feature.

      4. Create the following shellhook script inside /var/lib/foreman-proxy/shellhooks and make it executable

      1. cat print_objects
        #!/bin/bash

      cat > /tmp/results.txt

      5. Satellite UI --> Administer --> Webhook templates --> Clone the "Katello Sync" template with "Katello Sync clone" name, uncomment all lines that have @object mentioned, and save it

      6. Satellite UI --> Administer --> Webhook and create a new hook.

      1. hammer webhook info --id 2
        Id: 2
        Name: Test
        Target URL: https://satellite.example.com:9090/shellhook/print_objects
        Enabled: yes
        Event: actions.katello.repository.sync_succeeded.event.foreman
        HTTP Method: POST
        HTTP Content Type: application/json
        Webhook Template: Katello Sync clone
        Created at: 2022/09/15 11:57:35
        Updated at: 2022/09/15 12:12:49

      7. Sync the repo while monitoring the production.log .

      Actual results:

      The sync will complete but the webhook execution will fail:

      ~~
      2022-09-15T17:32:01 [E|dyn|67665294] Failed to run hook 'emit_event' for action 'Actions::Katello::Repository::Sync'
      2022-09-15T17:32:01 [E|dyn|67665294] undefined method '#action_output' for ForemanTasks::Task::Jail (ForemanTasks::Task::DynflowTask) (Safemode::NoMethodError)
      67665294 | /usr/share/gems/gems/safemode-1.3.6/lib/safemode/jail.rb:22:in `method_missing'
      67665294 | Katello Sync clone:85:in `bind'
      67665294 | /usr/share/gems/gems/safemode-1.3.6/lib/safemode.rb:51:in `eval'
      67665294 | /usr/share/foreman/app/services/foreman/renderer/safe_mode_renderer.rb:7:in
      ~~

      This happens as "task.action_output" is not a valid object for the repo sync tasks inside safe mode.

      So removing the last line will allow the hook execution i.e.

      ~~
      Task action output <%= @object.task.action_output %>
      ~~

      and the results will be printed inside /tmp/results.txt file as expected.

      Expected results:

      Either remove the offending object entry from the default example template or else make it available to use.

      Additional info:

      If i use a different webhook template with following content:

      <%= payload({
      object: @object.task
      }) %>

      Followng task data gets printed:

      {
      "object":

      { "id": "579d917b-6bc5-46ed-b1b8-4323f016394c", "label": "Actions::Katello::Repository::Sync", "started_at": "2022-09-15T17:50:59.053+05:30", "ended_at": "2022-09-15T17:51:03.221+05:30", "state": "stopped", "result": "success", "external_id": "ce3343c9-d0c6-47d1-9a9a-6fead6a081fc", "parent_task_id": null, "start_at": "2022-09-15T17:50:59.044+05:30", "start_before": null, "action": "Synchronize repository 'Satellite_Client_RHEL8_x86_64'; product 'Sat_Client_612'; organization 'RedHat'", "user_id": 4, "state_updated_at": "2022-09-15T17:51:03.281+05:30" }

      ,

      and action_output is not one of them.

            aruzicka@redhat.com Adam Ruzicka
            jira-bugzilla-migration RH Bugzilla Integration
            Peter Ondrejka Peter Ondrejka
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: