-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
fix(sdk/backend): allow using cluster's default sc
When using the SDK's function `CreatePVC`, leaving the `storage_class_name` field empty will result in the cluster’s default storage class being applied. To enhance modularity and clarity, the logic for building the PVC definition has been refactored into a dedicated function. Error messages have been updated to align with this change, and unit tests have been implemented to cover all required and optional fields. In the code handling annotations, the `GetFields` method has replaced the use of the `AsMap` method. This approach is more convenient and eliminates the need for type conversion to `structpb.Value`. Resolves: #11396 Signed-off-by: Sébastien Han <[email protected]>
Showing
10 changed files
with
380 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
kubernetes_platform/python/test/snapshot/data/create_dynamic_pvc_default_sc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2024 The Kubeflow Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from kfp import dsl | ||
from kfp import kubernetes | ||
|
||
|
||
@dsl.pipeline | ||
def my_pipeline(): | ||
kubernetes.CreatePVC( | ||
pvc_name_suffix="-my-pvc", | ||
access_modes=["ReadWriteOnce"], | ||
size="5Mi", | ||
annotations={"foo": "bar"}, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
from kfp import compiler | ||
|
||
compiler.Compiler().compile(my_pipeline, __file__.replace(".py", ".yaml")) |
99 changes: 99 additions & 0 deletions
99
kubernetes_platform/python/test/snapshot/data/create_dynamic_pvc_default_sc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# PIPELINE DEFINITION | ||
# Name: my-pipeline | ||
components: | ||
comp-createpvc: | ||
executorLabel: exec-createpvc | ||
inputDefinitions: | ||
parameters: | ||
access_modes: | ||
description: 'AccessModes to request for the provisioned PVC. May | ||
be one or more of ``''ReadWriteOnce''``, ``''ReadOnlyMany''``, ``''ReadWriteMany''``, | ||
or | ||
``''ReadWriteOncePod''``. Corresponds to `PersistentVolumeClaim.spec.accessModes | ||
<https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes>`_.' | ||
parameterType: LIST | ||
annotations: | ||
description: Annotations for the PVC's metadata. Corresponds to `PersistentVolumeClaim.metadata.annotations | ||
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaim>`_. | ||
isOptional: true | ||
parameterType: STRUCT | ||
pvc_name: | ||
description: 'Name of the PVC. Corresponds to `PersistentVolumeClaim.metadata.name | ||
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaim>`_. | ||
Only one of ``pvc_name`` and ``pvc_name_suffix`` can | ||
be provided.' | ||
isOptional: true | ||
parameterType: STRING | ||
pvc_name_suffix: | ||
description: 'Prefix to use for a dynamically generated name, which | ||
will take the form ``<argo-workflow-name>-<pvc_name_suffix>``. Only one | ||
of ``pvc_name`` and ``pvc_name_suffix`` can be provided.' | ||
isOptional: true | ||
parameterType: STRING | ||
size: | ||
description: The size of storage requested by the PVC that will be provisioned. | ||
For example, ``'5Gi'``. Corresponds to `PersistentVolumeClaim.spec.resources.requests.storage | ||
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaimSpec>`_. | ||
parameterType: STRING | ||
storage_class_name: | ||
defaultValue: '' | ||
description: 'Name of StorageClass from which to provision the PV | ||
to back the PVC. ``None`` indicates to use the cluster''s default | ||
storage class. Set to ``''''`` for a statically specified PVC.' | ||
isOptional: true | ||
parameterType: STRING | ||
volume_name: | ||
description: 'Pre-existing PersistentVolume that should back the | ||
provisioned PersistentVolumeClaim. Used for statically | ||
specified PV only. Corresponds to `PersistentVolumeClaim.spec.volumeName | ||
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaimSpec>`_.' | ||
isOptional: true | ||
parameterType: STRING | ||
outputDefinitions: | ||
parameters: | ||
name: | ||
parameterType: STRING | ||
deploymentSpec: | ||
executors: | ||
exec-createpvc: | ||
container: | ||
image: argostub/createpvc | ||
pipelineInfo: | ||
name: my-pipeline | ||
root: | ||
dag: | ||
tasks: | ||
createpvc: | ||
cachingOptions: | ||
enableCache: true | ||
componentRef: | ||
name: comp-createpvc | ||
inputs: | ||
parameters: | ||
access_modes: | ||
runtimeValue: | ||
constant: | ||
- ReadWriteOnce | ||
annotations: | ||
runtimeValue: | ||
constant: | ||
foo: bar | ||
pvc_name_suffix: | ||
runtimeValue: | ||
constant: -my-pvc | ||
size: | ||
runtimeValue: | ||
constant: 5Mi | ||
taskInfo: | ||
name: createpvc | ||
schemaVersion: 2.1.0 | ||
sdkVersion: kfp-2.10.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters