From c6c2b69e171d5097a5114b5f0fbd727bb993354b Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Sat, 30 Jul 2022 10:02:24 +0100 Subject: [PATCH 1/3] :bug: fix operator-sdk generate kustomize manifests to respect changes made by users in the config/manifests Signed-off-by: Camila Macedo --- changelog/fragments/fix.yaml | 8 ++++++++ .../v2/templates/config/manifests/kustomization.go | 6 ++++++ website/content/en/docs/faqs/_index.md | 14 ++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 changelog/fragments/fix.yaml diff --git a/changelog/fragments/fix.yaml b/changelog/fragments/fix.yaml new file mode 100644 index 00000000000..6dcf881744b --- /dev/null +++ b/changelog/fragments/fix.yaml @@ -0,0 +1,8 @@ +# entries is a list of entries to include in +# release notes and/or the migration guide +entries: + - description: > + Fix operator-sdk generate kustomize manifests to respect changes made by users in the config/manifests + kind: "bugfix" + breaking: false + diff --git a/internal/plugins/manifests/v2/templates/config/manifests/kustomization.go b/internal/plugins/manifests/v2/templates/config/manifests/kustomization.go index 7e7b090a80f..87c6122d72b 100644 --- a/internal/plugins/manifests/v2/templates/config/manifests/kustomization.go +++ b/internal/plugins/manifests/v2/templates/config/manifests/kustomization.go @@ -36,6 +36,12 @@ func (f *Kustomization) SetTemplateDefaults() error { f.Path = filepath.Join("config", "manifests", "kustomization.yaml") } + // We cannot overwiting the file after it be created because + // it might contain user changes (i.e to work with Kustomize 4.x + // the target /spec/template/spec/containers/1/volumeMounts/0 + // needs to be replaced with /spec/template/spec/containers/0/volumeMounts/0 + f.IfExistsAction = machinery.SkipFile + f.TemplateBody = kustomizationTemplate return nil diff --git a/website/content/en/docs/faqs/_index.md b/website/content/en/docs/faqs/_index.md index 35aff6aacb4..8ad63df95d0 100644 --- a/website/content/en/docs/faqs/_index.md +++ b/website/content/en/docs/faqs/_index.md @@ -331,5 +331,19 @@ Here are a couple workarounds to try to resolve the issue: If neither of those solutions work for you, please [open an issue][open-issue] +## After update my project to use a Kustomize 4.x version the make bundle does not properly work + +**Valid only for Golang/Hybrid projects using webhooks** + +> `Error: remove operation does not apply:doc is missing path: "/spec/template/spec/containers/1/volumeMounts/0": missing value` + +The error occurs because with the upper Kustomize version the containers used in the Deployment spec of your CSV +are no longer added at the same order. To sort it out you can update replace the target `/spec/template/spec/containers/1/volumeMounts/0` +with `/spec/template/spec/containers/0/volumeMounts/0` in `config/manifest/kustomization.yaml`. + +**NOTE** You MUST use SDK CLI versions > 1.22. Previous versions have a bug +where the command `operator-sdk generate kustomize manifests` is not respecting the changes +made on this manifest. + [cgo-docs]: https://pkg.go.dev/cmd/cgo [open-issue]: https://github.com/operator-framework/operator-sdk/issues/new/choose \ No newline at end of file From cfc748f46773721cb2fed11f92859e8600dd9b21 Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Mon, 1 Aug 2022 16:08:33 +0100 Subject: [PATCH 2/3] Update website/content/en/docs/faqs/_index.md Co-authored-by: Bryce Palmer --- website/content/en/docs/faqs/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/en/docs/faqs/_index.md b/website/content/en/docs/faqs/_index.md index 8ad63df95d0..c048db572da 100644 --- a/website/content/en/docs/faqs/_index.md +++ b/website/content/en/docs/faqs/_index.md @@ -331,7 +331,7 @@ Here are a couple workarounds to try to resolve the issue: If neither of those solutions work for you, please [open an issue][open-issue] -## After update my project to use a Kustomize 4.x version the make bundle does not properly work +## After updating my project to use a Kustomize 4.x version, 'make bundle' does not work **Valid only for Golang/Hybrid projects using webhooks** From 1de4fb519e488053b3f5271278c7c14d50d6368a Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Mon, 1 Aug 2022 16:08:39 +0100 Subject: [PATCH 3/3] Update website/content/en/docs/faqs/_index.md Co-authored-by: Bryce Palmer --- website/content/en/docs/faqs/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/en/docs/faqs/_index.md b/website/content/en/docs/faqs/_index.md index c048db572da..2adc81dff9f 100644 --- a/website/content/en/docs/faqs/_index.md +++ b/website/content/en/docs/faqs/_index.md @@ -337,7 +337,7 @@ If neither of those solutions work for you, please [open an issue][open-issue] > `Error: remove operation does not apply:doc is missing path: "/spec/template/spec/containers/1/volumeMounts/0": missing value` -The error occurs because with the upper Kustomize version the containers used in the Deployment spec of your CSV +The error occurs due to a change in the Kustomize 4.x versions where the containers used in the Deployment spec of your CSV are no longer added at the same order. To sort it out you can update replace the target `/spec/template/spec/containers/1/volumeMounts/0` with `/spec/template/spec/containers/0/volumeMounts/0` in `config/manifest/kustomization.yaml`.