aws-secret-sidecar-injector icon indicating copy to clipboard operation
aws-secret-sidecar-injector copied to clipboard

fix admission controller's podsInitContainerPatch

Open gueux opened this issue 3 years ago • 2 comments

Admission Controller can't succesfully patch the pods spec in case you deploy deployments sequence with mixed initContainers definition: some of them has initContainers, some not. In this case admission controller successfully apply patch to pods without initContainer and then never apply patch to pods with initContainers defined.

It produce next error in ReplicaSet:

Warning  FailedCreate  13m (x19 over 24m)  replicaset-controller  Error creating: Internal error occurred: invalid character '}' after array element

This MR avoid overriding global variable podsInitPatch after first patch applying

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

gueux avatar Jul 07 '21 17:07 gueux

@amit0701 didn't you already update the code to inject secrets into init containers? From what I recall, you iterate through and patch all of the init containers if the length of the array/slice is not 0. Can you have a look at this PR?

jicowan avatar Jul 19 '21 22:07 jicowan

@jicowan Yes, there was a patch to start secret injector as a first initContainer: https://github.com/aws-samples/aws-secret-sidecar-injector/pull/51 But my MR fixes advanced issue, when you have multiply Deployments with initContainers and without ones.

gueux avatar Sep 28 '21 11:09 gueux