Skip to content
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

Fixes #36530 - Fix up /katello/api/sync_plans/:sync_plan_id/product… #10632

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

qcjames53
Copy link
Contributor

…s and /katello/api/repositories/:repository_id/sync API endpoints.

Fixed broken ktests

What are the changes introduced in this pull request?

Fixed the Katello API endpoints for the following URLs:

GET /katello/api/sync_plans/:sync_plan_id/products 	(List of Products for sync plan)
GET /katello/api/repositories/:repository_id/sync 	(Get status of synchronisation for given repository)

and removed the endpoint for the following URL:

GET /katello/api/organizations/:organization_id/products/:product_id/sync 	(Get status of repo synchronisation for given product)

These endpoints broke when certain Pulp 2 functionality was removed from Foreman and Katello. The removed endpoint should no longer appear in the API documentation.

Considerations taken when implementing this change?

We believe that nothing is querying the removed endpoint (product lookup via candlepin id and organization). If we for some reason need this functionality, I'd be more than happy to fix it as well.

What are the testing steps for this pull request?

  1. Create a repository with products and a sync plan.
  2. Go to <host>/katello/sync_management. Ensure that running 'Synchronize now' on your repo functions as expected.
  3. Go to <host>/apidoc/v2.html. Ensure that the first two API endpoints are listed and that the third is not.
  4. Using a terminal, run these commands to verify the API endpoints work:
curl --user admin:changeme --request GET <host>/katello/api/sync_plans/<sp_id>/products?organization_id=1
curl --user admin:changeme --request GET <host>/katello/api/repositories/<repo_id>/sync
  1. Ensure the following command fails:
curl --user admin:changeme --request GET centos8-katello-devel.redhat.example.com/katello/api/organizations/1/products/1/sync

You should expect a big ol' html doc which indicates an invalid route.

…s and /katello/api/repositories/:repository_id/sync API endpoints.

Fixed broken ktests
@theforeman-bot
Copy link

Issues: #36530

Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised.

  • the two endpoints work
  • the removed endpoint fails as expected
  • Sync Status page and Tasks tab of product detail page continue to work as expected
