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

CustomResource update fails with "the body of the request was in an unknown format" error #1774

Closed
seunggs opened this issue Oct 19, 2021 · 11 comments · Fixed by #1779
Closed
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Milestone

Comments

@seunggs
Copy link

seunggs commented Oct 19, 2021

Hello!

  • Vote on this issue by adding a 👍 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

When running pulumi up for the second time, CustomResource fails to update with the error:

error: 1 error occurred:
        * the Kubernetes API server reported that "sidetrek-webapp-staging-cd3aydbs/frontend-svc" failed to fully initialize or become live: the body of the request was in an unknown format - accepted media types include: application/json-patch+json, application/merge-patch+json, application/apply-patch+yaml

Currently using @pulumi/pulumi ^3.10.1 and @pulumi/kubernetes ^3.6.0

Steps to reproduce

Run pulumi up with a CustomResource for Knative service (runs fine the first time the resource is created but fails for every subsequent pulumi up):

const KService = new k8s.apiextensions.CustomResource('api-svc', {
  apiVersion: 'serving.knative.dev/v1',
  kind: 'Service',
  metadata: {
    namespace,
    name,
  },
  spec: {
    template: {
      spec: {
        containers: [
          {
            image
          }
        ],
      }
    },
  },
}, { provider: k8sProvider })

Expected: Expected the CustomResource to be updated without error
Actual: Works fine on first pulumi up but fails on update (i.e. every subsequent pulumi up)

@lblackstone lblackstone transferred this issue from pulumi/pulumi Oct 19, 2021
@lblackstone lblackstone added the kind/bug Some behavior is incorrect or out of spec label Oct 19, 2021
@iamjekyun
Copy link

I'm also having this exact same issue with knative service component.

@iamjekyun
Copy link

I think that this might help. upgrade calls Update not Patch

knative/serving#11492 (comment)

@seunggs
Copy link
Author

seunggs commented Oct 26, 2021

@lblackstone Any plans to look into this issue? If I'm not mistaken, Knative is becoming quite popular and this bug renders Knative's revision-based deployment useless (i.e. no versioning, rollbacks, gradual deployment, etc).

@viveklak
Copy link
Contributor

Are there any updates on the CR between the pulumi ups? In the case of the second update that fails could you dump detailed logs? Something like the following should be sufficient:
pulumi -d --logflow --logtostderr -v=9 up 2>&1 | tee /tmp/log

If there is anything sensitive we can arrange sharing this privately.

@seunggs
Copy link
Author

seunggs commented Oct 27, 2021

Hi, I have the logs off of the command you sent but in case there's some sensitive information I'd like to send this privately (besides, there's an insane amount of logs) - let me know how and I can send it over.

Thanks for looking into this!

@viveklak
Copy link
Contributor

Acknowledging I have logs from @seunggs for this. Will post update once I am done looking through.

@viveklak
Copy link
Contributor

viveklak commented Oct 28, 2021

So I am not sure why the engine is trying to do an update even though there is no change in the code for the CR. This might be because of the provider performing a three-way strategic merge (fetching live state from server).

I believe the specific issue is due to the following code:

kind := kinds.Kind(lastSubmitted.GetKind())
if knownKind, _ := kind.Namespaced(); !knownKind {
// Use a JSON merge patch for CRD Kinds.
patch, patchType, err = MergePatch(
lastSubmitted, lastSubmittedJSON, currentSubmittedJSON, liveOldJSON,
)
return patch, patchType, lookupPatchMeta, err
}

In this case, the kind of the CR is "Service" which is misconstrued to refer to core service and ends up trying to use the three way strategic merge for the CR - resulting in the failure. This test needs to be strengthened to specifically look for fully qualified kinds instead.

@lblackstone
Copy link
Member

Thanks for tracking this down @viveklak! #1779 should fix the buggy check.

@seunggs
Copy link
Author

seunggs commented Oct 28, 2021

@lblackstone and @viveklak thanks for the quick fix! When will this fix be released?

@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Oct 29, 2021
@lblackstone
Copy link
Member

@seunggs
Copy link
Author

seunggs commented Oct 29, 2021

Awesome! 🎉

I can confirm that Knative revisions are now getting created properly on code update:

NAME            CONFIG NAME   K8S SERVICE NAME   GENERATION   READY   REASON   ACTUAL REPLICAS   DESIRED REPLICAS
app-svc-00001   app-svc                          1            True             1                 1
app-svc-00002   app-svc                          2            True             1                 1

Thanks for the quick turnaround on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants