Skip to content

Commit

Permalink
Initialize csm-metrics-powerscale repository
Browse files Browse the repository at this point in the history
1. Initialize csm-metrics-powerscale repository;
2. Add open source documents, create code structure for the repository.
  • Loading branch information
taohe1012 committed Jun 22, 2022
1 parent 1d21e5f commit 2326a90
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CODEOWNERS
#
# documentation for this file can be found at:
# https://help.github.com/en/articles/about-code-owners

# These are the default owners for the code and will
# be requested for review when someone opens a pull request.
# order is alphabetical for easier maintenance.
#
# Forrest Xia (forrestxia)
# Yian Zong (YianZong)
# Yiming Bao (baoy1)
# Tao He (taohe1012)
# Peter Cao (P-Cao)


# for all files:
* @forrestxia @YianZong @baoy1 @taohe1012 @P-Cao
33 changes: 33 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Description
A few sentences describing the overall goals of the pull request's commits.

# GitHub Issues
List the GitHub issues impacted by this PR:

| GitHub Issue # |
| -------------- |
| |

# Checklist:

- [ ] I have performed a self-review of my own code to ensure there are no formatting, vetting, linting, or security issues
- [ ] I have verified that new and existing unit tests pass locally with my changes
- [ ] I have not allowed coverage numbers to degenerate
- [ ] I have maintained at least 90% code coverage
- [ ] I have inspected the Grafana dashboards to verify the data is displayed properly
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have maintained backward compatibility

# How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

# Manual inspection of the GUI
I have verified that the dashboards show the data properly while generating I/O and storage resources

- [ ] Yes
- [ ] No
78 changes: 78 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Workflow
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
code-check:
name: Check Go formatting, linting, vetting
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Run the formatter, linter, and vetter
uses: dell/common-github-actions/go-code-formatter-linter-vetter@main
with:
directories: ./...
sanitize:
name: Check for forbidden words
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Run the forbidden words scan
uses: dell/common-github-actions/code-sanitizer@main
with:
args: /github/workspace
test:
name: Run Go unit tests and check package coverage
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Run unit tests and check package coverage
uses: dell/common-github-actions/go-code-tester@main
with:
threshold: 90
go_security_scan:
name: Go security
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Run Go Security
uses: securego/gosec@master
malware_security_scan:
name: Malware Scanner
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Run malware scan
uses: dell/common-github-actions/malware-scanner@main
with:
directories: .
options: -ri
image_security_scan:
name: Image Scanner
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18+
uses: actions/setup-go@v2
with:
go-version: ^1.18
id: go
- name: Checkout the code
uses: actions/checkout@v2
- name: Install Mockgen
run: go get github.com/golang/mock/mockgen@v1.6.0
- name: Get dependencies
run: go mod download
- name: Build csm-metrics-powerscale Docker Image
run: make clean build docker
- name: Image scanner
uses: Azure/container-scan@v0
with:
image-name: csm-metrics-powerscale
severity-threshold: HIGH
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
cmd/*/bin/
**/.vscode/
**/.idea/
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM scratch
LABEL vendor="Dell Inc." \
name="csm-metrics-powerscale" \
summary="Dell Container Storage Modules (CSM) for Observability - Metrics for PowerScale" \
description="Provides insight into storage usage and performance as it relates to the CSI (Container Storage Interface) Driver for Dell PowerScale" \
version="2.0.0" \
license="Apache-2.0"
ARG SERVICE
COPY $SERVICE/bin/service /service
ENTRYPOINT ["/service"]
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.PHONY: all
all: help

help:
@echo
@echo "The following targets are commonly used:"
@echo
@echo "build - Builds the code locally"
@echo "clean - Cleans the local build"
@echo "docker - Builds Docker images"
@echo "push - Pushes Docker images to a registry"
@echo "check - Runs code checking tools: lint, format, gosec, and vet"
@echo "test - Runs the unit tests"
@echo

.PHONY: build
build:
@$(foreach svc,$(shell ls cmd), CGO_ENABLED=0 GOOS=linux go build -o ./cmd/${svc}/bin/service ./cmd/${svc}/;)

.PHONY: clean
clean:
rm -rf cmd/*/bin

.PHONY: generate
generate:
go generate ./...

.PHONY: test
test:
go test -count=1 -cover -race -timeout 30s -short ./...

.PHONY: docker
docker:
SERVICE=cmd/metrics-powerscale docker build -t csm-metrics-powerscale -f Dockerfile cmd/metrics-powerscale/

.PHONY: push
push:
docker push ${DOCKER_REPO}/csm-metrics-powerscale\:latest

.PHONY: tag
tag:
docker tag csm-metrics-powerscale\:latest ${DOCKER_REPO}/csm-metrics-powerscale\:latest

.PHONY: check
check:
./scripts/check.sh ./cmd/... ./opentelemetry/... ./internal/...
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!--
Copyright (c) 2022 Dell Inc., or its subsidiaries. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
-->

# Observability Module for PowerScale

[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](https://github.com/dell/csm/blob/main/docs/CODE_OF_CONDUCT.md)
[![License](https://img.shields.io/github/license/dell/csm-metrics-powerscale)](LICENSE)
[![Docker Pulls](https://img.shields.io/docker/pulls/dellemc/csm-metrics-powerscale)](https://hub.docker.com/r/dellemc/csm-metrics-powerscale)
[![Go version](https://img.shields.io/github/go-mod/go-version/dell/csm-metrics-powerscale)](go.mod)
[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/dell/csm-metrics-powerscale?include_prereleases&label=latest&style=flat-square)](https://github.com/dell/csm-metrics-powerscale/releases/latest)

Metrics for PowerScale is part of Dell Container Storage Modules (CSM) for Observability, which provides Kubernetes administrators standardized approaches for storage observability in Kuberenetes environments.

Metrics for PowerScale is an open source distributed solution that provides insight into storage usage and performance as it relates to the CSI (Container Storage Interface) Driver for Dell PowerScale.

Metrics for PowerScale captures telemetry data of storage usage and performance obtained through the CSI Driver for Dell PowerScale. The Metrics service pushes it to the OpenTelemetry Collector, so it can be processed, and exported in a format consumable by Prometheus. Prometheus can then be configured to scrape the OpenTelemetry Collector exporter endpoint to provide metrics so they can be visualized in Grafana.

For documentation, please visit [Container Storage Modules documentation](https://dell.github.io/csm-docs/).

## Table of Contents

- [Code of Conduct](https://github.com/dell/csm/blob/main/docs/CODE_OF_CONDUCT.md)
- [Maintainer Guide](https://github.com/dell/csm/blob/main/docs/MAINTAINER_GUIDE.md)
- [Committer Guide](https://github.com/dell/csm/blob/main/docs/COMMITTER_GUIDE.md)
- [Contributing Guide](https://github.com/dell/csm/blob/main/docs/CONTRIBUTING.md)
- [Branching Strategy](https://github.com/dell/csm/blob/main/docs/BRANCHING.md)
- [List of Adopters](https://github.com/dell/csm/blob/main/ADOPTERS.md)
- [Maintainers](https://github.com/dell/csm/blob/main/docs/MAINTAINERS.md)
- [Support](https://github.com/dell/csm/blob/main/docs/SUPPORT.md)
- [Security](https://github.com/dell/csm/blob/main/docs/SECURITY.md)
- [About](#about)

## Building Metrics for PowerScale

If you wish to clone and build the Metrics for PowerScale service, a Linux host is required with the following installed:

| Component | Version | Additional Information |
| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Docker | v19+ | [Docker installation](https://docs.docker.com/engine/install/) |
| Docker Registry | | Access to a local/corporate [Docker registry](https://docs.docker.com/registry/) |
| Golang | v1.18+ | [Golang installation](https://github.com/travis-ci/gimme) |
| gosec | | [gosec](https://github.com/securego/gosec) |
| gomock | v.1.6.0 | [Go Mock](https://github.com/golang/mock) |
| git | latest | [Git installation](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) |
| gcc | | Run ```sudo apt install build-essential``` |
| kubectl | 1.23.5 | Ensure you copy the kubeconfig file from the Kubernetes cluster to the linux host. [kubectl installation](https://kubernetes.io/docs/tasks/tools/install-kubectl/) |
| Helm | v.3.8.1 | [Helm installation](https://helm.sh/docs/intro/install/) |

Once all prerequisites are on the Linux host, follow the steps below to clone and build the metrics service:

1. Clone the repository using the following command: `git clone https://github.com/dell/csm-metrics-powerscale.git`
2. Set the DOCKER_REPO environment variable to point to the local Docker repository, for example: `export DOCKER_REPO=<ip-address>:<port>`
3. In the csm-metrics-powerscale directory, run the following command to build the Docker image called csm-metrics-powerscale: `make clean build docker`
4. Tag (with the "latest" tag) and push the image to the local Docker repository by running the following command: `make tag push`

__Note:__ Linux support only. If you are using a local insecure docker registry, ensure you configure the insecure registries on each of the Kubernetes worker nodes to allow access to the local docker repository.

## Testing the Observability Module for PowerScale

From the root directory where the repo was cloned, the unit tests can be executed using the following command:

```console
make test
```

This will also provide code coverage statistics for the various Go packages.

## Versioning

This project is adhering to [Semantic Versioning](https://semver.org/).

## About

Dell Container Storage Modules (CSM) is 100% open source and community-driven. All components are available
under [Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0.html) on
GitHub.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/dell/csm-metrics-powerscale

go 1.18
58 changes: 58 additions & 0 deletions scripts/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

CHECK_DIRS="$*"

if [ -f "../vendor" ]; then
# Tell the applicable Go tools to use the vendor directory, if it exists.
MOD_FLAGS="-mod=vendor"
fi
FMT_TMPFILE=/tmp/check_fmt
FMT_COUNT_TMPFILE=${FMT_TMPFILE}.count

fmt_count() {
if [ ! -f $FMT_COUNT_TMPFILE ]; then
echo "0"
fi

head -1 $FMT_COUNT_TMPFILE
}

fmt() {
gofmt -d ${CHECK_DIRS//...} | tee $FMT_TMPFILE
cat $FMT_TMPFILE | wc -l > $FMT_COUNT_TMPFILE
if [ ! `cat $FMT_COUNT_TMPFILE` -eq "0" ]; then
echo Found `cat $FMT_COUNT_TMPFILE` formatting issue\(s\).
return 1
fi
}

echo === Checking format...
fmt
FMT_RETURN_CODE=$?
echo === Finished

echo === Vetting...
go vet ${MOD_FLAGS} ${CHECK_DIRS}
VET_RETURN_CODE=$?
echo === Finished

echo === Linting...
(command -v golint >/dev/null 2>&1 \
|| GO111MODULE=off GOINSECURE=golang.org/x/lint/golint go get -u golang.org/x/lint/golint) \
&& golint --set_exit_status ${CHECK_DIRS}
LINT_RETURN_CODE=$?
echo === Finished

echo === Running gosec...
gosec -quiet ${MOD_FLAGS} ${CHECK_DIRS}
SEC_RETURN_CODE=$?
echo === Finished

# Report output.
fail_checks=0
[ "${FMT_RETURN_CODE}" != "0" ] && echo "Formatting checks failed! => Run 'make format'." && fail_checks=1
[ "${VET_RETURN_CODE}" != "0" ] && echo "Vetting checks failed!" && fail_checks=1
[ "${LINT_RETURN_CODE}" != "0" ] && echo "Linting checks failed!" && fail_checks=1
[ "${SEC_RETURN_CODE}" != "0" ] && echo "Security checks failed!" && fail_checks=1

exit ${fail_checks}

0 comments on commit 2326a90

Please sign in to comment.