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

[JENKINS-71956] Octal notation fixes #1503

Merged

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Jan 19, 2024

Context
Kubernetes-client uses jackson-databind to parse yaml into objects, using snakeyaml.
Kubernetes-client has migrated their serialization methods to use SnakeYAML engine (fabric8io/kubernetes-client#4836)

The problem is that snakeyaml uses yaml 1.1 while snakeyaml-engine only supports yaml 1.2.

This causes inconsistencies when dealing with integer with the octal notation, as there are breaking changes between these two versions. Additionally, FasterXML/jackson-dataformats-text#3 documents that octal notation is not properly supported through jackson.

Plugin perspective

This follows up #1342, already providing some octal notation conversion.

User yaml is still expected to use yaml 1.1, using the 0xxx notation for octal integers. For a series of known paths in the pod spec, an automatic conversion will happen.

This behaviour can be disabled using -Dorg.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.DISABLE_OCTAL_MODES=true in case users have converted their yaml manifests to use decimal notation instead. A best effort is attempted to keep modes that have been provided using decimal notation, but this can't be foolproof.

Going forward, jackson 3.0 will use SnakeYAML engine so hopefully we will eventually get a more consistent behaviour, but I expect possible new breaking changes when it happens.

This adds a few paths I missed when I initially addressed this kubernetes-client upgrade in #1342, as well as providing unit tests.

Testing done

Submitter checklist

Preview Give feedback

* Support more paths to convert modes
* Allows to disable conversion for people who converted their manifests to decimal notation.
@Vlatombe Vlatombe marked this pull request as ready for review January 19, 2024 13:57
@Vlatombe Vlatombe requested a review from a team as a code owner January 19, 2024 13:57
@Vlatombe Vlatombe added the bug Bug Fixes label Jan 19, 2024
@Vlatombe Vlatombe merged commit 3b88431 into jenkinsci:master Jan 19, 2024
6 checks passed
@Vlatombe Vlatombe deleted the JENKINS-71956-octal-mode-improvements branch January 19, 2024 16:15
*
* The user can also provide permissions as a decimal integer, e.g. 511.
*
* This method attempts to guess whether the user provided a decimal or octal integer, and converts to octal if needed,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could make this more reliable by checking the octal representation (reference). Actual modes will normally have the group bits match either the user bits or the other bits (it would be weird to have three different octets). And normally u ≥ g ≥ o and w ≥ r ≥ x right? For example 777 satisfies all constraints whereas 511 in octal would be -r-x--x--x which violates r ≥ x for g/o and is thus technically legal for exotic scenarios but unlikely to be what the user meant.

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

Successfully merging this pull request may close these issues.

3 participants