Skip to content

Commit

Permalink
Add docs suggestion to deploytime report
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin M Granger <kgranger@redhat.com>
  • Loading branch information
KevinMGranger committed Sep 15, 2022
1 parent 42ffef8 commit 2ade153
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/troubleshooting/missing_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import pelorus.utils
from pelorus.utils import paginate_resource

DOCS_BASE_URL = "https://pelorus.readthedocs.io/en/stable/"
DEPLOYTIME_PREPARE_DATA_URL = DOCS_BASE_URL + "GettingStarted#preparing-your-data"
COMMITTIME_PREPARE_DATA_URL = DOCS_BASE_URL + "GettingStarted#commit-time"

# A NOTE ON TERMINOLOGY:
# what you might call a "resource" in openshift is called a ResourceInstance by the client.
# to the client, a Resource is its "type definition".
Expand Down Expand Up @@ -197,6 +201,10 @@ class DeploytimeTroubleshootingReport:
pods_missing_app_label: list[PodId]
replicators_missing_app_label: dict[ReplicatorId, OwnedPods]

@property
def anything_to_report(self):
return self.pods_missing_app_label or self.replicators_missing_app_label

def _print_pods(self):
if not self.pods_missing_app_label:
print("No pods were missing the app label", self.app_label)
Expand All @@ -216,10 +224,16 @@ def _print_replicators(self):
for replicator in self.replicators_missing_app_label:
print(" ", replicator.kind_, replicator.name)

def _print_suggestion(self):
print(f"Add the label {self.app_label}.")
print("See", DEPLOYTIME_PREPARE_DATA_URL)

def print_human_readable(self):
self._print_pods()
print()
self._print_replicators()
if self.anything_to_report:
self._print_suggestion()

def to_json(self) -> dict:
pods_missing_label = [pod.name for pod in self.pods_missing_app_label]
Expand Down Expand Up @@ -253,6 +267,10 @@ class CommittimeTroubleshootingReport:

builds_missing_app_label: list[BuildId]

@property
def anything_to_report(self):
return bool(self.builds_missing_app_label)

def print_human_readable(self):
if not self.builds_missing_app_label:
print("No builds were missing the app label", self.app_label)
Expand All @@ -262,6 +280,8 @@ def print_human_readable(self):
for build in self.builds_missing_app_label:
print(build.name)

# TODO: app label committime docs?

def to_json(self) -> dict:
return dict(
namespace=namespace,
Expand Down

0 comments on commit 2ade153

Please sign in to comment.