Skip to content

Commit

Permalink
Fix defaults for new parameters not considered value change (#120)
Browse files Browse the repository at this point in the history
- Previously adding new paramter with a default on an immutable
  parameter threw an error.
- Add helm values for environment variables.
  • Loading branch information
jkupferer authored Oct 21, 2024
1 parent c8c94c4 commit e917ff8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ spec:
value: "{{ .Values.manageClaimsInterval }}"
- name: MANAGE_HANDLES_INTERVAL
value: "{{ .Values.manageHandlesInterval }}"
- name: MANAGE_POOLS_INTERVAL
value: "{{ .Values.managePoolsInterval }}"
- name: OPERATOR_DOMAIN
value: {{ include "poolboy.operatorDomain" . }}
- name: RESOURCE_REFRESH_INTERVAL
value: "{{ .Values.resourceRefreshInterval }}"
image: "{{ include "poolboy.image" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
Expand Down
2 changes: 2 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ operatorDomain:

manageClaimsInterval: 60
manageHandlesInterval: 60
managePoolsInterval: 10
resourceRefreshInterval: 600

anarchy:
# Control whether anarchy integration should be created
Expand Down
6 changes: 6 additions & 0 deletions operator/resourceclaim.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,16 +942,19 @@ async def validate_with_provider(self,
parameter_states = self.status.get('provider', {}).get('parameterValues')

# Collect parameter values from status and resource provider defaults
parameters_from_defaults = set()
for parameter in resource_provider.get_parameters():
if parameter.name not in parameter_values:
if parameter_states and parameter.name in parameter_states:
parameter_values[parameter.name] = parameter_states[parameter.name]
elif parameter.default_template != None:
parameters_from_defaults.add(parameter.name)
parameter_values[parameter.name] = recursive_process_template_strings(
parameter.default_template,
variables = { **vars_, **parameter_values }
)
elif parameter.default_value != None:
parameters_from_defaults.add(parameter.name)
parameter_values[parameter.name] = parameter.default_value

parameter_names = set()
Expand All @@ -964,6 +967,9 @@ async def validate_with_provider(self,
# Unchanged from current state is automatically considered valid
# even if validation rules have changed.
continue
if parameter.name in parameters_from_defaults:
# New parameter set from default is automatically valid
continue
if not parameter.allow_update:
validation_errors.append(f"Parameter {parameter.name} is immutable.")
continue
Expand Down

0 comments on commit e917ff8

Please sign in to comment.