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

Collector for RRD data #290

Merged
merged 1 commit into from Nov 10, 2020
Merged

Collector for RRD data #290

merged 1 commit into from Nov 10, 2020

Conversation

divolgin
Copy link
Member

@divolgin divolgin commented Oct 31, 2020

Example collector and analyzer

apiVersion: troubleshoot.sh/v1beta2
kind: Analyzer
metadata:
  name: collector-sample
spec:
  collectors:
    - collectd:
        collectorName: "my-rrd"
        namespace: 'default'
        image: 'alpine:3'
        name: my-rrd-name
        hostPath: "/var/lib/collectd/rrd"
        imagePullPolicy: IfNotPresent

  analyzers:
    - collectd:
        checkName: "load and stuff"
        outcomes:
          - fail:
              when: "load > 1"
              message: High load detected on cluster nodes.
          - pass:
              message: Load on cluster nodes does not exceed expected values

Load value is normalized using the number of CPUs found in the RRD data.

Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

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

4 issues found.

pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go Outdated Show resolved Hide resolved
pkg/collect/rrd.go Outdated Show resolved Hide resolved
pkg/collect/rrd.go Outdated Show resolved Hide resolved
pkg/collect/rrd.go Outdated Show resolved Hide resolved
Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

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

4 issues found.

pkg/rrd/rrd.go Show resolved Hide resolved

func getFilesFromPod(ctx context.Context, client *kubernetes.Clientset, c *Collector, podName string, containerName string, namespace string, containerPath string) ([]byte, []byte, error) {
command := []string{"tar", "-C", filepath.Dir(containerPath), "-cf", "-", filepath.Base(containerPath)}
req := client.CoreV1().RESTClient().Post().Resource("pods").Name(podName).Namespace(namespace).SubResource("exec")
Copy link

Choose a reason for hiding this comment

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

Avoid unnecessary use of client-go restClient

View Rule

pkg/rrd/rrd_c.go Outdated
return append(args, makeArgs(e.args)...)
}

func parseInfoKey(ik string) (kname, kkey string, kid int) {
Copy link

Choose a reason for hiding this comment

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

Naked returns harm the readability of code, especially in long functions.

View Rule

pkg/rrd/rrd_c.go Outdated
return r
}

func parseGraphInfo(i *C.rrd_info_t) (gi GraphInfo, img []byte) {
Copy link

Choose a reason for hiding this comment

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

Naked returns harm the readability of code, especially in long functions.

View Rule

@divolgin divolgin force-pushed the divolgin/rrd branch 3 times, most recently from 897a7a6 to a384420 Compare November 4, 2020 01:42
Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

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

8 issues found.

pkg/collect/collectd.go Show resolved Hide resolved
pkg/collect/collectd.go Show resolved Hide resolved
pkg/collect/collectd.go Show resolved Hide resolved
pkg/rrd/rrd_darwin.go Show resolved Hide resolved
pkg/rrd/rrd_linux.go Show resolved Hide resolved
pkg/rrd/rrd_linux.go Show resolved Hide resolved
pkg/rrd/rrd_windows.go Show resolved Hide resolved
@divolgin divolgin force-pushed the divolgin/rrd branch 18 times, most recently from 836d80c to 886720e Compare November 5, 2020 19:44
Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

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

1 issues found.

@@ -42,138 +42,154 @@ func isExcluded(excludeVal multitype.BoolOrString) (bool, error) {
return parsed, nil
}

func (c *Collector) RunCollectorSync(globalRedactors []*troubleshootv1beta2.Redact) (map[string][]byte, error) {
var unRedacted map[string][]byte
func (c *Collector) RunCollectorSync(globalRedactors []*troubleshootv1beta2.Redact) (result map[string][]byte, err error) {
Copy link

Choose a reason for hiding this comment

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

Naked returns harm the readability of code, especially in long functions.

View Rule

@divolgin divolgin force-pushed the divolgin/rrd branch 3 times, most recently from 376e48b to 72e0708 Compare November 10, 2020 16:48
@divolgin divolgin merged commit 88a6d3f into master Nov 10, 2020
@divolgin divolgin deleted the divolgin/rrd branch November 10, 2020 23:57
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