Skip to content

Commit

Permalink
ci: add linters in zuul CI (#419)
Browse files Browse the repository at this point in the history
* fix: upgrade isort version

fix #418

* add linters in zuul ci

* remove lint jobs from gh action

* add linter job in project check

* exclude charts

---------

Co-authored-by: okozachenko1203 <[email protected]>
  • Loading branch information
okozachenko1203 and okozachenko1203 committed Aug 5, 2024
1 parent 96d4f3a commit 72aaa6c
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 101 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,3 @@ jobs:

- name: Install package using constraints
run: pip install --constraint https://releases.openstack.org/constraints/upper/${{ matrix.openstack-version }} ./dist/*.whl

black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable

flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pipx install flake8
- uses: suo/flake8-github-action@releases/v1
with:
checkName: flake8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: isort/isort-action@master
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
__pycache__
dist
magnum_cluster_api/charts/vendor/*
site
site
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
exclude: ^magnum_cluster_api/charts/

repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.0.0
Expand All @@ -7,7 +9,7 @@ repos:
- commit-msg

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 24.8.0
hooks:
- id: black

Expand All @@ -17,7 +19,7 @@ repos:
- id: flake8

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort

Expand Down
2 changes: 1 addition & 1 deletion docs/admin/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ state, you can follow the steps below to troubleshoot the issue:
```

!!! note

If the cluster exists and it is in `Provisioned` state, you can skip to
step 3.

Expand Down
2 changes: 1 addition & 1 deletion docs/developer/cluster-topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ In order to do this, the driver creates a [`ClusterClass`](https://cluster-api.s

It's important to note that there are only _one_ scenarios where the `spec.topology.class` for a given `Cluster` will be modified and this will be when a cluster upgrade is done. This is because there is an expectation by the user that a rolling restart operation will occur if a cluster upgrade is requested. No other action should be allowed to change the `spec.topology.class` of a `Cluster`.

For users, it's important to keep in mind that if they want to use a newer `ClusterClass` in order to make sure of a new feature available in a newer `ClusterClass`, they can simply do an upgrade within Magnum to the same cluster template and it will actually force an update of the `spec.topology.class`, which might then naturally cause a full rollout to occur.
For users, it's important to keep in mind that if they want to use a newer `ClusterClass` in order to make sure of a new feature available in a newer `ClusterClass`, they can simply do an upgrade within Magnum to the same cluster template and it will actually force an update of the `spec.topology.class`, which might then naturally cause a full rollout to occur.
20 changes: 10 additions & 10 deletions docs/user/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ dashboard, Terraform, Ansible or the Magnum API directly.
to launch a cluster, the first of which are related to it's basic
configuration, the required fields are:

* **Cluster Name**
* **Cluster Name**
The name of the cluster that will be created.

* **Cluster Template**
* **Cluster Template**
The cluster template that will be used to create the cluster.

* **Keypair**
* **Keypair**
The SSH key pair that will be used to access the cluster.

In this example, we're going to create a cluster with the name of
Expand All @@ -116,22 +116,22 @@ dashboard, Terraform, Ansible or the Magnum API directly.
The next step is deciding on the size of the cluster and selecting if auto
scaling will be enabled for the cluster. The required fields are:

* **Number of Master Nodes**
* **Number of Master Nodes**
The number of master nodes that will be created in the cluster.

* **Flavor of Master Nodes**
* **Flavor of Master Nodes**
The flavor of the master nodes that will be created in the cluster.

* **Number of Worker Nodes**
* **Number of Worker Nodes**
The number of worker nodes that will be created in the cluster.

* **Flavor of Worker Nodes**
* **Flavor of Worker Nodes**
The flavor of the worker nodes that will be created in the cluster.

In addition, if you want to enable auto scaling, you will need to provide the
following information:

* **Auto-scale Worker Nodes**
* **Auto-scale Worker Nodes**
Whether or not to enable auto scaling for the worker nodes.

* **Minimum Number of Worker Nodes**
Expand Down Expand Up @@ -164,7 +164,7 @@ dashboard, Terraform, Ansible or the Magnum API directly.
if you want to attach the cluster to an existing network with other
resources.

* **Cluster API**
* **Cluster API**
This setting controls if the API will get a floating IP address assigned
to it. You can set this to _Accessible on private network only_ if you
are using an existing network and don't want to expose the API to the
Expand All @@ -181,7 +181,7 @@ dashboard, Terraform, Ansible or the Magnum API directly.
the cluster which automatically detects nodes that are unhealthy and
replaces them with new nodes. The required fields are:

* **Automatically Repair Unhealthy Nodes**
* **Automatically Repair Unhealthy Nodes**
Whether or not to enable auto-healing for the cluster.

In this example, we're going to enable auto-healing for the cluster since it
Expand Down
2 changes: 1 addition & 1 deletion docs/user/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ all necessary dependencies for deploying Kubernetes clusters. These images are
pre-configured with Kubernetes binaries, container runtimes, networking
components, and other required software.

The images used by the Cluster API driver for Magnum are built using the
The images used by the Cluster API driver for Magnum are built using the
[`kubernetes-sigs/image-builder`](https://github.com/kubernetes-sigs/image-builder)
project. This project provides a comprehensive and flexible framework for
constructing Kubernetes-specific images.
Expand Down
2 changes: 1 addition & 1 deletion docs/user/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ specify the volume size and type using the following labels:
`boot_volume_type`

: The volume type of the boot volume.
**Default value**: Default volume
**Default value**: Default volume

`etcd_volume_size`

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "magnum-cluster-api"
name = "magnum-cluster-api"
version = "0.21.2"
description = "Cluster API driver for Magnum"
authors = ["Mohammed Naser <[email protected]>"]
Expand Down
28 changes: 16 additions & 12 deletions tools/sync-ccm-manifests
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,22 @@ for manifest in MANIFESTS:
del doc["spec"]["template"]["spec"]["volumes"][2]["secret"]

# NOTE(okozachenko1203): Add `/etc/kuberentes/cloud_ca.crt`.
doc["spec"]["template"]["spec"]["containers"][0]["volumeMounts"].append({
"name": "cloud-ca-cert-volume",
"readOnly": True,
"mountPath": "/etc/config/ca.crt",
})
doc["spec"]["template"]["spec"]["volumes"].append({
"name": "cloud-ca-cert-volume",
"hostPath": {
"type": "File",
"path": "/etc/kubernetes/cloud_ca.crt",
},
})
doc["spec"]["template"]["spec"]["containers"][0]["volumeMounts"].append(
{
"name": "cloud-ca-cert-volume",
"readOnly": True,
"mountPath": "/etc/config/ca.crt",
}
)
doc["spec"]["template"]["spec"]["volumes"].append(
{
"name": "cloud-ca-cert-volume",
"hostPath": {
"type": "File",
"path": "/etc/kubernetes/cloud_ca.crt",
},
}
)

# NOTE(mnaser): We need to run as root in order to read the `cloud.conf`
# file from the host.
Expand Down
56 changes: 32 additions & 24 deletions tools/sync-cinder-csi-manifests
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,22 @@ for manifest in MANIFESTS:
del doc["spec"]["template"]["spec"]["volumes"][1]["secret"]

# NOTE(okozachenko1203): Add `/etc/kuberentes/cloud_ca.crt`.
doc["spec"]["template"]["spec"]["containers"][5]["volumeMounts"].append({
"name": "cloud-ca-cert-volume",
"readOnly": True,
"mountPath": "/etc/config/ca.crt",
})
doc["spec"]["template"]["spec"]["volumes"].append({
"name": "cloud-ca-cert-volume",
"hostPath": {
"type": "File",
"path": "/etc/kubernetes/cloud_ca.crt",
},
})
doc["spec"]["template"]["spec"]["containers"][5]["volumeMounts"].append(
{
"name": "cloud-ca-cert-volume",
"readOnly": True,
"mountPath": "/etc/config/ca.crt",
}
)
doc["spec"]["template"]["spec"]["volumes"].append(
{
"name": "cloud-ca-cert-volume",
"hostPath": {
"type": "File",
"path": "/etc/kubernetes/cloud_ca.crt",
},
}
)

# NOTE(mnaser): We need to run as root in order to read the `cloud.conf`
# file from the host.
Expand All @@ -85,18 +89,22 @@ for manifest in MANIFESTS:
del doc["spec"]["template"]["spec"]["volumes"][4]["secret"]

# NOTE(okozachenko1203): Add `/etc/kuberentes/cloud_ca.crt`.
doc["spec"]["template"]["spec"]["containers"][2]["volumeMounts"].append({
"name": "cloud-ca-cert-volume",
"readOnly": True,
"mountPath": "/etc/config/ca.crt",
})
doc["spec"]["template"]["spec"]["volumes"].append({
"name": "cloud-ca-cert-volume",
"hostPath": {
"type": "File",
"path": "/etc/kubernetes/cloud_ca.crt",
},
})
doc["spec"]["template"]["spec"]["containers"][2]["volumeMounts"].append(
{
"name": "cloud-ca-cert-volume",
"readOnly": True,
"mountPath": "/etc/config/ca.crt",
}
)
doc["spec"]["template"]["spec"]["volumes"].append(
{
"name": "cloud-ca-cert-volume",
"hostPath": {
"type": "File",
"path": "/etc/kubernetes/cloud_ca.crt",
},
}
)

# NOTE(mnaser): We need to run as root in order to read the `cloud.conf`
# file from the host.
Expand Down
52 changes: 34 additions & 18 deletions tools/sync-manila-csi-manifests
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,49 @@ for manifest in MANIFESTS:
"value"
] = "unix:///var/lib/kubelet/plugins/csi-nfsplugin/csi.sock"
doc["spec"]["template"]["spec"]["containers"][3]["env"][4]["value"] = "NFS"
doc["spec"]["template"]["spec"]["containers"][3]["image"] = "registry.k8s.io/provider-os/manila-csi-plugin:latest"
doc["spec"]["template"]["spec"]["containers"][3]["volumeMounts"][1]["mountPath"] = "/var/lib/kubelet/plugins/csi-nfsplugin"
doc["spec"]["template"]["spec"]["volumes"][1]["hostPath"]["path"] = "/var/lib/kubelet/plugins/csi-nfsplugin"
doc["spec"]["template"]["spec"]["containers"][3][
"image"
] = "registry.k8s.io/provider-os/manila-csi-plugin:latest"
doc["spec"]["template"]["spec"]["containers"][3]["volumeMounts"][1][
"mountPath"
] = "/var/lib/kubelet/plugins/csi-nfsplugin"
doc["spec"]["template"]["spec"]["volumes"][1]["hostPath"][
"path"
] = "/var/lib/kubelet/plugins/csi-nfsplugin"

# NOTE(okozachenko1203): Add `/etc/kuberentes/cloud_ca.crt`.
doc["spec"]["template"]["spec"]["containers"][3]["volumeMounts"].append({
"name": "cloud-ca-cert-volume",
"readOnly": True,
"mountPath": "/etc/config/ca.crt",
})
doc["spec"]["template"]["spec"]["volumes"].append({
"name": "cloud-ca-cert-volume",
"hostPath": {
"type": "File",
"path": "/etc/kubernetes/cloud_ca.crt",
},
})
doc["spec"]["template"]["spec"]["containers"][3]["volumeMounts"].append(
{
"name": "cloud-ca-cert-volume",
"readOnly": True,
"mountPath": "/etc/config/ca.crt",
}
)
doc["spec"]["template"]["spec"]["volumes"].append(
{
"name": "cloud-ca-cert-volume",
"hostPath": {
"type": "File",
"path": "/etc/kubernetes/cloud_ca.crt",
},
}
)

if doc["kind"] == "DaemonSet":
doc["spec"]["template"]["spec"]["containers"][1]["env"][3][
"value"
] = "unix:///var/lib/kubelet/plugins/csi-nfsplugin/csi.sock"
doc["spec"]["template"]["spec"]["containers"][1]["env"][4]["value"] = "NFS"
doc["spec"]["template"]["spec"]["containers"][1]["image"] = "registry.k8s.io/provider-os/manila-csi-plugin:latest"
doc["spec"]["template"]["spec"]["containers"][1][
"image"
] = "registry.k8s.io/provider-os/manila-csi-plugin:latest"
# Set FWD plugin
doc["spec"]["template"]["spec"]["containers"][1]["volumeMounts"][1]["mountPath"] = "/var/lib/kubelet/plugins/csi-nfsplugin"
doc["spec"]["template"]["spec"]["volumes"][2]["hostPath"]["path"] = "/var/lib/kubelet/plugins/csi-nfsplugin"
doc["spec"]["template"]["spec"]["containers"][1]["volumeMounts"][1][
"mountPath"
] = "/var/lib/kubelet/plugins/csi-nfsplugin"
doc["spec"]["template"]["spec"]["volumes"][2]["hostPath"][
"path"
] = "/var/lib/kubelet/plugins/csi-nfsplugin"
# Set toleration
doc["spec"]["template"]["spec"]["tolerations"] = [{"operator": "Exists"}]

Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ commands =
[testenv:functional]
commands =
pytest magnum_cluster_api/tests/functional/

[testenv:linters]
skipsdist = True
deps =
pre-commit
commands =
pre-commit run --all-files --show-diff-on-failure
4 changes: 4 additions & 0 deletions zuul.d/jobs.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- job:
name: magnum-cluster-api-linters
parent: tox-linters

- job:
name: magnum-cluster-api-unit
parent: tox
Expand Down
1 change: 1 addition & 0 deletions zuul.d/project.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- project:
check:
jobs:
- magnum-cluster-api-linters
- magnum-cluster-api-unit
- magnum-cluster-api-functional
templates:
Expand Down

0 comments on commit 72aaa6c

Please sign in to comment.