|
9 | 9 | "fmt" |
10 | 10 | "regexp" |
11 | 11 | "sort" |
| 12 | + "strings" |
12 | 13 |
|
13 | 14 | autoscalev2beta2 "k8s.io/api/autoscaling/v2beta2" |
14 | 15 | networkingv1 "k8s.io/api/networking/v1" |
@@ -1138,6 +1139,21 @@ func getVolume(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, nodeSpecUniq |
1138 | 1139 | return volumesHolder |
1139 | 1140 | } |
1140 | 1141 |
|
| 1142 | +func getCommand(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []string { |
| 1143 | + if (m.Spec.StartScript != "" && m.Spec.EntryArg != "") { |
| 1144 | + return []string{m.Spec.StartScript} |
| 1145 | + } |
| 1146 | + return []string{firstNonEmptyStr(m.Spec.StartScript, "bin/run-druid.sh"), nodeSpec.NodeType} |
| 1147 | +} |
| 1148 | + |
| 1149 | +func getEntryArg(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []string { |
| 1150 | + if (m.Spec.EntryArg != "") { |
| 1151 | + bashCommands := strings.Join([]string{m.Spec.EntryArg, "&&", firstNonEmptyStr(m.Spec.DruidScript, "bin/run-druid.sh"), nodeSpec.NodeType}, " ") |
| 1152 | + return []string{"-c", bashCommands} |
| 1153 | + } |
| 1154 | + return nil |
| 1155 | +} |
| 1156 | + |
1141 | 1157 | func getEnv(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, configMapSHA string) []v1.EnvVar { |
1142 | 1158 | envHolder := firstNonNilValue(nodeSpec.Env, m.Spec.Env).([]v1.EnvVar) |
1143 | 1159 | // enables to do the trick to force redeployment in case of configmap changes. |
@@ -1312,7 +1328,8 @@ func makePodSpec(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, nodeSpecUn |
1312 | 1328 | { |
1313 | 1329 | Image: firstNonEmptyStr(nodeSpec.Image, m.Spec.Image), |
1314 | 1330 | Name: fmt.Sprintf("%s", nodeSpecUniqueStr), |
1315 | | - Command: []string{firstNonEmptyStr(m.Spec.StartScript, "bin/run-druid.sh"), nodeSpec.NodeType}, |
| 1331 | + Command: getCommand(nodeSpec, m), |
| 1332 | + Args: getEntryArg(nodeSpec, m), |
1316 | 1333 | ImagePullPolicy: v1.PullPolicy(firstNonEmptyStr(string(nodeSpec.ImagePullPolicy), string(m.Spec.ImagePullPolicy))), |
1317 | 1334 | Ports: nodeSpec.Ports, |
1318 | 1335 | Resources: nodeSpec.Resources, |
|
0 commit comments