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

unable to update arrays via parameterKey #171

Open
drewwells opened this issue Sep 21, 2023 · 5 comments
Open

unable to update arrays via parameterKey #171

drewwells opened this issue Sep 21, 2023 · 5 comments

Comments

@drewwells
Copy link

Describe the bug
When attempting to update an array in values, it's no longer possible to do so. Instead, it creates a map["0"] entry.

To Reproduce
use a parameterKey myscore[0]

Expected behavior

Expected it to produce values [99]

Instead it produces

{"0":99}

Screenshots
Actual
image
Expected
image

Additional context
I tracked down this drift from expected array output to the following PRs

After this PR, an oddity is emitted with [99,...] instead of [99] #86

Arrays can no longer be updated by workflows, instead get treated as maps
#112

@drewwells
Copy link
Author

I tracked down the problem. We have seen several issues in last few release of kubevela, and it may be unrelated to workflow.
Our values are passed from valuesFrom in a separate configmap. In that situation, workflow seems to guess types and creates maps instead of arrays. We also can't update annotations without specifying the specific key ie.

annotations:
  eks.amazon.com/role: abba

If I add this information directly to the application CR values: property, then the behavior of kubevela 0.6.5 workflow 0.3.3 is restored.

@drewwells
Copy link
Author

Empty arrays get this error as well:

invalid cue task for evaluation: runtime error: index out of range
        [0] with length 0

We need more flexibility in how to update arrays. I basically have to populate an array in order to use kubevela and this poses problems since this array needs to be null when kubevela isn't operating on it.

@FogDong
Copy link
Member

FogDong commented Oct 8, 2023

Can you provide a workflow yaml to reproduce this?

@drewwells
Copy link
Author

drewwells commented Oct 11, 2023

If you're familiar with cert-manager, it represents solvers in an array:

solvers:
- dns01:
   route53:
    region: us-east-1

Here's a workflow to attempt to update it

    workflow:
      steps:
      - name: read-provider-info
        outputs:
        - name: region
          valueFrom: |
            import "encoding/json"
            json.Unmarshal(output.value.data["data.json"]).region
        - name: hosted_zone_id
          valueFrom: |
            import "encoding/json"
            json.Unmarshal(output.value.data["data.json"]).hosted_zone_id
        properties:
          apiVersion: v1
          kind: ConfigMap
          name: cluster-config-map
          namespace: vela-system
        type: read-object
      - inputs:
        - from: region
          parameterKey: properties.values.solvers[0].dns01.route53.region
        - from: hosted_zone_id
          parameterKey: properties.values.solvers[0].dns01.route53.hostedZoneID
        name: apply
        properties:
          component: cert-manager-issuer
        type: apply-component

Arrays are problematic, b/c you can not append to an array. So for me to add to solvers, I get index out of range errors until I provide a default values with 2 items in the array.

@drewwells
Copy link
Author

drewwells commented Oct 11, 2023

Annotation workflow example:

    workflow:
      steps:
      - name: read-object
        outputs:
        - name: appinfra_grafana_role_arn
          valueFrom: |
            import "encoding/json"
            json.Unmarshal(output.value.data["data.json"]).roles.appinfra_grafana_irsa.arn
        properties:
          apiVersion: v1
          kind: ConfigMap
          name: cluster-config-map
          namespace: vela-system
        type: read-object
      - inputs:
        - from: appinfra_grafana_role_arn
          parameterKey: properties.values.serviceAccount.annotations["eks.amazonaws.com/role-arn"]
        name: apply
        properties:
          component: appinfra-grafana
        type: apply-component

I'll get invalid yaml (keys cannot have quotes) from this workflow until I populate values.yaml with annotations["eks.amazonaws.com/role-arn"]: ""

annotations:
  "eks.amazonaws.com/role-arn": somevalue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants