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

Fix backwards "Bouncing to" status #3989

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion paasta_tools/cli/cmds/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,9 @@ def get_instance_state(status: InstanceStatusKubernetesV2) -> str:
else:
return PaastaColors.green("Running")
else:
versions = sorted(status.versions, key=lambda x: x.create_timestamp)
versions = sorted(
status.versions, key=lambda x: x.create_timestamp, reverse=True
)
git_shas = {r.git_sha for r in versions}
config_shas = {r.config_sha for r in versions}
bouncing_to = []
Expand Down
26 changes: 24 additions & 2 deletions tests/cli/test_cmds_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -1820,8 +1820,10 @@ def test_running(self, mock_kubernetes_status_v2):
assert remove_ansi_escape_sequences(instance_state) == "Running"

def test_bouncing(self, mock_kubernetes_status_v2):
old_version = mock_kubernetes_status_v2.versions[0]
new_version = paastamodels.KubernetesVersion(
create_timestamp=1.0,
# ensure creation is after current version
create_timestamp=old_version.create_timestamp + 1000,
git_sha="bbb111",
config_sha="config111",
ready_replicas=0,
Expand All @@ -1832,9 +1834,29 @@ def test_bouncing(self, mock_kubernetes_status_v2):
instance_state = remove_ansi_escape_sequences(instance_state)
assert instance_state == "Bouncing to bbb111, config111"

def test_bouncing_ordering(self, mock_kubernetes_status_v2):
old_version = mock_kubernetes_status_v2.versions[0]
new_version = paastamodels.KubernetesVersion(
# ensure creation is _before_ current version
create_timestamp=old_version.create_timestamp - 1000,
git_sha="bbb111",
config_sha="config111",
ready_replicas=0,
)
mock_kubernetes_status_v2.versions.append(new_version)

instance_state = get_instance_state(mock_kubernetes_status_v2)
instance_state = remove_ansi_escape_sequences(instance_state)
assert instance_state != "Bouncing to bbb111, config111"
assert (
instance_state
== f"Bouncing to {old_version.git_sha[:8]}, {old_version.config_sha}"
)

def test_bouncing_git_sha_change_only(self, mock_kubernetes_status_v2):
old_version = mock_kubernetes_status_v2.versions[0]
new_version = paastamodels.KubernetesVersion(
create_timestamp=1.0,
create_timestamp=old_version.create_timestamp + 1000,
git_sha="bbb111",
config_sha=mock_kubernetes_status_v2.versions[0].config_sha,
ready_replicas=0,
Expand Down