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

ConfigManagementPlugin get 「Unknown grpc.method=GetParametersAnnouncement grpc.service=plugin.ConfigManagementPluginService」 #16077

Closed
3 tasks done
xshi0001 opened this issue Oct 23, 2023 · 2 comments · Fixed by #16190

Comments

@xshi0001
Copy link

xshi0001 commented Oct 23, 2023

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug

ConfigManagementPlugin demo: https://github.com/argoproj/argo-cd/tree/master/examples/plugins

and get:

time="2023-10-23T15:17:53Z" level=error msg="finished streaming call with code Unknown" error="get parameters announcement error: error unmarshaling dynamic parameter output into ParametersAnnouncementResponse: json: cannot unmarshal object into Go value of type []*apiclient.ParameterAnnouncement" grpc.code=Unknown grpc.method=GetParametersAnnouncement grpc.service=plugin.ConfigManagementPluginService grpc.start_time="2023-10-23T15:17:53Z" grpc.time_ms=81.583 span.kind=server system=grpc

To Reproduce

apiVersion: v1
kind: ConfigMap
metadata:
  name: helm-plugin-config
  namespace: argocd
  uid: f2c8a6ef-a026-4127-8e33-b5073da65e2e
  resourceVersion: '894548'
  creationTimestamp: '2023-10-19T09:11:59Z'
  labels:
    k8slens-edit-resource-version: v1
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: >
      {"apiVersion":"v1","data":{"generate.sh":"#!/bin/sh\n\nARGUMENTS=$(echo
      \"$ARGOCD_APP_PARAMETERS\" | jq -r '.[] | select(.name ==
      \"values-files\").array | .[] | \"--values=\" + .')\nPARAMETERS=$(echo
      \"$ARGOCD_APP_PARAMETERS\" | jq -r '.[] | select(.name ==
      \"helm-parameters\").map | to_entries | map(\"\\(.key)=\\(.value)\") | .[]
      | \"--set=\" + .')\n\necho \". $ARGUMENTS $PARAMETERS\" | xargs helm
      template\n","get-parameters.sh":"#!/bin/sh\n\nyq e -o=json values.yaml |
      jq '{\n  name: \"helm-parameters\",\n  title: \"Helm Parameters\",\n 
      collectionType: \"map\",\n  map: [leaf_paths as $path | {\"key\": $path |
      join(\".\"), \"value\": getpath($path)|tostring}] |
      from_entries\n}'\n","plugin.yaml":"apiVersion: argoproj.io/v1alpha1\nkind:
      ConfigManagementPlugin\nmetadata:\n  name: simple-helm-cmp\nspec:\n 
      version: v1.0\n  generate:\n    command: [sh,
      /var/run/argocd/helm-plugin/generate.sh]\n  discover:\n    fileName:
      \"./values.yaml\"\n  parameters:\n    static:\n      - name:
      values-files\n        title: VALUES FILES\n        collectionType:
      array\n    dynamic:\n      command: [sh,
      /var/run/argocd/helm-plugin/get-parameters.sh]\n"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"helm-plugin-config","namespace":"argocd"}}
  managedFields:
    - manager: kubectl-client-side-apply
      operation: Update
      apiVersion: v1
      time: '2023-10-19T09:11:59Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:data:
          .: {}
          f:generate.sh: {}
        f:metadata:
          f:annotations:
            .: {}
            f:kubectl.kubernetes.io/last-applied-configuration: {}
    - manager: node-fetch
      operation: Update
      apiVersion: v1
      time: '2023-10-23T14:12:00Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:data:
          f:get-parameters.sh: {}
          f:plugin.yaml: {}
        f:metadata:
          f:labels:
            .: {}
            f:k8slens-edit-resource-version: {}
  selfLink: /api/v1/namespaces/argocd/configmaps/helm-plugin-config
data:
  generate.sh: >
    #!/bin/sh


    ARGUMENTS=$(echo "$ARGOCD_APP_PARAMETERS" | jq -r '.[] | select(.name ==
    "values-files").array | .[] | "--values=" + .')

    PARAMETERS=$(echo "$ARGOCD_APP_PARAMETERS" | jq -r '.[] | select(.name ==
    "helm-parameters").map | to_entries | map("\(.key)=\(.value)") | .[] |
    "--set=" + .')


    echo ". $ARGUMENTS $PARAMETERS" | xargs helm template
  get-parameters.sh: |
    #!/bin/sh

    yq e -o=json values.yaml | jq '{
      name: "helm-parameters-dynamic",
      collectionType: "map",
      map: [leaf_paths as $path | {"key": $path | join("."), "value": getpath($path)|tostring}] | from_entries
    }'
  plugin.yaml: |
    apiVersion: argoproj.io/v1alpha1
    kind: ConfigManagementPlugin
    metadata:
      name: simple-helm-cmp
    spec:
      version: v1.0
      generate:
        command: [sh, /var/run/argocd/helm-plugin/generate.sh]
      discover:
        fileName: "./values.yaml"
      parameters:
        static:
          - name: values-files
            title: VALUES FILES
            collectionType: array
        dynamic:
          command: [sh, /var/run/argocd/helm-plugin/get-parameters.sh]
image

Expected behavior

get correct param from argocd ui

Screenshots

image

Version

[root@blueprint fastdfs]#  argocd version
argocd: v2.8.4+c279299
  BuildDate: 2023-09-13T19:43:37Z
  GitCommit: c27929928104dc37b937764baf65f38b78930e59
  GitTreeState: clean
  GoVersion: go1.20.7
  Compiler: gc
  Platform: linux/amd64
argocd-server: v2.9.0+d7cd236

Logs

time="2023-10-23T15:20:56Z" level=debug msg="config.Spec.Discover.FileName is provided"
time="2023-10-23T15:20:56Z" level=info msg="finished streaming call with code OK" grpc.code=OK grpc.method=MatchRepository grpc.service=plugin.ConfigManagementPluginService grpc.start_time="2023-10-23T15:20:56Z" grpc.time_ms=27.056 span.kind=server system=grpc
time="2023-10-23T15:20:56Z" level=info msg="sh /var/run/argocd/helm-plugin/get-parameters.sh" dir=/tmp/_cmp_server/1f8e6a8c-601b-497d-a26a-46ea26803c4d/helm-guestbook execID=70a58
time="2023-10-23T15:20:56Z" level=debug msg="{\n  \"name\": \"helm-parameters-dynamic\",\n  \"collectionType\": \"map\",\n  \"map\": {\n    \"replicaCount\": \"1\",\n    \"image.repository\": \"docker.io/hekai/gcr.io_heptio-images_ks-guestbook-demo_0.2\",\n    \"image.tag\": \"latest\",\n    \"image.pullPolicy\": \"IfNotPresent\",\n    \"service.type\": \"ClusterIP\",\n    \"service.port\": \"80\",\n    \"ingress.path\": \"/\",\n    \"ingress.hosts.0\": \"chart-example.local\"\n  }\n}\n" duration=47.69324ms execID=70a58
time="2023-10-23T15:20:56Z" level=error msg="finished streaming call with code Unknown" error="get parameters announcement error: error unmarshaling dynamic parameter output into ParametersAnnouncementResponse: json: cannot unmarshal object into Go value of type []*apiclient.ParameterAnnouncement" grpc.code=Unknown grpc.method=GetParametersAnnouncement grpc.service=plugin.ConfigManagementPluginService grpc.start_time="2023-10-23T15:20:56Z" grpc.time_ms=81.021 span.kind=server system=grp
@xshi0001 xshi0001 added the bug Something isn't working label Oct 23, 2023
@crenshaw-dev
Copy link
Member

My script is out of date and incorrect. Try this:

  get-parameters.sh: |
    #!/bin/sh

-    yq e -o=json values.yaml | jq '{
+    yq e -o=json values.yaml | jq '[{
      name: "helm-parameters-dynamic",
      collectionType: "map",
      map: [leaf_paths as $path | {"key": $path | join("."), "value": getpath($path)|tostring}] | from_entries
-    }'
+    }]'

