diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 858d65c..876765d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,13 +6,19 @@ updates: schedule: interval: "daily" open-pull-requests-limit: 10 + reviewers: + - "onmetal/csi-maintainers" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" open-pull-requests-limit: 10 + reviewers: + - "onmetal/csi-maintainers" - package-ecosystem: "docker" directory: "/" schedule: interval: "daily" open-pull-requests-limit: 10 + reviewers: + - "onmetal/csi-maintainers" diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml index a2e2731..2eaf87c 100644 --- a/.github/workflows/clean.yml +++ b/.github/workflows/clean.yml @@ -10,7 +10,7 @@ on: jobs: checks: name: run - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 diff --git a/.github/workflows/kustomize-validation.yml b/.github/workflows/kustomize-validation.yml index 2168edb..9b0a634 100644 --- a/.github/workflows/kustomize-validation.yml +++ b/.github/workflows/kustomize-validation.yml @@ -9,7 +9,7 @@ on: jobs: kustomize-validation: - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v3 diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 1191b7f..002ec7e 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -25,7 +25,7 @@ on: jobs: buildAndPush: if: ${{ github.event.label.name == 'ok-to-image' }} || ${{ github.event.label.name == 'ok-to-šŸ³' }} || ${{ github.ref == 'refs/heads/main' }} - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: docker/metadata-action@v4 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 37345c0..20de2f8 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -9,7 +9,7 @@ on: jobs: update_release_draft: - runs-on: self-hosted + runs-on: ubuntu-latest steps: # Drafts your next Release notes as Pull Requests are merged into "main" - uses: release-drafter/release-drafter@v5 diff --git a/.github/workflows/size-label.yml b/.github/workflows/size-label.yml index 0ecbca3..6dd157c 100644 --- a/.github/workflows/size-label.yml +++ b/.github/workflows/size-label.yml @@ -6,7 +6,7 @@ on: jobs: size-label: - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: size-label uses: pascalgn/size-label-action@v0.4.3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b525970..45bd0ec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ on: jobs: checks: name: run - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..d8755c8 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +# onmetal-csi-driver maintainers +* @onmetal/csi-maintainers diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..f6059eb --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +Please refer to the [Gardener on Metal code of conduct](https://onmetal.github.io/documentation/contribute/overview/#code-of-conduct). \ No newline at end of file diff --git a/README.md b/README.md index 298ddf0..38ec4ff 100755 --- a/README.md +++ b/README.md @@ -1,29 +1,29 @@ -![Gardener on Metal Logo](docs/assets/logo.png) - # onmetal-csi-driver - [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) +[![Test](https://github.com/onmetal/onmetal-csi-driver/actions/workflows/test.yml/badge.svg)](https://github.com/onmetal/onmetal-csi-driver/actions/workflows/test.yml) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com) [![GitHub License](https://img.shields.io/static/v1?label=License&message=Apache-2.0&color=blue&style=flat-square)](LICENSE) -> CSI driver for Gardener on Metal +CSI driver for Gardener on Metal ## Overview -The onmetal Container Storage Interface (CSI) driver is a [CSI specification-compliant](https://github.com/onmetal/onmetal-csi-driver/tree/main/docs) driver used by Gardener on Metal to manage the lifecycle of onmetal volumes. - -The CSI is a standard for exposing arbitrary block and file storage systems to containerized workloads on Kubernetes. +The onmetal Container Storage Interface (CSI) driver is a [CSI specification-compliant](https://github.com/onmetal/onmetal-csi-driver/tree/main/docs) +driver used by Gardener on Metal to manage the lifecycle of onmetal volumes. The CSI is a standard for exposing +arbitrary block and file storage systems to containerized workloads on Kubernetes. -This driver provides CSI implementation for Gardener on Metal. For any Persistent volume (PVC) created using this driver, it will create a new onmetal volume and mount the relevant disks to machine(s) (VMs). +This driver provides CSI implementation for Gardener on Metal. For any Persistent volume (PVC) created using this +driver, it will create a new onmetal volume and mount the relevant disks to machine(s) (VMs). ## Installation, Usage, and Development For more details please refer to documentation folder [/docs](https://github.com/onmetal/onmetal-csi-driver/tree/main/docs) -## Contributing +## Feedback and Support -We'd love to get feedback from you. -Please report bugs, suggestions or post questions by opening a [Github issue](https://github.com/onmetal/onmetal-csi-driver/issues) +Feedback and contributions are always welcome! +Please report bugs, suggestions or post questions by opening a [Github issue](https://github.com/onmetal/onmetal-csi-driver/issues). ## License [Apache License 2.0](/LICENSE) diff --git a/code_of_conduct.md b/code_of_conduct.md deleted file mode 100755 index a248a0d..0000000 --- a/code_of_conduct.md +++ /dev/null @@ -1,33 +0,0 @@ -# Code of conduct -This document provides community guidelines for a safe, respectful, productive, and collaborative place for any person who is willing to contribute to Gardener on metal project. - -This Code of Conduct is adapted from the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md) - -## Our Pledge - -We as members of the `Gardener on Metal` project, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -## Our Standards - -### Examples of behavior that contributes to a positive environment for our community include: - -- Demonstrating empathy and kindness toward other people -- Being respectful of differing opinions, viewpoints, and experiences -- Giving and gracefully accepting constructive feedback -- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -- Focusing on what is best not just for us as individuals, but for the overall community - -### Examples of unacceptable behavior include: - -- The use of sexualized language or imagery, and sexual attention or advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, without their explicit permission -- Other conduct which could reasonably be considered inappropriate in a professional setting - -## Contributing -Gardener on Metal uses GitHub to manage reviews of pull requests. - -Please, refer to [Contributors Guide](https://github.com/onmetal/onmetal-csi-driver/blob/main/docs/development/contribution.md) to find out detailed information. \ No newline at end of file diff --git a/docs/assets/logo.png b/docs/assets/logo.png deleted file mode 100644 index a845665..0000000 Binary files a/docs/assets/logo.png and /dev/null differ diff --git a/docs/development/contribution.md b/docs/development/contribution.md deleted file mode 100644 index b0bb7f5..0000000 --- a/docs/development/contribution.md +++ /dev/null @@ -1,107 +0,0 @@ -# Contributors Guide - -## Contributing - -The Gardener on Metal project uses Github to manage reviews of pull requests. - -* If you are looking to make your first contribution, follow [Steps to Contribute](#steps-to-contribute) - -* If you have a trivial fix or improvement, go ahead and create a pull request and address (with @...) a suitable maintainer of this repository in the description of the pull request. - -* If you plan to do something more involved, first discuss your ideas by creating an -[issue](https://github.com/onmetal/onmetal-csi-driver/issues) for this repository. This will avoid unnecessary work and surely give you and us a good deal of inspiration. - -> Please follow these style guidelines to have your contribution considered by the maintainers: -Coding style guidelines [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments), -Formatting and style section of Peter Bourgonā€™s [Go: Best Practices for Production Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style). - -## Steps to Contribute - -Do you want to work on an issue? You are welcome to claim an existing one by commenting on it in GitHub. - -> Perform a cursory search to see if the issue has already been taken by someone else. -This will prevent misunderstanding and duplication of effort from contributors on the same issue. - -If you have questions about one of the issues please comment on them and one of the -maintainers will clarify it. - -We kindly ask you to follow the [Pull Request Checklist](#pull-request-checklist) to ensure reviews can happen accordingly. - -## Contributing Code - -You are welcome to contribute code to the Gardener on Metal project in order to fix a bug or to implement a new feature. - -The following rules govern code contributions: - -* Contributions must be licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) -* You need to sign the [Developer Certificate of Origin](#developer-certificate-of-origin). - -## Contributing Documentation - -You are welcome to contribute documentation to the Gardener on Metal project. - -The following rules govern documentation contributions: - -* Contributions must be licensed under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/legalcode) -* You need to sign the [Developer Certificate of Origin](#developer-certificate-of-origin). - -## Developer Certificate of Origin - -Due to legal reasons, contributors will be asked to accept a Developer Certificate of Origin (DCO) before they submit -the first pull request to the Gardener on Metal project, this happens in an automated fashion during the submission -process. We use [the standard DCO text of the Linux Foundation](https://developercertificate.org/). - -## Pull Request Checklist - -* Fork and clone the repository to you local machine. - -```shell -git clone git@github.com:onmetal/onmetal-csi-driver.git -cd onmetal-csi-driver -``` - -* Create a branch from the `main` using 'git checkout' command. - -> If needed, rebase to the current `main` branch before submitting your pull request. If it doesn't merge properly - with `main` you may be asked to rebase your changes. - - ```shell - git checkout -b my_feature - # rebase if necessary - git fetch upstream main - git rebase upstream/main - ``` - -* Commits should be as small as possible, while ensuring that each commit is correct independently -(i.e. each commit should compile and pass tests). - -* Create your patch and test your changes before you commit them. Automated test by unit / integration tests are preferred. -If tested manually, provide information about the test scope in the PR description. Now you can commit -your changes to your feature branch and push it to your fork. - -```shell -git add . -git commit -m "Something meaningful" -git push origin my_feature -``` - -> Alternatively you can amend your commit before pushing if you forgot something by using `git commit --amend` - -* Create _Work In Progress [WIP]_ pull requests only if you need a clarification or an explicit review before you can -continue your work item. - -* If your patch is not getting reviewed, or you need a specific person to review it, you can @-reply a reviewer asking -for a review in the pull request or a comment. - -* Post review: - * If a reviewer requires you to change your commit(s), please test the changes again. - * Amend the affected commit(s) and force push onto your branch. - * Set respective comments in your GitHub review as resolved. - * Create a general PR comment to notify the reviewers that your amendments are ready for another round of review. - -## Issues and Planning - -We use GitHub issues to track bugs and enhancement requests. Please provide as much context as possible when you open an issue. The information you provide must be comprehensive enough to understand, reproduce the behavior and find related reports of that issue for the assignee. -Therefore, contributors may use but aren't restricted to the issue template provided by the Gardener on Metal maintainers. - -Issues and pull requests are tracked in the [backlog](https://github.com/onmetal/onmetal-csi-driver/projects) for this project. \ No newline at end of file diff --git a/docs/troubleshooting/troubleshooting.md b/docs/troubleshooting/troubleshooting.md index cd91017..054b136 100644 --- a/docs/troubleshooting/troubleshooting.md +++ b/docs/troubleshooting/troubleshooting.md @@ -12,7 +12,7 @@ ``` Example: ``` - rohit@ubuntu:~/gitrepo/onmetal$ kubectl --kubeconfig=/home/rohit/.kube/config get nodes + kubectl --kubeconfig=/home//.kube/config get nodes NAME STATUS ROLES AGE VERSION csi-master Ready master 106m v1.18.1 @@ -23,7 +23,7 @@ ``` Example: ``` - root@csi-master:~# kubectl get node csi-worker -o yaml | grep -i spec -A 3 + kubectl get node csi-worker -o yaml | grep -i spec -A 3 spec: providerID: onmetal://csi/csi-worker status: @@ -36,7 +36,7 @@ 4. Check CSI driver is deployed and Running ```bash - root@node1:~# kubectl get pods -n onmetal-csi + kubectl get pods -n onmetal-csi NAME READY STATUS RESTARTS AGE onmetal-csi-driver-0 5/5 Running 0 51s onmetal-csi-node-mkfs9 2/2 Running 0 29s @@ -49,7 +49,7 @@ failed pvc request status: ```bash - root@node1:~# kubectl get pvc -n onmetal-csi + kubectl get pvc -n onmetal-csi NAMESPACE NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE csi-test pvc-demo Pending onmetal-storageclass-demo 2s ``` @@ -62,13 +62,13 @@ ``` Ideal onmetal volume: ```bash - root@node1:~# kubectl get volume -n onmetal-csi + kubectl get volume -n onmetal-csi NAMESPACE NAME VOLUMEPOOLREF VOLUMECLASS STATE PHASE AGE onmetal-csi volume-sample volumepool-sample fast Available Bound 8m43s ``` Ideal pvc status: ```bash - root@node1:~# kubectl get pvc -n onmetal-csi + kubectl get pvc -n onmetal-csi NAMESPACE NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE onmetal-csi pvc-demo Bound csi-onmetal-44eb33bc46 1Gi RWO onmetal-storageclass-demo 9s ``` @@ -78,7 +78,7 @@ Example error: ```bash - root@node1:~# kubectl logs -f onmetal-csi-driver-0 -c driver -n onmetal-csi + kubectl logs -f onmetal-csi-driver-0 -c driver -n onmetal-csi time="2022-05-31T06:41:15Z" level=info msg="request received to publish volume csi-onmetal-44eb33bc46 at node 192.168.0.108\n" time="2022-05-31T06:41:15Z" level=info msg="get machine with provided name and namespace" time="2022-05-31T06:41:15Z" level=error msg="could not get machine with name node1,namespace onmetal-csi, error:machines.compute.api.onmetal.de \"node1\" not found" @@ -95,14 +95,14 @@ Example error: ```bash - root@node1:~# kubectl logs -f onmetal-csi-driver-0 -c driver -n onmetal-csi + kubectl logs -f onmetal-csi-driver-0 -c driver -n onmetal-csi time="2022-05-31T06:41:15Z" level=info msg="request received to publish volume csi-onmetal-44eb33bc46 at node 192.168.0.108\n" time="2022-05-31T06:41:15Z" level=info msg="get machine with provided name and namespace" time="2022-05-31T06:41:15Z" level=error msg="could not get machine with name node1,namespace onmetal-csi, error:machines.compute.api.onmetal.de \"node1\" not found" ``` 3. Check whether the disk to mount is available with volume. ```bash - root@node1:~# kubectl logs -f onmetal-csi-driver-0 -c driver -n onmetal-csi + kubectl logs -f onmetal-csi-driver-0 -c driver -n onmetal-csi time="2022-05-31T06:51:40Z" level=info msg="request received to publish volume csi-onmetal-4c50e230e1 at node 192.168.0.108\n" time="2022-05-31T06:51:40Z" level=info msg="get machine with provided name and namespace" time="2022-05-31T06:51:40Z" level=info msg="update machine with volumeattachment" @@ -112,31 +112,30 @@ ``` 4. Check disk to mount is available at /dev/disks/by-id directory. - Look for the disk by manually entering into the machine at below path `/dev/disk/by-id/` - + Example disk-path format: `/dev/disk/by-id/virtio-odc-e50014ee2b3f4627a` Example error: ```bash - root@node1:~# kubectl logs -f onmetal-csi-node-n9gjf -c driver -n onmetal-csi + kubectl logs -f onmetal-csi-node-n9gjf -c driver -n onmetal-csi time="2022-05-31T06:35:13Z" level=error msg="failed to stage volume:format of disk \"/host/dev/disk/by-id/virtio-odc-e50014ee2b3f4627a\" failed: type:(\"ext4\") target:(\"/var/lib/kubelet/plugins/kubernetes.io/csi/onmetal-csi-driver/b6fef28a18a856aa16c7a1201db104c250b95a02e4ec959377f589a096655b4e/globalmount\") options:(\"rw,defaults\") errcode:(exit status 1) output:(mke2fs 1.44.5 (15-Dec-2018)\nThe file /host/dev/disk/by-id/virtio-odc-e50014ee2b3f4627a does not exist and no size was specified.\n) " ``` Ideal onmetal machine: ```bash - root@node1:~# kubectl get machine -n onmetal-csi + kubectl get machine -n onmetal-csi NAME MACHINECLASSREF IMAGE MACHINEPOOLREF STATE AGE node1 machineclass-sample myimage_repo_location machinepool-sample Running 9m28s ``` Ideal onmetal volume: ```bash - root@node1:~# kubectl get volume -n onmetal-csi + kubectl get volume -n onmetal-csi NAMESPACE NAME VOLUMEPOOLREF VOLUMECLASS STATE PHASE AGE onmetal-csi volume-sample volumepool-sample fast Available Bound 24s ``` Volume status with disk available (Wwn): ```bash - root@node1:~# kubectl describe volume volume-sample -n onmetal-csi + kubectl describe volume volume-sample -n onmetal-csi Name: volume-sample Namespace: onmetal-csi ... @@ -152,12 +151,12 @@ ``` Create pod to mount volume: ```bash - root@node1:~# kubectl apply -f onmetal-csi-driver/config/samples/pod.yaml -n onmetal-csi + kubectl apply -f onmetal-csi-driver/config/samples/pod.yaml -n onmetal-csi pod/pod-demo created ``` ```bash - root@node1:~# kubectl get pods pod-demo -n onmetal-csi + kubectl get pods pod-demo -n onmetal-csi NAME READY STATUS RESTARTS AGE pod-demo 1/1 Running 0 4m57s ``` diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index eb46d60..6a6321e 100755 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -93,10 +93,10 @@ func NodeGetZone(ctx context.Context, nodeName string, t client.Client) (string, return zone, nil } -func NodeGetProviderID(ctx context.Context, nodeName string, t client.Client) (string, error) { +func NodeGetProviderID(ctx context.Context, nodeName string, c client.Client) (string, error) { node := &corev1.Node{} nodeKey := client.ObjectKey{Name: nodeName} - if err := t.Get(ctx, nodeKey, node); err != nil { + if err := c.Get(ctx, nodeKey, node); err != nil { return "", fmt.Errorf("could not get node %s: %w", nodeName, err) }