Skip to content

Commit 3636f7f

Browse files
committed
fix fluentbit changes nixed fluentd setup.
1 parent 8e7a45b commit 3636f7f

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

operator/src/main/java/oracle/kubernetes/operator/helpers/BasePodStepContext.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,8 @@ protected V1ResourceRequirements createResources() {
221221
}
222222

223223
protected V1PodSpec createPodSpec() {
224-
return new V1PodSpec()
224+
V1PodSpec podSpec = new V1PodSpec()
225225
.containers(getContainers())
226-
.volumes(getFluentdVolumes())
227-
.volumes(getFluentbitVolumes())
228226
.addContainersItem(createPrimaryContainer())
229227
.affinity(getServerSpec().getAffinity())
230228
.topologySpreadConstraints(getTopologySpreadConstraints())
@@ -239,6 +237,16 @@ protected V1PodSpec createPodSpec() {
239237
.restartPolicy(getServerSpec().getRestartPolicy())
240238
.securityContext(getPodSecurityContext())
241239
.imagePullSecrets(getServerSpec().getImagePullSecrets());
240+
241+
for (V1Volume additionalVolume : getFluentdVolumes()) {
242+
podSpec.addVolumesItem(additionalVolume);
243+
}
244+
245+
for (V1Volume additionalVolume : getFluentbitVolumes()) {
246+
podSpec.addVolumesItem(additionalVolume);
247+
}
248+
249+
return podSpec;
242250
}
243251

244252
abstract V1PodSecurityContext getPodSecurityContext();

operator/src/test/java/oracle/kubernetes/operator/helpers/JobHelperTest.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@
113113
import static oracle.kubernetes.operator.helpers.PodHelperTestBase.createSecretKeyRefEnvVar;
114114
import static oracle.kubernetes.operator.helpers.PodHelperTestBase.createSecurityContext;
115115
import static oracle.kubernetes.operator.helpers.PodHelperTestBase.createToleration;
116+
import static oracle.kubernetes.operator.helpers.StepContextConstants.FLUENTBIT_CONFIGMAP_VOLUME;
116117
import static oracle.kubernetes.operator.helpers.StepContextConstants.FLUENTD_CONFIGMAP_NAME_SUFFIX;
118+
import static oracle.kubernetes.operator.helpers.StepContextConstants.FLUENTD_CONFIGMAP_VOLUME;
117119
import static oracle.kubernetes.operator.helpers.StepContextConstants.FLUENTD_CONFIG_DATA_NAME;
118120
import static oracle.kubernetes.operator.helpers.StepContextConstants.FLUENTD_CONTAINER_NAME;
119121
import static oracle.kubernetes.operator.helpers.StepContextConstants.INIT_DOMAIN_ON_PV_CONTAINER;
@@ -500,6 +502,46 @@ void whenFluentdWatchIntrospectLogsEnable_jobPodShouldHaveFluentdSidecar() {
500502

501503
}
502504

505+
@Test
506+
void whenFluentdWatchIntrospectLogsEnable_jobPodShouldHaveFluentdVolume() {
507+
configureDomain().withFluentdConfiguration(true, "dummy-cred",
508+
null, null, null);
509+
510+
V1JobSpec jobSpec = createJobSpec();
511+
512+
Optional<Object> list = Optional.ofNullable(jobSpec)
513+
.map(V1JobSpec::getTemplate)
514+
.map(V1PodTemplateSpec::getSpec)
515+
.map(V1PodSpec::getVolumes)
516+
.map(c -> c.isEmpty() ? null : c.stream().filter(v -> v.getName()
517+
.equals(FLUENTD_CONFIGMAP_VOLUME)).findAny().orElse(null));
518+
519+
assertThat(list, notNullValue());
520+
521+
assertThat(list, not(Optional.empty()));
522+
523+
}
524+
525+
@Test
526+
void whenFluentbitWatchIntrospectLogsEnable_jobPodShouldHaveFluentbitVolume() {
527+
configureDomain().withFluentbitConfiguration(true,"dummy-cred", "",
528+
"", null,null);
529+
530+
V1JobSpec jobSpec = createJobSpec();
531+
532+
Optional<Object> list = Optional.ofNullable(jobSpec)
533+
.map(V1JobSpec::getTemplate)
534+
.map(V1PodTemplateSpec::getSpec)
535+
.map(V1PodSpec::getVolumes)
536+
.map(c -> c.isEmpty() ? null : c.stream().filter(v -> v.getName()
537+
.equals(FLUENTBIT_CONFIGMAP_VOLUME)).findAny().orElse(null));
538+
539+
assertThat(list, notNullValue());
540+
541+
assertThat(list, not(Optional.empty()));
542+
543+
}
544+
503545
@Test
504546
void whenFluentdWatchIntrospectLogsDisable_jobPodShouldHaveFluentdSidecar() {
505547
configureDomain().withFluentdConfiguration(false, "dummy-cred",
@@ -516,6 +558,7 @@ void whenFluentdWatchIntrospectLogsDisable_jobPodShouldHaveFluentdSidecar() {
516558

517559
}
518560

561+
519562
@Test
520563
void whenNoFluentdConfigmap_createIt() {
521564
configureDomain().withFluentdConfiguration(false, "dummy-cred",

0 commit comments

Comments
 (0)