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.
here is an example Deprovisioned subscription
and now let's try to
ocm describe clusterit:These messages are both misleading technically (there is a subscription with these ids) and unfortunate☹️ .
Here are the accessed APIs:
clustersAPI indeed stops returning data on Archived/Deprovisioned clusters, butsubscriptionsAPI 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.=> improve GetCluster message when Subscription exists but is inactive #518
GetClusterhelper returns acmv1.Clusterso would be unsuitable anyway when we only have subscription data.=> Add a new GetSubscription / GetSubscriptionAndCluster helper?
PrintClusterDescriptionwould need many adjustments to deal with partial data...--outputand--jsonflags now dump Cluster JSON. How can we extend them to include Subscription too / support cases of having only Subscription?