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

Fix defaults for new parameters not considered value change #120

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading