-
Notifications
You must be signed in to change notification settings - Fork 980
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
Patching from environment patches does not work with Pipeline mode #5267
Comments
This should work as expected: ---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: nop.sqlinstances.example.org
spec:
compositeTypeRef:
apiVersion: example.org/v1alpha1
kind: XSQLInstance
environment:
environmentConfigs:
- ref:
name: example-environment-1
type: Reference
mode: Pipeline
pipeline:
- step: patches
functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
environment:
patches:
- type: ToCompositeFieldPath
fromFieldPath: labels.environment
toFieldPath: metadata.annotations[valueFromEnv]
- type: ToCompositeFieldPath
fromFieldPath: annotations.environment
toFieldPath: metadata.labels[valueFromEnv]
resources:
- name: nop
base:
apiVersion: nop.crossplane.io/v1alpha1
kind: NopResource
spec:
forProvider:
fields:
fromNopResource: fromNopResource
conditionAfter:
- conditionType: Ready
conditionStatus: "False"
time: 0s
- conditionType: Ready
conditionStatus: "True"
time: 10s
patches:
- type: ToCompositeFieldPath
fromFieldPath: spec.forProvider.fields.fromNopResource
toFieldPath: status.valueFromNopResource |
here's the diff between the original composition and what @phisco is suggesting: 14,20d13
< patches:
< - type: ToCompositeFieldPath
< fromFieldPath: labels.environment
< toFieldPath: metadata.annotations[valueFromEnv]
< - type: ToCompositeFieldPath
< fromFieldPath: annotations.environment
< toFieldPath: metadata.labels[valueFromEnv]
28a22,29
> environment:
> patches:
> - type: ToCompositeFieldPath
> fromFieldPath: labels.environment
> toFieldPath: metadata.annotations[valueFromEnv]
> - type: ToCompositeFieldPath
> fromFieldPath: annotations.environment
> toFieldPath: metadata.labels[valueFromEnv] Out of curiosity @lajchon, did you try out the https://github.com/crossplane-contrib/crossplane-migrator when doing this migration from native patch & transform to Functions? We are expecting to include that migration tooling into the official |
When I try that, my Composite resource reports the following fatal condition: status:
conditions:
- message: >-
cannot compose resources: pipeline step "patches" returned a fatal
result: invalid Function input: environment.patches[0][type]: Invalid
value: "ToCompositeFieldPath": invalid environment patch type
reason: ReconcileError
status: 'False'
type: Synced Also, when I look at the @jbw976 I'll try |
@jbw976 same result after using
Resultant apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
creationTimestamp: "2024-01-19T17:16:51Z"
name: nop.sqlinstances.example.org
spec:
compositeTypeRef:
apiVersion: example.org/v1alpha1
kind: XSQLInstance
environment:
environmentConfigs:
- ref:
name: example-environment-1
type: Reference
mode: Pipeline
pipeline:
- functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
environment:
patches:
- fromFieldPath: complex.c.f
toFieldPath: status.valueFromEnv
type: ToCompositeFieldPath
- fromFieldPath: complex.c.f
toFieldPath: metadata.annotations[valueFromEnv]
type: ToCompositeFieldPath
- fromFieldPath: complex.c.f
toFieldPath: metadata.labels[valueFromEnv]
type: ToCompositeFieldPath
kind: Resources
patchSets: []
resources:
- base:
apiVersion: nop.crossplane.io/v1alpha1
kind: NopResource
spec:
forProvider:
conditionAfter:
- conditionStatus: "False"
conditionType: Ready
time: 0s
- conditionStatus: "True"
conditionType: Ready
time: 10s
fields:
fromNopResource: fromNopResource
name: nop
patches:
- fromFieldPath: spec.forProvider.fields.fromNopResource
toFieldPath: status.valueFromNopResource
type: ToCompositeFieldPath
step: patch-and-transform
fromNopResource
toFieldPath: status.valueFromNopResource
type: ToCompositeFieldPath apiVersion: example.org/v1alpha1
kind: XSQLInstance
metadata:
finalizers:
- composite.apiextensions.crossplane.io
generateName: example-
generation: 2
labels:
crossplane.io/claim-name: example
crossplane.io/claim-namespace: default
crossplane.io/composite: example-tbct6
stage: develop
name: example-tbct6
status:
conditions:
- lastTransitionTime: '2024-01-19T17:13:03Z'
message: >-
cannot compose resources: pipeline step "patch-and-transform" returned a
fatal result: invalid Function input: environment.patches[0][type]:
Invalid value: "ToCompositeFieldPath": invalid environment patch type
reason: ReconcileError
status: 'False'
type: Synced
spec:
claimRef:
apiVersion: example.org/v1alpha1
kind: SQLInstance
name: example
namespace: default
compositionRef:
name: nop.sqlinstances.example.org
compositionRevisionRef:
name: nop.sqlinstances.example.org-8ed5b9b
compositionUpdatePolicy: Automatic
parameters:
storageGB: 10 |
If I'm following correctly there's nothing to do on core Crossplane, and the issue is fixed but unreleased in function-patch-and-transform. I'd transfer this to function-patch-and-transform, but unfortunately you can't transfer issues to different orgs. Given that the issue is fixed and just pending release I'm going to mark this resolved. |
What happened?
When switching to
mode: Pipeline
inComposition
and utilizingfunction-patch-and-transform
,spec.environment.patches
are never applied. Switching tospec.resources
, the composite resource is successfully patched.How can we reproduce it?
Create new kind cluster:
Deploy Crossplane 1.14.5:
Deploy Provider, Composition and CompositeResourceDefinition:
Deploy EnvironmentConfig:
Deploy Claim:
Output resources:
Results:
Expect
XSQLInstance
to contain the followingannotation
andlabel
, but it does not, even after Claim reportstrue
for Synced and Ready.Lastly, the same also appears to be true when using
spec.environment.patches[].type: ToEnvironmentFieldPath
. New key is never made available through in-memory environment.What environment did it happen in?
Crossplane version: v1.14.5
function-patch-and-transform version: v0.2.1
The text was updated successfully, but these errors were encountered: