Skip to content

Commit

Permalink
Sync from main (#1253)
Browse files Browse the repository at this point in the history
* add v4.14 to renovate.json

* Exapnd MachineConfigPool for creation (#1204)

* Exapnd MachineConfigPool for creation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* ICSP: set repository_digest_mirrors to None (#1231)

* Add close-stale-issues workflow

* [pre-commit.ci] pre-commit autoupdate (#1239)

updates:
- [github.com/hadialqattan/pycln: v2.1.3 → v2.1.5](hadialqattan/pycln@v2.1.3...v2.1.5)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* rmemove pre-commit-hooks

* remove ruff from pre-commit

* Update OWNERS (#1241)

* adding omrirh to owners

* Update OWNERS

Co-authored-by: oharan2 <[email protected]>

---------

Co-authored-by: Meni Yakove <[email protected]>
Co-authored-by: oharan2 <[email protected]>

* StorageClass - add support for resource creation (#1246)

* Update StorageClass class

* fix per review

* fix per review

* wait_for_condition: use sampler, not watcher (#1248)

* wait_for_condition: use sampler, not watcher

* wait_for_condition: use sampler, not watcher

* [pre-commit.ci] pre-commit autoupdate (#1245)

updates:
- [github.com/PyCQA/autoflake: v2.1.1 → v2.2.0](PyCQA/autoflake@v2.1.1...v2.2.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* disable stale.yml

* Update close-stale-issues.yml

* [pre-commit.ci] pre-commit autoupdate (#1252)

updates:
- [github.com/psf/black: 23.3.0 → 23.7.0](psf/black@23.3.0...23.7.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

---------

Co-authored-by: Yossi Segev <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Omri Bar Haim <[email protected]>
Co-authored-by: oharan2 <[email protected]>
Co-authored-by: dalia-frank <[email protected]>
Co-authored-by: Ruth Netser <[email protected]>
  • Loading branch information
7 people authored Jul 19, 2023
1 parent a31a640 commit 4d8f146
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 20 deletions.
17 changes: 0 additions & 17 deletions .github/stale.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/close-stale-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
with:
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
days-before-stale: 60
days-before-close: 7
ignore-updates: true
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:

repos:
- repo: https://github.com/PyCQA/autoflake
rev: "v2.1.1"
rev: "v2.2.0"
hooks:
- id: autoflake
args:
Expand All @@ -12,7 +12,7 @@ repos:
- --remove-all-unused-imports

- repo: https://github.com/hadialqattan/pycln
rev: "v2.1.3"
rev: "v2.1.5"
hooks:
- id: pycln

Expand All @@ -22,7 +22,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: "23.3.0"
rev: "23.7.0"
hooks:
- id: black

Expand Down
2 changes: 2 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ approvers:
reviewers:
- myakove
- rnetser
- omrirh
- oharan2
71 changes: 71 additions & 0 deletions ocp_resources/machine_config_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,79 @@


class MachineConfigPool(Resource):
"""
MachineConfigPool object. API reference:
https://docs.openshift.com/container-platform/4.12/rest_api/machine_apis/machineconfigpool-machineconfiguration-openshift-io-v1.html
Args:
node_selector (dict): Matching dict with supported selector logic, either labels or expressions.
matchLabels example:
matchLabels:
component: <some component>
matchExpressions:
- { key: tier, operator: In, values: [cache] }
- { key: environment, operator: NotIn, values: [dev] }
matchExpressions example:
matchExpressions:
- key: <resource name>/role
operator: In
values:
- value_1
- value_2
machine_config_selector (dict): Matching labels/expressions, to determine which MachineConfig objects
to apply this MachineConfigPool object.
For filtering based on labels, the `matchLabels` dict is used - the same way as it is used in the
nodeSelector (see the example of node_selector["matchLabels"] above).
For filtering based on expressions, the `matchExpressions` dict is used - the same way as it is used in the
nodeSelector (see the example of node_selector["matchExpressions"] above).
configuration (dict): Targeted MachineConfig object for the machine config pool, in the following format:
{"name": (str), "source": <List of dicts, each representing a MachineConfig resource>}
max_unavailable (int or str): Number/percentage of nodes that can go Unavailable during an update.
paused (bool): Whether changes to this MachineConfigPool should be stopped.
"""

api_group = Resource.ApiGroup.MACHINECONFIGURATION_OPENSHIFT_IO

class Status(Resource.Status):
UPDATED = "Updated"
UPDATING = "Updating"

def __init__(
self,
machine_config_selector=None,
configuration=None,
node_selector=None,
max_unavailable=None,
paused=None,
**kwargs,
):
super().__init__(**kwargs)
self.configuration = configuration
self.machine_config_selector = machine_config_selector
self.node_selector = node_selector
self.max_unavailable = max_unavailable
self.paused = paused

def to_dict(self):
super().to_dict()
if not self.yaml_file:
self.res.update(
{
"spec": {
"configuration": self.configuration or {},
},
},
)

manifest_spec = self.res["spec"]
if self.machine_config_selector:
manifest_spec["machineConfigSelector"] = self.machine_config_selector

if self.node_selector:
manifest_spec["nodeSelector"] = self.node_selector

if self.max_unavailable:
manifest_spec["maxUnavailable"] = self.max_unavailable

if self.paused:
manifest_spec["paused"] = self.paused
58 changes: 58 additions & 0 deletions ocp_resources/storage_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,61 @@ class Annotations:
IS_DEFAULT_CLASS = (
f"{Resource.ApiGroup.STORAGECLASS_KUBERNETES_IO}/is-default-class"
)

class ReclaimPolicy:
DELETE = "Delete"
RETAIN = "Retain"

def __init__(
self,
provisioner=None,
reclaim_policy=None,
volume_binding_mode=None,
allow_volume_expansion=None,
parameters=None,
allowed_topologies=None,
mount_options=None,
**kwargs,
):
"""
StorageClass object
Args:
provisioner (str): The provisioner of the storage class
reclaim_policy (str): Can be either "Delete" or "Retain"
volume_binding_mode (str): When volume binding and dynamic provisioning should occur
allow_volume_expansion (bool): True for allowing the volume expansion
parameters (dict): Describe volumes belonging to the storage class.
allowed_topologies (list): Restrict provisioning to specific topologies
mount_options (list): PV's that are dynamically created by the SC will have the mount options
"""
super().__init__(
**kwargs,
)

self.provisioner = provisioner
self.reclaim_policy = reclaim_policy
self.volume_binding_mode = volume_binding_mode
self.allow_volume_expansion = allow_volume_expansion
self.parameters = parameters
self.allowed_topologies = allowed_topologies
self.mount_options = mount_options

def to_dict(self):
super().to_dict()
if not self.yaml_file:
if not self.provisioner:
raise ValueError("provisioner must be specified")
self.res.update({"provisioner": self.provisioner})
if self.reclaim_policy:
self.res.update({"reclaimPolicy": self.reclaim_policy})
if self.volume_binding_mode:
self.res.update({"volumeBindingMode": self.volume_binding_mode})
if self.allow_volume_expansion:
self.res.update({"allowVolumeExpansion": self.allow_volume_expansion})
if self.parameters:
self.res.update({"parameters": self.parameters})
if self.allowed_topologies:
self.res.update({"allowedTopologies": self.allowed_topologies})
if self.mount_options:
self.res.update({"mountOptions": self.mount_options})
1 change: 1 addition & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"baseBranches": [
"main",
"v4.14",
"v4.13",
"v4.12",
"v4.11",
Expand Down

0 comments on commit 4d8f146

Please sign in to comment.