Skip to content

Commit

Permalink
Fix pod version fault-tolerance issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhiguo committed Jul 2, 2024
1 parent 8d7291c commit c4749be
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/mutation/mutation_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mutation
import (
"encoding/json"
"fmt"
"go.uber.org/zap"
"net/http"
"strings"

Expand Down Expand Up @@ -164,7 +165,14 @@ func addPodInitContainer(targetPod *corev1.Pod, envs []corev1.EnvVar, deployment
}
agentVersion := config.DefaultInjectorConfig.AgentConfig.Version
if av, ok := targetPod.Labels[config.AgentVersionLabel]; ok {
agentVersion = av
if v, ok := config.InjectorAgentVersion[av]; ok {
_, configExists := config.InjectorConfigMaps[v.ConfigMapName]
if v.Enable && configExists {
agentVersion = v.Version
log.Info("[mutation] injection-pod: Inject the specified version to pod",
zap.String("pod", targetPod.Name), zap.String("version", agentVersion))
}
}
}
agentInitContainer := &corev1.Container{
Name: config.InitContainerName,
Expand Down

0 comments on commit c4749be

Please sign in to comment.