[vagrant@centos8-katello-devel-stable katello]$ curl --user admin:changeme --request GET https://centos8-katello-devel-stable.example.com/katello/api/sync_plans/1/products?organization_id=1 | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   800  100   800    0     0   1120      0 --:--:-- --:--:-- --:--:--  1118
{
  "total": 1,
  "subtotal": 1,
  "selectable": 1,
  "page": 1,
  "per_page": 20,
  "error": null,
  "search": null,
  "sort": {
    "by": "name",
    "order": "asc"
  },
  "results": [
    {
      "id": 305,
      "cp_id": "602111952143",
      "name": "EPEL8",
      "label": "EPEL8",
      "description": null,
      "provider_id": 1,
      "sync_plan_id": 1,
      "sync_summary": {
        "pending": 1,
        "warning": 1,
        "success": 1
      },
      "gpg_key_id": null,
      "ssl_ca_cert_id": null,
      "ssl_client_cert_id": null,
      "ssl_client_key_id": null,
      "sync_state": "Syncing Complete.",
      "last_sync": "2023-06-29 13:07:03 UTC",
      "last_sync_words": "4 minutes",
      "organization_id": 1,
      "organization": {
        "name": "Default Organization",
        "label": "Default_Organization",
        "id": 1
      },
      "sync_plan": {
        "id": 1,
        "name": "Weekly",
        "description": null,
        "sync_date": "2023-06-29 13:07:00 UTC",
        "interval": "weekly",
        "next_sync": "2023-07-06 13:07:00 UTC",
        "cron_expression": null
      },
      "repository_count": 3
    }
  ]
}
[vagrant@centos8-katello-devel-stable katello]$ curl --user admin:changeme --request GET https://centos8-katello-devel-stable.example.com/katello/api/repositories/24/sync | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1949    0  1949    0     0   3492      0 --:--:-- --:--:-- --:--:--  3486
{
  "id": "b87129f4-1993-48ed-ba99-cff14f9eeec7",
  "label": "Actions::Katello::Repository::Sync",
  "pending": true,
  "action": "Synchronize repository 'EPEL8 x86_64'; product 'EPEL8'; organization 'Default Organization'",
  "username": "admin",
  "started_at": "2023-06-29 13:05:43 UTC",
  "ended_at": null,
  "state": "running",
  "result": "pending",
  "progress": 0.63,
  "input": {
    "repository": {
      "id": 24,
      "name": "EPEL8 x86_64",
      "label": "EPEL8_x86_64"
    },
    "product": {
      "id": 305,
      "name": "EPEL8",
      "label": "EPEL8",
      "cp_id": "602111952143"
    },
    "provider": {
      "id": 1,
      "name": "Anonymous"
    },
    "organization": {
      "id": 1,
      "name": "Default Organization",
      "label": "Default_Organization"
    },
    "services_checked": [
      "pulp3"
    ],
    "id": 24,
    "sync_result": {
      "class": "Dynflow::ExecutionPlan::OutputReference",
      "execution_plan_id": "e7a5823e-e692-43f5-ae32-8ce7a1d405cf",
      "step_id": 19,
      "action_id": 2,
      "subkeys": []
    },
    "skip_metadata_check": false,
    "validate_contents": false,
    "contents_changed": {
      "class": "Dynflow::ExecutionPlan::OutputReference",
      "execution_plan_id": "e7a5823e-e692-43f5-ae32-8ce7a1d405cf",
      "step_id": 19,
      "action_id": 2,
      "subkeys": [
        "contents_changed"
      ]
    },
    "locale": "en",
    "current_request_id": "b7a4e7ae-c635-4c8d-952e-ae47da19654e",
    "current_timezone": "America/New_York",
    "current_organization_id": 1,
    "current_location_id": 2,
    "current_user_id": 4
  },
  "output": {},
  "humanized": {
    "action": "Synchronize",
    "input": [
      [
        "repository",
        {
          "text": "repository 'EPEL8 x86_64'",
          "link": null
        }
      ],
      [
        "product",
        {
          "text": "product 'EPEL8'",
          "link": "/products/305/"
        }
      ],
      [
        "organization",
        {
          "text": "organization 'Default Organization'",
          "link": "/organizations/1/edit"
        }
      ]
    ],
    "output": "Total steps: 13826/13826\n--------------------------------\nAssociating Content: 99/99\nDownloading Artifacts: 70/70\nDownloading Metadata Files: 6/6\nParsed Advisories: 3760/3760\nParsed Comps: 24/24\nParsed Packages: 9761/9761\nSkipping Packages: 0/0\nUn-Associating Content: 106/106",
    "errors": []
  },
  "cli_example": null,
  "start_at": "2023-06-29 13:05:43 UTC",
  "available_actions": {
    "cancellable": false,
    "resumable": false
  }
}

@evgeni I took a look at https://docs.ansible.com/ansible/latest/collections/theforeman/foreman/organization_module.html#ansible-collections-theforeman-foreman-organization-module and https://docs.ansible.com/ansible/latest/collections/theforeman/foreman/sync_plan_module.html#ansible-collections-theforeman-foreman-sync-plan-module and I don't think removing GET /organizations/:organization_id/products/:product_id/sync will break FAM, but please correct me if I'm wrong :)

@evgeni
Copy link
Member

evgeni commented Jun 29, 2023

Correct, this one is not used in FAM.

What we do use is POST /katello/api/products/:product_id/sync from

api :POST, "/products/:id/sync", N_("Sync all repositories for a product")
but that's totally unrelated (but has a waaaaay to similar name).

@jeremylenz
Copy link
Member

Nice, then my ACK becomes unqualified!

thanks @qcjames53! LGTM 👍

@jeremylenz jeremylenz changed the title Fixes #36530 - Fixed up /katello/api/sync_plans/:sync_plan_id/product… Fixes #36530 - Fix up /katello/api/sync_plans/:sync_plan_id/product… Jun 29, 2023
@jeremylenz jeremylenz merged commit a2959b2 into Katello:master Jul 3, 2023
5 checks passed
@qcjames53 qcjames53 deleted the 36530-fix-sync-api-endpoints branch July 3, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants