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

YAML Multiline block indicator issue #1829

Closed
jfbourner opened this issue Oct 12, 2022 · 2 comments · Fixed by #1912
Closed

YAML Multiline block indicator issue #1829

jfbourner opened this issue Oct 12, 2022 · 2 comments · Fixed by #1912
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jfbourner
Copy link

jfbourner commented Oct 12, 2022

Describe the bug

When adding ISTIO configuration, via the annotations config, it is setting a Block Chomping Indicator to clip the new line, where it needs to retain the new line.
Yaml Multiline
ISTIO Config

POM Plugin config

<resources>
	<annotations>
		<all>
			<property>
				<name>proxy.istio.io/config</name>
				<value>proxyMetadata:
    ISTIO_META_DNS_CAPTURE: "false"
holdApplicationUntilProxyStarts: true</value>
			</property>
		</all>
	</annotations>
</resources>

Deployment.yml Output

metadata:
    annotations:
      proxy.istio.io/config: |-
        proxyMetadata:
            ISTIO_META_DNS_CAPTURE: "false"
        holdApplicationUntilProxyStarts: true

As you can see above the deployment yaml has "|-" which causes the annotation to not work with ISTIO

Eclipse JKube version

1.9.1

Component

Kubernetes Maven Plugin

Apache Maven version

3.8.3

Gradle version

No response

Steps to reproduce

  1. Configure the maven plugin - annotation - with multiline text.
  2. Build it using mvn k8s:resource
  3. Check target output

Expected behavior

Expected output

metadata:
    annotations:
      proxy.istio.io/config:  |
        proxyMetadata:
            ISTIO_META_DNS_CAPTURE: "false"
        holdApplicationUntilProxyStarts: true

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

other (please specify in additional context)

Environment

Windows, Linux

Eclipse JKube Logs

No response

Sample Reproducer Project

Sits on commercial infra

Additional context

No response

@jfbourner jfbourner added the bug Something isn't working label Oct 12, 2022
@rohanKanojia
Copy link
Member

rohanKanojia commented Nov 9, 2022

@jfbourner : Thanks for reporting, I can reproduce the issue. I think this behavior is coming from our Jackson ObjectMapper in ResourceUtil which is not doing serialization as expected.

https://github.com/eclipse/jkube/blob/63ab8d3a3239f20da0f1ccc747ad219153d7af32/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/ResourceUtil.java#L55-L56

In the meantime, Could you please check if using mvn k8s:resource -Djkube.resourceType=json works for your project as a workaround?

@rohanKanojia
Copy link
Member

Nope, my previous assumption was wrong.

Jackson ObjectMapper is doing what it is supposed to do. Somehow trailing newline doesn't seem to be added to annotation value via this config:

                            <property>
                                    <name>proxy.istio.io/config</name>
                                    <value>proxyMetadata:
    ISTIO_META_DNS_CAPTURE: "false"
holdApplicationUntilProxyStarts: true</value>
                            </property>

this generates annotation with value: proxyMetadata:\n ISTIO_META_DNS_CAPTURE: "false"\nholdApplicationUntilProxyStarts: true (notice there is no newline at the end) . This results in Jackson adding |- which means strip ending newline.

I tried adding &#xA; to enforce newline at the end but it didn't work. This looks like an XML specific problem, in gradle I'm easily able to specify newline at the end. If I make changes in code to enforce trailing newline for multiline strings it correctly adds |

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 14, 2022
… in labels/annotations (eclipse-jkube#1829)

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 15, 2022
… in labels/annotations (eclipse-jkube#1829)

Add a trailing newline in case of multiline values in labels and
annotations in MetadataVisitor

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa added this to the 1.11.0 milestone Nov 17, 2022
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Jan 30, 2023
… in labels/annotations (eclipse-jkube#1829)

Add a trailing newline in case of multiline values in labels and
annotations in MetadataVisitor

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Feb 14, 2023
… in labels/annotations (eclipse-jkube#1829)

Add a trailing newline in case of multiline values in labels and
annotations in MetadataVisitor

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit that referenced this issue Feb 15, 2023
… in labels/annotations (#1829)

Add a trailing newline in case of multiline values in labels and
annotations in MetadataVisitor

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants