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

Show server statuses only when they are deployed into the Kubernetes cluster #1603

Merged
merged 11 commits into from Oct 11, 2022

Conversation

t-eckert
Copy link
Contributor

@t-eckert t-eckert commented Oct 7, 2022

Previously, if a user had servers deployed outside of a given K8s cluster, the status command would fail when it attempted to show the health status of servers. We recently removed a similar feature for clients which had the same problem when we moved to the "agentless" architecture.

This PR changes the status command to only print the health status of clients and servers if they are expected to be present in the K8s cluster. If the user is running with the agentless architecture or has servers deployed outside of the cluster (e.g. HCP). The status command will simply not show the health status instead of failing.

Changes proposed in this PR:

  • Only show health status for servers if they are expected to be present in the K8s cluster.
  • Move some constants and vars up to the top of a file where I think it makes more sense for them to be.
  • Fix any tests broken as a result of this change.
Screenshots Agentless status with unhealthy servers no-clients-yes-servers-unhealthy

Agentless status with healthy servers
no-clients-yes-servers-healthy

0.48.0 unhealthy clients and servers
clients-and-servers-unhealthy

0.48.0 unhealthy clients and healthy servers
clients-and-servers-semi-healthy

0.48.0 healthy clients a
clients-and-servers-healthy
nd servers

How I've tested this PR:

  • Unit tests for the CLI cover this change.
  • Deployed Consul to a Kind cluster and ran the status command both when the clients/servers were not ready and as they came online.

How I expect reviewers to test this PR:

  • Running unit tests to check the behavior is expected.

Checklist:

  • Tests added
  • CHANGELOG entry added

    HashiCorp engineers only, community PRs should not add a changelog entry.
    Entries should use present tense (e.g. Add support for...)

@t-eckert t-eckert marked this pull request as ready for review October 10, 2022 17:06
@t-eckert t-eckert requested review from a team, jmurret and kschoche and removed request for a team October 10, 2022 17:32
Copy link
Contributor

@jmurret jmurret left a comment

Choose a reason for hiding this comment

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

Looks good. Nice work! One suggestion on some text and then minor observations.

cli/cmd/status/status.go Outdated Show resolved Hide resolved
return "", errors.New("found multiple server stateful sets")
return err
}
if len(clients.Items) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit. you could make this a shared func for this and below and pass in:

  • agentType string (servers vs clients. also used for string replacement in the output)
  • desiredAgents int
  • readyAgents int

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I appreciate this feedback! I did think about doing that to "DRY" out this function. My thinking with the current way it is written is that one day we will nix the clients check and I don't want an extra function floating around. I think it's nice to just delete the specific lines and not have to change anything else. Once those lines are gone, there won't be any more deduping.

What do you think of that? Am I overthinking it?

cli/cmd/status/status_test.go Outdated Show resolved Hide resolved
Thomas Eckert and others added 2 commits October 11, 2022 14:19
Co-authored-by: John Murret <john.murret@hashicorp.com>
Comment on lines 39 to 45
"No clients, no agents": {0, 0, 0, 0},
"3 clients - 1 healthy, no agents": {3, 1, 0, 0},
"3 clients - 3 healthy, no agents": {3, 3, 0, 0},
"3 clients - 1 healthy, 3 agents - 1 healthy": {3, 1, 3, 1},
"3 clients - 3 healthy, 3 agents - 3 healthy": {3, 3, 3, 3},
"No clients, 3 agents - 1 healthy": {0, 0, 3, 1},
"No clients, 3 agents - 3 healthy": {0, 0, 3, 3},
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're using confusing terminology here, it should be clients and servers since agents means both :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great feedback. I fixed this when removing clients.

@t-eckert t-eckert changed the title Show Clients and Servers statuses only when they are deployed into the Kubernetes cluster Show server statuses only when they are deployed into the Kubernetes cluster Oct 11, 2022
Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

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

Looks great thanks for this.

@t-eckert t-eckert merged commit cd34d0f into main Oct 11, 2022
@t-eckert t-eckert deleted the te/show-status-contextually branch October 11, 2022 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants