Skip to content

Conversation

@shakti-das
Copy link
Member

Signed-off-by: Shakti shaktiprakash.das@salesforce.com

Please provide a description for what this PR is for.
Fixes #24258
Adds support for appending to a list via IstioOperator component patch. We (Salesforce) need this feature to append additional containers to Istiod Deployment. This feature will also help in adding additional command/args values to the list instead of the need to replace the entire command/args list.

And to help us figure out who should review this PR, please
put an X in all the areas that this PR affects.

[x] Configuration Infrastructure
[ ] Docs
[x] Installation
[ ] Networking
[ ] Performance and Scalability
[ ] Policies and Telemetry
[ ] Security
[ ] Test and Release
[ ] User Experience
[ ] Developer Infrastructure

Signed-off-by: Shakti <shaktiprakash.das@salesforce.com>
@shakti-das shakti-das requested a review from a team as a code owner June 3, 2020 11:03
@googlebot googlebot added the cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. label Jun 3, 2020
@istio-testing istio-testing added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 3, 2020
@shakti-das
Copy link
Member Author

/ok-to-test

@istio-testing istio-testing added the ok-to-test Set this label allow normal testing to take place for a PR not submitted by an Istio org member. label Jun 3, 2020
@pnambiarsf
Copy link

@howardjohn - Could you please review and approve ?

@GregHanson
Copy link
Member

is appending to the next index the way to create a new leaf? https://istio.io/docs/reference/config/istio.operator.v1alpha1/#K8sObjectOverlay-PathValue

Value to add, delete or replace. For add, the path should be a new leaf.

The provided examples don't show any add examples. Which is standard practice? When referencing a list via overlay, and specifying a new element, should it just be appended to the existing list or overwrite the list with a new single element list?

@shakti-das
Copy link
Member Author

We have indexed based access to a list. So, if the index doesn't exist then adding to the list would make sense. It will be the same behavior that we have with map, i.e, if something is not found then insert, else replace.

To replace the entire list, we can stop before the indexing into the list and that would replace the entire list.

@shakti-das
Copy link
Member Author

shakti-das commented Jun 4, 2020

Please note that prior to the commit d464fb8, this was the pre-existing default behavior for appending to list.

The commit mentioned above added the createMissing flag check for list append logic too:

var foundNode interface{}
if idx >= len(lst) {
if !createMissing {
return nil, false, fmt.Errorf("index %d exceeds list length %d at path %s", idx, len(lst), remainPath)
}
foundNode = make(map[string]interface{})
} else {
foundNode = lst[idx]
}

This is the point where the behavior changed to not append items to list and instead throw error exceeds list length.

@shakti-das
Copy link
Member Author

This change in behavior is currently blocking us from using IstioOperator to deploy Istio.

@istio-testing istio-testing merged commit ca7e72b into istio:master Jun 4, 2020
@shakti-das shakti-das deleted the shakti/append-to-list branch June 5, 2020 07:47
nschhina pushed a commit to nschhina/istio that referenced this pull request Jun 18, 2020
Signed-off-by: Shakti <shaktiprakash.das@salesforce.com>
@toonsevrin
Copy link
Contributor

Is there a way to blindly add based on a key? eg. path: spec.template.spec.containers.[name:my_sidecar] instead of using an index?

Using an index hardly seems safe as it may override a sidecar that is added during an istio upgrade.

@shakti-das
Copy link
Member Author

It could still override the sidecar if name:my_sidecar already exists.

@toonsevrin
Copy link
Contributor

Also true, I've just played around and seems like using a very high index is permitted, I'll just do that, consider this question resolved 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. ok-to-test Set this label allow normal testing to take place for a PR not submitted by an Istio org member. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Appending to list via IstioOperator spec

8 participants