Skip to content
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: 2 additions & 2 deletions .github/workflows/codespell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:
jobs:
codespell:
name: codespell
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
Expand All @@ -27,7 +27,7 @@ jobs:
check_hidden: true
misspell:
name: misspell
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/collect-logs/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Collect Logs'
description: 'Collect cluster logs for debugging'
inputs:
name:
description: 'Name identifier for the log collection'
required: true

runs:
using: 'composite'
steps:
- name: Collect cluster logs
if: always()
shell: bash
run: |
echo "=== Collecting logs for ${{ inputs.name }} ==="
echo ""

echo "=== Kubernetes resources in openshift-storage namespace ==="
kubectl get all -n openshift-storage -o wide || true
echo ""

echo "=== CephCluster status ==="
kubectl get cephcluster -n openshift-storage -o yaml || true
echo ""

echo "=== Rook Operator logs ==="
kubectl logs -n openshift-storage -l app=rook-ceph-operator --tail=500 || true
echo ""

echo "=== Ceph Mon logs ==="
kubectl logs -n openshift-storage -l app=rook-ceph-mon --tail=500 || true
echo ""

echo "=== Ceph OSD logs ==="
kubectl logs -n openshift-storage -l app=rook-ceph-osd --tail=500 || true
echo ""

echo "=== Ceph MGR logs ==="
kubectl logs -n openshift-storage -l app=rook-ceph-mgr --tail=500 || true
echo ""

echo "=== Done collecting logs for ${{ inputs.name }} ==="
92 changes: 92 additions & 0 deletions .github/workflows/go-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Go Test
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This matches the go test job but this workflow also have slow e2e tests creating minikube cluster and running the tool. Maybe split them to another workflow?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand but we need the minikube cluster to test the tool, right?


on:
pull_request:
push:

defaults:
run:
# reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
shell: bash --noprofile --norc -eo pipefail -x {0}

# cancel the in-progress workflow when PR is refreshed.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
ODF_SKIP_PROMPTS: true
steps:
- name: checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Install cri-dockerd
run: |
curl -LO https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.21/cri-dockerd_0.3.21.3-0.ubuntu-focal_amd64.deb
sudo dpkg -i cri-dockerd_0.3.21.3-0.ubuntu-focal_amd64.deb
rm -f cri-dockerd_0.3.21.3-0.ubuntu-focal_amd64.deb

- name: Setup Minikube
uses: medyagh/setup-minikube@latest
with:
minikube-version: "1.37.0"
kubernetes-version: v1.35.0
driver: none
container-runtime: docker
memory: 6g
cpus: 2
addons: ingress
cni: calico

- name: Wait for cluster ready
shell: bash
run: |
kubectl wait --for=condition=Ready nodes --all --timeout=300s
kubectl get nodes -o wide
kubectl cluster-info

- name: use local disk
run: tests/github-action-helper.sh use_local_disk

- name: deploy rook cluster
run: tests/github-action-helper.sh deploy_rook openshift-storage openshift-storage

- name: Build odf-cli
shell: bash
run: make build

- name: Run unit tests
shell: bash
run: make test

- name: Test odf-cli commands
shell: bash
run: |
./bin/odf --help
./bin/odf get health
./bin/odf ceph status
./bin/odf get rook-status

- name: collect common logs
if: always()
uses: ./.github/workflows/collect-logs
with:
name: go-test

- name: consider debugging
if: failure()
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: false
31 changes: 31 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: golangci-lint
on:
push:
pull_request:

# cancel the in-progress workflow when PR is refreshed.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

permissions:
contents: read

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: go.mod
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
version: v2.8.0
# actions/setup-go already handles caching
skip-cache: true
63 changes: 0 additions & 63 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,66 +1,3 @@
# Created by https://www.gitignore.io/api/go,vim,visualstudiocode
# Edit at https://www.gitignore.io/?templates=go,vim,visualstudiocode

### Go ###
# Binaries for programs and plugins
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out


### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
.history

### IntelliJ ###
.idea

# End of https://www.gitignore.io/api/go,vim,visualstudiocode
_output
_cache
bin

catalog/ocs-bundle.yaml
catalog/noobaa-bundle.yaml

tools/csv-merger/csv-merger
tools/csv-checksum/csv-checksum
tools/cluster-deploy/cluster-deploy
tools/shellcheck
metrics/mixin/build/vendor

# Ignore ticketgen output
hack/ticketgen/*.pem
hack/ticketgen/*.pub
hack/ticketgen/*.txt
40 changes: 40 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
version: "2"
linters:
default: none
enable:
- errcheck
- govet
- gosec
- ineffassign
- staticcheck
- unused
exclusions:
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- staticcheck
text: "QF1008:" # could remove embedded field "Connection" from selector (staticcheck)
- linters:
- staticcheck
text: "QF1007:" # could merge conditional assignment into variable declaration (staticcheck)
- linters:
- staticcheck
text: "QF1001:" # could apply De Morgan's law (staticcheck)
- linters:
- staticcheck
text: "QF1006:" # could lift into loop condition (staticcheck)
- linters:
- staticcheck
text: "Requeue is deprecated"
- linters:
- staticcheck
text: "Use aws-sdk-go-v2" # aws-sdk-go v1 deprecated warning
formatters:
enable:
- gofmt
- gofumpt
11 changes: 11 additions & 0 deletions .govulncheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Configuration for govulncheck
# This file allows us to exclude certain vulnerabilities that are not
# in the critical execution path of odf-cli

excludes:
# Submariner-related vulnerabilities in DR functionality
# These are not in the main execution path and are dependency issues
- "GO-2024-*" # Placeholder for submariner vulnerability IDs

# Alternative: we could also use build tags to exclude DR functionality
# during vulnerability scanning if needed
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build:
gofmt -w $(shell find . -type f -name '*.go')
@echo
env GOOS=$(shell go env GOOS) GOARCH=$(shell go env GOARCH) go build -o bin/odf cmd/odf/main.go
env GOOS=$(shell go env GOOS) GOARCH=$(shell go env GOARCH) go build -o bin/odf cmd/odf/main.go

clean:
@rm -f bin/odf
Expand All @@ -10,7 +10,7 @@ test:
@echo "running unit tests"
go test ./...

help :
help:
@echo "build : Create go binary."
@echo "test : Runs unit tests"
@echo "clean : Remove go binary file."
2 changes: 1 addition & 1 deletion cmd/odf/ceph/ceph.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var CephCmd = &cobra.Command{
// splitCephDaemonNameAndID splits the arg based on '.' so that we use it with label, example osd.0 to osd and 0
func splitCephDaemonNameAndID(args string) []string {
if !strings.Contains(args, ".") {
logging.Fatal(fmt.Errorf("Invalid argument to 'ceph daemon' command: %v. The arg should be in the format of '<daemon.id>'", args))
logging.Fatal(fmt.Errorf("invalid argument to 'ceph daemon' command: %v. The arg should be in the format of '<daemon.id>'", args))
}
return strings.Split(args, ".")
}
5 changes: 4 additions & 1 deletion cmd/odf/get/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/red-hat-storage/odf-cli/cmd/odf/root"
"github.com/rook/kubectl-rook-ceph/pkg/health"
"github.com/rook/kubectl-rook-ceph/pkg/k8sutil"
"github.com/rook/kubectl-rook-ceph/pkg/logging"
"github.com/spf13/cobra"
)

Expand All @@ -15,7 +16,9 @@ var clusterHealth = &cobra.Command{
Example: "odf get health",
PreRun: func(cmd *cobra.Command, args []string) {
// verify operator pod is running
k8sutil.WaitForPodToRun(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "app=rook-ceph-operator")
if _, err := k8sutil.WaitForPodToRun(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "app=rook-ceph-operator"); err != nil {
logging.Fatal(err)
}
},
Run: func(cmd *cobra.Command, _ []string) {
health.Health(cmd.Context(), root.ClientSets, root.OperatorNamespace, root.StorageClusterNamespace)
Expand Down
7 changes: 6 additions & 1 deletion cmd/odf/maintenance/maintenance.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package maintenance

import (
"fmt"
Comment thread
subhamkrai marked this conversation as resolved.

"github.com/red-hat-storage/odf-cli/cmd/odf/root"
"github.com/rook/kubectl-rook-ceph/pkg/k8sutil"
"github.com/rook/kubectl-rook-ceph/pkg/logging"
"github.com/spf13/cobra"
)

Expand All @@ -14,7 +17,9 @@ var MaintenanceCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
// verify operator pod is running
k8sutil.WaitForPodToRun(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "app=rook-ceph-operator")
if _, err := k8sutil.WaitForPodToRun(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "app=rook-ceph-operator"); err != nil {
logging.Fatal(fmt.Errorf("failed to wait for rook-ceph-operator pod: %v", err))
}
},
}

Expand Down
7 changes: 6 additions & 1 deletion cmd/odf/operator/rook/restart.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package rook

import (
"fmt"

"github.com/red-hat-storage/odf-cli/cmd/odf/root"
"github.com/rook/kubectl-rook-ceph/pkg/k8sutil"
"github.com/rook/kubectl-rook-ceph/pkg/logging"
"github.com/spf13/cobra"
)

Expand All @@ -13,7 +16,9 @@ var restartCmd = &cobra.Command{
Example: "odf operator rook restart",
PreRun: func(cmd *cobra.Command, args []string) {
// verify operator pod is running
k8sutil.WaitForPodToRun(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "app=rook-ceph-operator")
if _, err := k8sutil.WaitForPodToRun(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "app=rook-ceph-operator"); err != nil {
logging.Fatal(fmt.Errorf("failed to wait for rook-ceph-operator pod: %v", err))
}
},
Run: func(cmd *cobra.Command, _ []string) {
k8sutil.RestartDeployment(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "rook-ceph-operator")
Expand Down
Loading