Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync from main #1253

Merged
merged 17 commits into from
Jul 19, 2023
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
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