Skip to content
Open
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
Binary file modified class_generator/schema/__resources-mappings.json.gz
Binary file not shown.
157 changes: 157 additions & 0 deletions ocp_resources/cluster_queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md


from typing import Any

from ocp_resources.resource import Resource


class ClusterQueue(Resource):
"""
ClusterQueue is the Schema for the clusterQueue API.
"""

api_group: str = Resource.ApiGroup.KUEUE_X_K8S_IO

def __init__(
self,
admission_checks: list[Any] | None = None,
admission_checks_strategy: dict[str, Any] | None = None,
admission_scope: dict[str, Any] | None = None,
cohort: str | None = None,
cohort_name: str | None = None,
fair_sharing: dict[str, Any] | None = None,
flavor_fungibility: dict[str, Any] | None = None,
namespace_selector: dict[str, Any] | None = None,
preemption: dict[str, Any] | None = None,
queueing_strategy: str | None = None,
resource_groups: list[Any] | None = None,
stop_policy: str | None = None,
**kwargs: Any,
) -> None:
r"""
Args:
admission_checks (list[Any]): admissionChecks lists the AdmissionChecks required by this
ClusterQueue. Cannot be used along with AdmissionCheckStrategy.
Available in kueue.x-k8s.io/v1beta1.

admission_checks_strategy (dict[str, Any]): admissionCheckStrategy defines a list of strategies to determine which
ResourceFlavors require AdmissionChecks.

admission_scope (dict[str, Any]): admissionScope indicates whether the ClusterQueue participates in
AdmissionFairSharing. Available in kueue.x-k8s.io/v1beta2+.

cohort (str): cohort that this ClusterQueue belongs to. CQs that belong to the same
cohort can borrow unused resources from each other.
Available in kueue.x-k8s.io/v1beta1.

cohort_name (str): cohortName that this ClusterQueue belongs to. CQs that belong to the
same cohort can borrow unused resources from each other. A CQ can
be a member of a single borrowing cohort. A workload submitted to
a queue referencing this CQ can borrow quota from any CQ in the
cohort. Only quota for the [resource, flavor] pairs listed in the
CQ can be borrowed. If empty, this ClusterQueue cannot borrow from
any other ClusterQueue and vice versa. A cohort is a name that
links CQs together, but it doesn't reference any object.
Available in kueue.x-k8s.io/v1beta2+.

fair_sharing (dict[str, Any]): fairSharing defines the properties of the ClusterQueue when
participating in FairSharing. The values are only relevant if
FairSharing is enabled in the Kueue configuration.

flavor_fungibility (dict[str, Any]): flavorFungibility defines whether a workload should try the next
flavor before borrowing or preempting in the flavor being
evaluated.

namespace_selector (dict[str, Any]): namespaceSelector defines which namespaces are allowed to submit
workloads to this clusterQueue. Beyond this basic support for
policy, a policy agent like Gatekeeper should be used to enforce
more advanced policies. Defaults to null which is a nothing
selector (no namespaces eligible). If set to an empty selector
`{}`, then all namespaces are eligible.

preemption (dict[str, Any]): preemption defines the preemption policies for the ClusterQueue.

queueing_strategy (str): QueueingStrategy indicates the queueing strategy of the workloads
across the queues in this ClusterQueue. Current Supported
Strategies: - StrictFIFO: workloads are ordered strictly by
creation time. Older workloads that can't be admitted will block
admitting newer workloads even if they fit available quota. -
BestEffortFIFO: workloads are ordered by creation time, however
older workloads that can't be admitted will not block admitting
newer workloads that fit existing quota.

resource_groups (list[Any]): resourceGroups describes groups of resources. Each resource group
defines the list of resources and a list of flavors that provide
quotas for these resources. Each resource and each flavor can only
form part of one resource group. resourceGroups can be up to 16.

stop_policy (str): stopPolicy - if set to a value different from None, the ClusterQueue
is considered Inactive, no new reservation being made. Depending
on its value, its associated workloads will: - None - Workloads
are admitted - HoldAndDrain - Admitted workloads are evicted and
Reserving workloads will cancel the reservation. - Hold - Admitted
workloads will run to completion and Reserving workloads will
cancel the reservation.

"""
super().__init__(**kwargs)

self.admission_checks = admission_checks
self.admission_checks_strategy = admission_checks_strategy
self.admission_scope = admission_scope
self.cohort = cohort
self.cohort_name = cohort_name
self.fair_sharing = fair_sharing
self.flavor_fungibility = flavor_fungibility
self.namespace_selector = namespace_selector
self.preemption = preemption
self.queueing_strategy = queueing_strategy
self.resource_groups = resource_groups
self.stop_policy = stop_policy

def to_dict(self) -> None:

super().to_dict()

if not self.kind_dict and not self.yaml_file:
self.res["spec"] = {}
_spec = self.res["spec"]

if self.admission_checks is not None:
_spec["admissionChecks"] = self.admission_checks

if self.admission_checks_strategy is not None:
_spec["admissionChecksStrategy"] = self.admission_checks_strategy
Comment on lines +122 to +125

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

4. Invalid clusterqueue spec combo 🐞 Bug ≡ Correctness

ClusterQueue.to_dict() can serialize both spec.admissionChecks and spec.admissionChecksStrategy when
both constructor args are provided, even though the API contract (documented in this class) says
they cannot be used together. This produces a manifest that violates the documented API constraints
and may fail server-side validation or behave unexpectedly.
Agent Prompt
### Issue description
`ClusterQueue` documents that `admissionChecks` cannot be used together with `admissionCheckStrategy`, but the wrapper currently allows both inputs and will emit both fields in `spec` when both are set.

### Issue Context
This is a newly added generated wrapper; adding a small guard is consistent with other resources in this repo that raise early (e.g., `MissingRequiredArgumentError`) when required/invalid combinations are detected.

### Fix Focus Areas
- ocp_resources/cluster_queue.py[16-36]
- ocp_resources/cluster_queue.py[113-126]

### Suggested fix
Add a guard in `__init__` or `to_dict` such as:

```python
if self.admission_checks is not None and self.admission_checks_strategy is not None:
    raise ValueError("admission_checks and admission_checks_strategy are mutually exclusive")
```

