Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Hook 'system cluster-info' command #1531

Merged
merged 3 commits into from May 11, 2020

Conversation

a-palchikov
Copy link
Contributor

@a-palchikov a-palchikov commented May 8, 2020

Description

This PR adds the hook up for the system cluster-info command added in #1361. Without this, the debug reports will contain a figment of kubernetes resources (i.e. will not have container logs).
For some reason, the forward port did not have the command hook up code.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change has a user-facing impact

Linked tickets and other PRs

TODOs

  • Self-review the change
  • Perform manual testing
  • Address review feedback

Testing done

Debug logs (focused on kubernetes) captured before the change:

$ gravity system cluster-info --help
[ERROR]: expected command but got "cluster-info"
$ gravity system report --filter=kubernetes >report.tgz
$ tar tvf report.tgz
-rw-r--r-- root/root      2375 2020-05-08 20:49 k8s-daemonsets
-rw-r--r-- root/root      6142 2020-05-08 20:49 k8s-deployments
-rw-r--r-- root/root     18996 2020-05-08 20:49 k8s-describe-daemonsets
-rw-r--r-- root/root     40553 2020-05-08 20:49 k8s-describe-deployments
-rw-r--r-- root/root     17206 2020-05-08 20:49 k8s-describe-endpoints
-rw-r--r-- root/root     41833 2020-05-08 20:49 k8s-describe-jobs
-rw-r--r-- root/root     31004 2020-05-08 20:49 k8s-describe-nodes
-rw-r--r-- root/root    204307 2020-05-08 20:49 k8s-describe-pods
-rw-r--r-- root/root     37824 2020-05-08 20:49 k8s-describe-replicasets
-rw-r--r-- root/root     11683 2020-05-08 20:49 k8s-describe-services
-rw-r--r-- root/root      3796 2020-05-08 20:49 k8s-endpoints
-rw-r--r-- root/root      2501 2020-05-08 20:49 k8s-jobs
-rw-r--r-- root/root      5454 2020-05-08 20:49 k8s-logs-kube-system-coredns-98n5q-coredns-prev
... <more previous container logs skipped>
-rw-r--r-- root/root       614 2020-05-08 20:49 k8s-nodes
-rw-r--r-- root/root      6393 2020-05-08 20:49 k8s-pods
-rw-r--r-- root/root      6704 2020-05-08 20:49 k8s-replicasets
-rw-r--r-- root/root      2912 2020-05-08 20:49 k8s-services

Debug logs after the change:

$ ./gravity system cluster-info --help
usage: gravity system cluster-info

dump kubernetes cluster info suitable for debugging

Flags:
      --help                 Show context-sensitive help (also try --help-long and --help-man).
      --debug                Enable debug mode.
  -q, --quiet                Suppress any extra output to stdout.
      --insecure             Skip TLS verification.
      --state-dir=STATE-DIR  Gravity local state directory.
      --log-file="/var/log/gravity-install.log"  
                             Path to the log file with diagnostic information.
$ ./gravity system report --filter=kubernetes >report.tgz
$ tar tvf report.tgz 
-rw-r--r-- root/root    307338 2020-05-08 20:46 k8s-cluster-info-dump.tgz
-rw-r--r-- root/root      2375 2020-05-08 20:46 k8s-daemonsets
-rw-r--r-- root/root      6142 2020-05-08 20:46 k8s-deployments
-rw-r--r-- root/root     18996 2020-05-08 20:46 k8s-describe-daemonsets
-rw-r--r-- root/root     40553 2020-05-08 20:46 k8s-describe-deployments
-rw-r--r-- root/root     17206 2020-05-08 20:46 k8s-describe-endpoints
-rw-r--r-- root/root     41833 2020-05-08 20:46 k8s-describe-jobs
-rw-r--r-- root/root     31004 2020-05-08 20:46 k8s-describe-nodes
-rw-r--r-- root/root    204307 2020-05-08 20:46 k8s-describe-pods
-rw-r--r-- root/root     37824 2020-05-08 20:46 k8s-describe-replicasets
-rw-r--r-- root/root     11683 2020-05-08 20:46 k8s-describe-services
-rw-r--r-- root/root      3796 2020-05-08 20:46 k8s-endpoints
-rw-r--r-- root/root      2501 2020-05-08 20:46 k8s-jobs
-rw-r--r-- root/root      5454 2020-05-08 20:46 k8s-logs-kube-system-coredns-98n5q-coredns-prev
... <more previous container logs skipped>
-rw-r--r-- root/root       614 2020-05-08 20:46 k8s-nodes
-rw-r--r-- root/root      6393 2020-05-08 20:46 k8s-pods
-rw-r--r-- root/root      6704 2020-05-08 20:46 k8s-replicasets
-rw-r--r-- root/root      2912 2020-05-08 20:46 k8s-services

@a-palchikov a-palchikov requested review from a team, r0mant and knisbet May 8, 2020 20:40
@@ -38,7 +37,7 @@ func NewKubernetesCollector(ctx context.Context, runner utils.CommandRunner) Col
Cmd("k8s-nodes", utils.PlanetCommand(kubectl.Command("get", "nodes", "--output", "wide"))...),
Cmd("k8s-describe-nodes", utils.PlanetCommand(kubectl.Command("describe", "nodes"))...),
Cmd("k8s-cluster-info-dump.tgz",
constants.GravityBin, "system", "cluster-info"),
utils.Exe.Path, "system", "cluster-info"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will ensure that the command works consistently regardless of the operation state - i.e. during upgrade.

@a-palchikov a-palchikov merged commit 89aa72c into version/7.0.x May 11, 2020
@a-palchikov a-palchikov deleted the dmitri/7.0.x/cluster-info-cmd branch May 11, 2020 16:04
@a-palchikov a-palchikov mentioned this pull request Jul 15, 2020
3 tasks
a-palchikov added a commit that referenced this pull request Jul 24, 2020
* Expand improvements (#1361)

* Forward port changes from 6.3.x
* Fix tests
* Do not pull/unpack planet package as it needs special attention to file/directory context
* Forward port changes from #1348
* Format multiple operations in 'gravity plan' if outputting as text as a table. Forward ports #1373

* Revert LVMSystemDir to schema backwards compatible and mark it deprecated in code.
Handle completed operation error gracefully in expand.

* Remove container name in selinux Makefile to avoid conflicts with multiple jenkins jobs

* Rework client/agent logic to remove the agent from the agent group
running by the cluster controller after the operation is completed.

* Bump e

* Port another slew of PRs:
 * #1361
 * #1424
 * #1530
 * #1531
 * #1542
 * #1603
 * #1648
 * https://github.com/gravitational/gravity.e/pull/4298

* Regenerate proto sources

* Address review comments

* Bump e. Update cli args test to use a common set of redacted flags for redact test cases

* Revert another test change

* Correct planet path for journalctl
helgi pushed a commit to helgi/gravity that referenced this pull request Jun 21, 2021
* Expand improvements (gravitational#1361)

* Forward port changes from 6.3.x
* Fix tests
* Do not pull/unpack planet package as it needs special attention to file/directory context
* Forward port changes from gravitational#1348
* Format multiple operations in 'gravity plan' if outputting as text as a table. Forward ports gravitational#1373

* Revert LVMSystemDir to schema backwards compatible and mark it deprecated in code.
Handle completed operation error gracefully in expand.

* Remove container name in selinux Makefile to avoid conflicts with multiple jenkins jobs

* Rework client/agent logic to remove the agent from the agent group
running by the cluster controller after the operation is completed.

* Bump e

* Port another slew of PRs:
 * gravitational#1361
 * gravitational#1424
 * gravitational#1530
 * gravitational#1531
 * gravitational#1542
 * gravitational#1603
 * gravitational#1648
 * https://github.com/gravitational/gravity.e/pull/4298

* Regenerate proto sources

* Address review comments

* Bump e. Update cli args test to use a common set of redacted flags for redact test cases

* Revert another test change

* Correct planet path for journalctl
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants