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

SONAR-23559 Improves editions and versions setting for sonarqube chart #606

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davividal
Copy link
Collaborator

@davividal davividal commented Dec 13, 2024

@davividal davividal requested review from jCOTINEAU and carminevassallo and removed request for jCOTINEAU December 13, 2024 14:31
@carminevassallo carminevassallo force-pushed the dkv/sonar-23559 branch 2 times, most recently from 816a8ee to cfbb48e Compare December 20, 2024 13:41
Copy link
Collaborator

@carminevassallo carminevassallo left a comment

Choose a reason for hiding this comment

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

Hi @davividal,

the basic logic works, I could validate locally 🎉

However, there are a few things that I'd suggest we improve. Please let me know your opinion.

.cirrus/schema_test.sh Show resolved Hide resolved
}
}
},
"allOf": [
Copy link
Collaborator

@carminevassallo carminevassallo Dec 20, 2024

Choose a reason for hiding this comment

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

Based on the acceptance criteria of the task, I think that adding this strong validation of the fields is not required.

Specifically, when edition is set, as of now we always favor this, regardless of whether community.enabled is set or not. The downside of adding the strong validation is to have quite a few warnings (not really meaningful) written when edition is not set.

E.g.

Error: values don't meet the specifications of the schema(s) in the following chart(s):
sonarqube:
- (root): Must validate "then" as "if" was valid
- (root): edition is required
- (root): Must validate all the schemas (allOf)

Only the second warning is really actionable.

Having said that, shall we simplify the validation? wdyt? You might also look at this PR and the usage of the fail-fast mechanism in charts/sonarqube-dce/templates/validation.yaml

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using schema validation and fail will lead to a fail-fast mechanism. Still, I think that fail will clutter the templates by trying to mimic something already available to us through schema validation. :)

As for simplifying the validation, when I was rebasing my PR against master (after merging yours), I (expectedly) got the validation error when running the tests. Despite reviewing your PR, it still took me a couple of minutes to understand and locate the template file. Comparing both solutions side-by-side, I don't think that replacing this with that would improve the clarity.

While I agree that the Helm's output is not ideal, I still think the overall solution is easier to understand and maintain.

WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for clarifying. In my opinion, we should favor the readability of the error above all. While I see that in helm we don't really have standard way to fail-fast, the following two error lines that are shown in the current implementation are "internal" errors and should not be shown.

- (root): Must validate "then" as "if" was valid
- (root): Must validate all the schemas (allOf)

If we follow the "simplified validation", we cleanup the error messages displaying only what's relevant and we don't lose in debugging "power" as there is a clear execution error message pointing to the file, e.g., "Error: execution error at (sonarqube/templates/validation.yaml:2:4)". Furthermore, at the validation-failure stage, the user is not supposed to navigate internally into the chart and debug the failure. If we adopt clear failure messages, the users will be clearly notified about what's wrong and how the deployment can be fixed (e.g., which parameters are not accepted, which ones need to be now provided). My proposal would still be to use the validation through the validation.yaml file, wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you think now, @carminevassallo?

I kept the enum in the values.schema, as the error message seems clear and relevant enough to me:

$ helm template charts/sonarqube -f tests/unit-test/test-cases-values/sonarqube/invalid-edition.yaml --set monitoringPasscode=abc42
Error: values don't meet the specifications of the schema(s) in the following chart(s):
sonarqube:
- edition: edition must be one of the following: "developer", "enterprise"

@davividal davividal force-pushed the dkv/sonar-23559 branch 3 times, most recently from c0667c1 to 4c9df46 Compare January 2, 2025 14:05
Copy link

sonarqube-next bot commented Jan 6, 2025

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 this pull request may close these issues.

2 participants