(Optionally use `MissingRequiredArgumentError` or a new dedicated exception if that’s preferred in this codebase.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this should be addressed already


if self.admission_scope is not None:
_spec["admissionScope"] = self.admission_scope

if self.cohort is not None:
_spec["cohort"] = self.cohort

if self.cohort_name is not None:
_spec["cohortName"] = self.cohort_name

if self.fair_sharing is not None:
_spec["fairSharing"] = self.fair_sharing

if self.flavor_fungibility is not None:
_spec["flavorFungibility"] = self.flavor_fungibility

if self.namespace_selector is not None:
_spec["namespaceSelector"] = self.namespace_selector

if self.preemption is not None:
_spec["preemption"] = self.preemption

if self.queueing_strategy is not None:
_spec["queueingStrategy"] = self.queueing_strategy

if self.resource_groups is not None:
_spec["resourceGroups"] = self.resource_groups

if self.stop_policy is not None:
_spec["stopPolicy"] = self.stop_policy

# End of generated code
81 changes: 81 additions & 0 deletions ocp_resources/kueue_components_platform_opendatahub_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md


from typing import Any

from ocp_resources.resource import Resource


class Kueue(Resource):
"""
Kueue is the Schema for the kueues API
"""

api_group: str = Resource.ApiGroup.COMPONENTS_PLATFORM_OPENDATAHUB_IO

def __init__(
self,
auto_create_queues: bool | None = None,
default_cluster_queue_name: str | None = None,
default_local_queue_name: str | None = None,
dev_flags: dict[str, Any] | None = None,
management_state: str | None = None,
**kwargs: Any,
) -> None:
r"""
Args:
auto_create_queues (bool): Controls whether the operator automatically creates default
ClusterQueue, LocalQueue and ResourceFlavor resources in managed
namespaces. When false (the default), the operator skips queue
creation entirely. Only used when autoCreateQueues is true.
Available in RHOAI >= 3.5.

default_cluster_queue_name (str): Configures the automatically created cluster queue name.

default_local_queue_name (str): Configures the automatically created, in the managed namespaces, local
queue name.

dev_flags (dict[str, Any]): Add developer fields. Available in RHOAI <= 2.x.

management_state (str): Set to one of the following values: - "Managed" : the operator is
actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so -
"Unmanaged" : the operator is actively managing the component and
trying to keep it active. It will only upgrade the
component if it is safe to do so - "Removed" : the operator is
actively managing the component and will not install it,
or if it is installed, the operator will try to remove it

"""
super().__init__(**kwargs)

self.auto_create_queues = auto_create_queues
self.default_cluster_queue_name = default_cluster_queue_name
self.default_local_queue_name = default_local_queue_name
self.dev_flags = dev_flags
self.management_state = management_state

def to_dict(self) -> None:

super().to_dict()

if not self.kind_dict and not self.yaml_file:
self.res["spec"] = {}
_spec = self.res["spec"]

if self.auto_create_queues is not None:
_spec["autoCreateQueues"] = self.auto_create_queues

if self.default_cluster_queue_name is not None:
_spec["defaultClusterQueueName"] = self.default_cluster_queue_name

if self.default_local_queue_name is not None:
_spec["defaultLocalQueueName"] = self.default_local_queue_name

if self.dev_flags is not None:
_spec["devFlags"] = self.dev_flags

if self.management_state is not None:
_spec["managementState"] = self.management_state

# End of generated code
93 changes: 93 additions & 0 deletions ocp_resources/kueue_kueue_openshift_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md


from typing import Any

from ocp_resources.resource import Resource


class Kueue(Resource):
"""
Kueue is the CRD to represent the Kueue operator.
"""

api_group: str = Resource.ApiGroup.KUEUE_OPENSHIFT_IO

def __init__(
self,
config: dict[str, Any] | None = None,
log_level: str | None = None,
management_state: str | None = None,
observed_config: dict[str, Any] | None = None,
operator_log_level: str | None = None,
unsupported_config_overrides: dict[str, Any] | None = None,
**kwargs: Any,
) -> None:
r"""
Args:
config (dict[str, Any]): config is the desired configuration for the Kueue operator.

log_level (str): logLevel is an intent based logging for an overall component. It does
not give fine grained control, but it is a simple way to manage
coarse grained logging choices that operators have to interpret
for their operands. Valid values are: "Normal", "Debug", "Trace",
"TraceAll". Defaults to "Normal".

management_state (str): managementState indicates whether and how the operator should manage
the component

observed_config (dict[str, Any]): observedConfig holds a sparse config that controller has observed from
the cluster state. It exists in spec because it is an input to
the level for the operator

operator_log_level (str): operatorLogLevel is an intent based logging for the operator itself.
It does not give fine grained control, but it is a simple way to
manage coarse grained logging choices that operators have to
interpret for themselves. Valid values are: "Normal", "Debug",
"Trace", "TraceAll". Defaults to "Normal".

unsupported_config_overrides (dict[str, Any]): unsupportedConfigOverrides overrides the final configuration that was
computed by the operator. Red Hat does not support the use of this
field. Misuse of this field could lead to unexpected behavior or
conflict with other configuration options. Seek guidance from the
Red Hat support before using this field. Use of this property
blocks cluster upgrades, it must be removed before upgrading your
cluster.

"""
super().__init__(**kwargs)

self.config = config
self.log_level = log_level
self.management_state = management_state
self.observed_config = observed_config
self.operator_log_level = operator_log_level
self.unsupported_config_overrides = unsupported_config_overrides

def to_dict(self) -> None:

super().to_dict()

if not self.kind_dict and not self.yaml_file:
self.res["spec"] = {}
_spec = self.res["spec"]

if self.config is not None:
_spec["config"] = self.config

if self.log_level is not None:
_spec["logLevel"] = self.log_level

if self.management_state is not None:
_spec["managementState"] = self.management_state

if self.observed_config is not None:
_spec["observedConfig"] = self.observed_config

if self.operator_log_level is not None:
_spec["operatorLogLevel"] = self.operator_log_level

if self.unsupported_config_overrides is not None:
_spec["unsupportedConfigOverrides"] = self.unsupported_config_overrides

# End of generated code
65 changes: 65 additions & 0 deletions ocp_resources/local_queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md


from typing import Any

from ocp_resources.resource import NamespacedResource


class LocalQueue(NamespacedResource):
"""
LocalQueue is the Schema for the localQueues API
"""

api_group: str = NamespacedResource.ApiGroup.KUEUE_X_K8S_IO

def __init__(
self,
cluster_queue: str | None = None,
fair_sharing: dict[str, Any] | None = None,
stop_policy: str | None = None,
**kwargs: Any,
) -> None:
r"""
Args:
cluster_queue (str): clusterQueue is a reference to a clusterQueue that backs this
localQueue.

fair_sharing (dict[str, Any]): fairSharing defines the properties of the LocalQueue when
participating in AdmissionFairSharing. The values are only
relevant if AdmissionFairSharing is enabled in the Kueue
configuration. Available in kueue.x-k8s.io/v1beta2+.

stop_policy (str): stopPolicy - if set to a value different from None, the LocalQueue is
considered Inactive, no new reservation being made. Depending on
its value, its associated workloads will: - None - Workloads are
admitted - HoldAndDrain - Admitted workloads are evicted and
Reserving workloads will cancel the reservation. - Hold - Admitted
workloads will run to completion and Reserving workloads will
cancel the reservation.

"""
super().__init__(**kwargs)

self.cluster_queue = cluster_queue
self.fair_sharing = fair_sharing
self.stop_policy = stop_policy

def to_dict(self) -> None:

super().to_dict()

if not self.kind_dict and not self.yaml_file:
self.res["spec"] = {}
_spec = self.res["spec"]

if self.cluster_queue is not None:
_spec["clusterQueue"] = self.cluster_queue

if self.fair_sharing is not None:
_spec["fairSharing"] = self.fair_sharing

if self.stop_policy is not None:
_spec["stopPolicy"] = self.stop_policy

# End of generated code
Loading