Skip to content

ocm describe cluster fails for Archived/Deprovisioned clusters #517

@cben

Description

@cben

here is an example Deprovisioned subscription

> ocm get sub 2QaydcSjzvQGWHqxRpSReT7mWW4
{
  ...
  "cluster_id": "24301dug094uiivh57o0hfdhotp1cbom",
  "display_name": "celia-imdsv2",
  "external_cluster_id": "89ffcb09-33bd-47ce-aa21-e793383b136d",
  "href": "/api/accounts_mgmt/v1/subscriptions/2QaydcSjzvQGWHqxRpSReT7mWW4",
  "id": "2QaydcSjzvQGWHqxRpSReT7mWW4",
  "kind": "Subscription",
  "managed": true,
  ...
  "organization_id": "1wuVGGV6SCmD8ya6yRGEJzvmVuC",
  "plan": {
    "href": "/api/accounts_mgmt/v1/plans/MOA",
    ...
  },
  "provenance": "Provisioning",
  "status": "Deprovisioned",
}

and now let's try to ocm describe cluster it:

> ocm describe cluster 89ffcb09-33bd-47ce-aa21-e793383b136d
Error: Can't retrieve cluster for key '89ffcb09-33bd-47ce-aa21-e793383b136d': There are no subscriptions or clusters with identifier or name '89ffcb09-33bd-47ce-aa21-e793383b136d'

> ocm describe cluster celia-imdsv2
Error: Can't retrieve cluster for key 'celia-imdsv2': There are no subscriptions or clusters with identifier or name 'celia-imdsv2'

> ocm describe cluster 2QaydcSjzvQGWHqxRpSReT7mWW4
Error: Can't retrieve cluster for key '2QaydcSjzvQGWHqxRpSReT7mWW4': There are no subscriptions or clusters with identifier or name '2QaydcSjzvQGWHqxRpSReT7mWW4'

> ocm describe cluster 24301dug094uiivh57o0hfdhotp1cbom
Error: Can't retrieve cluster for key '24301dug094uiivh57o0hfdhotp1cbom': There are no subscriptions or clusters with identifier or name '24301dug094uiivh57o0hfdhotp1cbom'

These messages are both misleading technically (there is a subscription with these ids) and unfortunate ☹️.

Here are the accessed APIs:

Request URL is 'https://api.stage.openshift.com/api/accounts_mgmt/v1/subscriptions?search=%28display_name+%3D+%2724301dug094uiivh57o0hfdhotp1cbom%27+or+cluster_id+%3D+%2724301dug094uiivh57o0hfdhotp1cbom%27+or+external_cluster_id+%3D+%2724301dug094uiivh57o0hfdhotp1cbom%27%29+and+status+in+%28%27Reserved%27%2C+%27Active%27%29&size=1'

Request URL is 'https://api.stage.openshift.com/api/clusters_mgmt/v1/clusters?search=id+%3D+%2724301dug094uiivh57o0hfdhotp1cbom%27+or+name+%3D+%2724301dug094uiivh57o0hfdhotp1cbom%27+or+external_id+%3D+%2724301dug094uiivh57o0hfdhotp1cbom%27&size=1'

clusters API indeed stops returning data on Archived/Deprovisioned clusters, but subscriptions API retains a lot of info that could be shown (as UI does on https://console.redhat.com/openshift/archived).

Peeking at GetCluster() helper code, it does query subscriptions but appends status in ('Reserved', 'Active') clause.

  • It's used by many commands, most of which still want to only deal with active managed clusters. For those, the error message should be adjusted to say a subscription exists but is inactive.
    => improve GetCluster message when Subscription exists but is inactive #518
  • rename GetCluster -> GetActiveCluster?
  • GetCluster helper returns a cmv1.Cluster so would be unsuitable anyway when we only have subscription data.
    => Add a new GetSubscription / GetSubscriptionAndCluster helper?
  • PrintClusterDescription would need many adjustments to deal with partial data...
  • Accept subscription IDs (currently only looks up by cluster ID | external UUID | display_name)
  • --output and --json flags now dump Cluster JSON. How can we extend them to include Subscription too / support cases of having only Subscription?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions