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

Feat: Add support for arbitrary custom values in regions.json #286

Conversation

johnksv
Copy link
Contributor

@johnksv johnksv commented Oct 14, 2023

Background: As we are developing our services helm charts we need to inject some values per region (values that are not a part of region.json today). We don’t want to make constant changes (and releases) to the onyxia-api (several reasons for that), and a suggestion would therefore be to have a field in regions.json where one can add arbitrary values to be injected/made available into the charts.

Solution proposed in this PR:

Custom values can be added to regions.json via the field "customValues" and will then be accessible in the helm chart.
E.g. in regions.json:

"services":
 
 "customValues": {
    "myCustomKey": "myValue",
    "myNestedCustomKey": {
      "nestedKey": "nestedValue"
    }
  }
}

would result in the properties myCustomKey and myNestedCustomKey.nestedKey being available in the helm chart:
image

Should the field be named customValues or something else?
Does the frontend need any changes to accommodate for this? I guess there might be use cases where these custom values would be configurable?

Custom values can be added to regions.json via the field "customValues" and will then be accessible in the helm chart
@johnksv johnksv force-pushed the feat-support-arbitrary-custom-values branch from 77601a8 to 5ef2dec Compare October 14, 2023 12:59
@@ -240,6 +240,7 @@ private Collection<Object> publishApps(
User user = userProvider.getUser(region);
Map<String, Object> fusion = new HashMap<>();
fusion.putAll((Map<String, Object>) requestDTO.getOptions());
fusion.putAll(region.getServices().getCustomValues());
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sur of this one.
I don't know why we should put that custom values here
@olevitt any thought ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi !

Adding the custom values here does not work as you expect.
This fusion map is supposed to have keys corresponding to the helm package values keys. There is almost no chance that the customValues keys exactly correspond to the helm package values keys.
The mapping between configuration keys and helm package specific keys is done in web app based on x-onyxia specified in values.schema.json file.
So I think this line should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for feedback!

The mapping between configuration keys and helm package specific keys is done in web app based on x-onyxia specified in values.schema.json file.

Do I understand you correctly if you think that the values from customValues should be sent to web such that they can be edited there, @olevitt ?

I would say one approach to providing custom values in regions.json is to do the mapping in API, and not let the user be able to override these custom values.

Copy link
Contributor

@olevitt olevitt left a comment

Choose a reason for hiding this comment

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

Thanks for this PR !

See my 2 comments for small changes

@@ -240,6 +240,7 @@ private Collection<Object> publishApps(
User user = userProvider.getUser(region);
Map<String, Object> fusion = new HashMap<>();
fusion.putAll((Map<String, Object>) requestDTO.getOptions());
fusion.putAll(region.getServices().getCustomValues());
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi !

Adding the custom values here does not work as you expect.
This fusion map is supposed to have keys corresponding to the helm package values keys. There is almost no chance that the customValues keys exactly correspond to the helm package values keys.
The mapping between configuration keys and helm package specific keys is done in web app based on x-onyxia specified in values.schema.json file.
So I think this line should be removed

@@ -65,6 +65,7 @@ Users can work on Onyxia as a User or as a Group to which they belong. Each user
| `quotas` | | Properties setting quotas on how many resources a user can get on the services provider. | See [Quotas properties](#quotas-properties) |
| `defaultConfiguration` | | Default configuration on services that a user can override. For client purposes only. | See [Default Configuration](#default-configuration-properties) |
| `customInitScript` | | This can be used to customize user environments using a regional script executed by some users' pods. | See [CustomInitScript properties](#custom-init-script-properties) |
| `customValues` | | This can be used to specify custom values thath should be avaiable in the underlaying helm chart when a service is launched. Nested values are supported. | ` "customValues": {"myCustomKey": "myValue", "myNestedCustomKey": {"nestedKey": "nestedValue"} }` |
Copy link
Contributor

Choose a reason for hiding this comment

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

typos in thath and underlaying.
I suggest we rephrase with something like :
This can be used to specify custom values that will be available for chart values injection (see catalog documentation). Nested values are supported.

@johnksv
Copy link
Contributor Author

johnksv commented Nov 7, 2023

Sorry for not updating this PR for the last couple of weeks. Other things have been taking my time.. A small update: For us this feature is a must to support multiple environments, so I hope someone on my team, or myself, can put in necessary time to implement this.
If you be want to and have opportunity please feel free to implement this PR.

@olevitt
Copy link
Contributor

olevitt commented Nov 7, 2023

Sorry for not updating this PR for the last couple of weeks. Other things have been taking my time.. A small update: For us this feature is a must to support multiple environments, so I hope someone on my team, or myself, can put in necessary time to implement this. If you be want to and have opportunity please feel free to implement this PR.

Sure. I will take it from here. After that, next step will be on web app

@olevitt olevitt mentioned this pull request Nov 8, 2023
@olevitt
Copy link
Contributor

olevitt commented Nov 8, 2023

Superseeded by #298

@olevitt olevitt closed this Nov 8, 2023
@johnksv johnksv deleted the feat-support-arbitrary-custom-values branch November 16, 2023 15:31
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.

3 participants