@xshi0001
Copy link
Author

My script is out of date and incorrect. Try this:

  get-parameters.sh: |
    #!/bin/sh

-    yq e -o=json values.yaml | jq '{
+    yq e -o=json values.yaml | jq '[{
      name: "helm-parameters-dynamic",
      collectionType: "map",
      map: [leaf_paths as $path | {"key": $path | join("."), "value": getpath($path)|tostring}] | from_entries
-    }'
+    }]'

thx! has fixed it~~

image

@crenshaw-dev crenshaw-dev reopened this Oct 31, 2023
@crenshaw-dev crenshaw-dev added type:docs and removed bug Something isn't working labels Oct 31, 2023
crenshaw-dev added a commit to crenshaw-dev/argo-cd that referenced this issue Oct 31, 2023
ishitasequeira pushed a commit that referenced this issue Nov 1, 2023
gcp-cherry-pick-bot bot pushed a commit that referenced this issue Nov 1, 2023
gcp-cherry-pick-bot bot pushed a commit that referenced this issue Nov 1, 2023
gcp-cherry-pick-bot bot pushed a commit that referenced this issue Nov 1, 2023
crenshaw-dev added a commit that referenced this issue Nov 1, 2023
Signed-off-by: Michael Crenshaw <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
crenshaw-dev added a commit that referenced this issue Nov 1, 2023
Signed-off-by: Michael Crenshaw <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
crenshaw-dev added a commit that referenced this issue Nov 1, 2023
Signed-off-by: Michael Crenshaw <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
jmilic1 pushed a commit to jmilic1/argo-cd that referenced this issue Nov 13, 2023
vladfr pushed a commit to vladfr/argo-cd that referenced this issue Dec 13, 2023
tesla59 pushed a commit to tesla59/argo-cd that referenced this issue Dec 16, 2023
alexmt pushed a commit to alexmt/argo-cd that referenced this issue Jan 19, 2024
lyda pushed a commit to lyda/argo-cd that referenced this issue Mar 28, 2024
Hariharasuthan99 pushed a commit to AmadeusITGroup/argo-cd that referenced this issue Jun 16, 2024
alexmt pushed a commit to alexmt/argo-cd that referenced this issue Dec 6, 2024
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

Successfully merging a pull request may close this issue.

2 participants