Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasy-yzj committed Aug 12, 2024
1 parent 4168425 commit dcd4689
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/controller/instanceset/in_place_update_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,17 @@ func getPodUpdatePolicy(its *workloads.InstanceSet, pod *corev1.Pod) (PodUpdateP
return NoOpsPolicy, nil
}

func isContainerInjected(ocs, ncs []corev1.Container) bool {
for _, nc := range ncs {
index := slices.IndexFunc(ocs, func(oc corev1.Container) bool {
return nc.Name == oc.Name
// These lines're used for scenarios that user have other controllers/webhooks like OpenKruise SidecarSet running.
// It'll mutate the pod to inject custom containers (e.g. sidecars) in. InstanceSet will tolerate these behaviors and avoid pod recreation if additional containers're injected.
func isContainerInjected(cur, expect []corev1.Container) bool {
for _, ec := range expect {
index := slices.IndexFunc(cur, func(cc corev1.Container) bool {
return ec.Name == cc.Name
})
if index < 0 {
return false
}
if nc.Image != ocs[index].Image {
if ec.Image != cur[index].Image {
return false
}
}
Expand Down

0 comments on commit dcd4689

Please sign in to comment.