@@ -325,11 +325,6 @@ func TestFluentdAggregator_ConfigChecks(t *testing.T) {
325
325
},
326
326
},
327
327
Workers : 1 ,
328
- Security : & v1beta1.Security {
329
- SecurityContext : & corev1.SecurityContext {
330
- ReadOnlyRootFilesystem : utils .BoolPointer (true ),
331
- },
332
- },
333
328
},
334
329
},
335
330
}
@@ -464,3 +459,174 @@ func TestFluentdAggregator_ConfigChecks(t *testing.T) {
464
459
common .RequireNoError (t , rbacv1 .AddToScheme (o .Scheme ))
465
460
})
466
461
}
462
+ func TestFluentdAggregator_ConfigChecks_WhenReadOnlyRootFilesystemIsConfigured (t * testing.T ) {
463
+ common .Initialize (t )
464
+ ns := "testing-3"
465
+ releaseNameOverride := "e2e"
466
+ outputName := "test-output"
467
+ flowName := "test-flow"
468
+ common .WithCluster ("fluentd-configcheck-readonly-root-filesystem" , t , func (t * testing.T , c common.Cluster ) {
469
+ setup .LoggingOperator (t , c , setup .LoggingOperatorOptionFunc (func (options * setup.LoggingOperatorOptions ) {
470
+ options .Namespace = ns
471
+ options .NameOverride = releaseNameOverride
472
+ }))
473
+
474
+ ctx := context .Background ()
475
+
476
+ logging := v1beta1.Logging {
477
+ ObjectMeta : metav1.ObjectMeta {
478
+ Name : "fluentd-aggregator-configchecks-test" ,
479
+ Namespace : ns ,
480
+ },
481
+ Spec : v1beta1.LoggingSpec {
482
+ EnableRecreateWorkloadOnImmutableFieldChange : true ,
483
+ ControlNamespace : ns ,
484
+ FluentbitSpec : & v1beta1.FluentbitSpec {
485
+ Network : & v1beta1.FluentbitNetwork {
486
+ Keepalive : utils .BoolPointer (false ),
487
+ },
488
+ ConfigHotReload : & v1beta1.HotReload {
489
+ Image : v1beta1.ImageSpec {
490
+ Repository : common .ConfigReloaderRepo ,
491
+ Tag : common .ConfigReloaderTag ,
492
+ },
493
+ },
494
+ BufferVolumeImage : v1beta1.ImageSpec {
495
+ Repository : common .NodeExporterRepo ,
496
+ Tag : common .NodeExporterTag ,
497
+ },
498
+ },
499
+ FluentdSpec : & v1beta1.FluentdSpec {
500
+ Image : v1beta1.ImageSpec {
501
+ Repository : common .FluentdImageRepo ,
502
+ Tag : common .FluentdImageTag ,
503
+ },
504
+ ConfigReloaderImage : v1beta1.ImageSpec {
505
+ Repository : common .ConfigReloaderRepo ,
506
+ Tag : common .ConfigReloaderTag ,
507
+ },
508
+ BufferVolumeImage : v1beta1.ImageSpec {
509
+ Repository : common .NodeExporterRepo ,
510
+ Tag : common .NodeExporterTag ,
511
+ },
512
+ Resources : corev1.ResourceRequirements {
513
+ Limits : corev1.ResourceList {
514
+ corev1 .ResourceCPU : resource .MustParse ("500m" ),
515
+ corev1 .ResourceMemory : resource .MustParse ("200M" ),
516
+ },
517
+ Requests : corev1.ResourceList {
518
+ corev1 .ResourceCPU : resource .MustParse ("250m" ),
519
+ corev1 .ResourceMemory : resource .MustParse ("50M" ),
520
+ },
521
+ },
522
+ BufferVolumeMetrics : & v1beta1.Metrics {},
523
+ Scaling : & v1beta1.FluentdScaling {
524
+ Replicas : 1 ,
525
+ Drain : v1beta1.FluentdDrainConfig {
526
+ Enabled : true ,
527
+ Image : v1beta1.ImageSpec {
528
+ Repository : common .FluentdDrainWatchRepo ,
529
+ Tag : common .FluentdDrainWatchTag ,
530
+ },
531
+ },
532
+ },
533
+ Workers : 1 ,
534
+ Security : & v1beta1.Security {
535
+ SecurityContext : & corev1.SecurityContext {
536
+ ReadOnlyRootFilesystem : utils .BoolPointer (true ),
537
+ },
538
+ },
539
+ },
540
+ },
541
+ }
542
+ common .RequireNoError (t , c .GetClient ().Create (ctx , & logging ))
543
+ output := v1beta1.Output {
544
+ ObjectMeta : metav1.ObjectMeta {
545
+ Name : outputName ,
546
+ Namespace : ns ,
547
+ },
548
+ Spec : v1beta1.OutputSpec {
549
+ FileOutput : & output.FileOutputConfig {
550
+ Path : "/tmp/logs/${tag}/%Y/%m/%d.%H.%M" ,
551
+ Append : true ,
552
+ Buffer : & output.Buffer {
553
+ Type : "file" ,
554
+ Timekey : "1m" ,
555
+ TimekeyWait : "10s" ,
556
+ },
557
+ },
558
+ },
559
+ }
560
+
561
+ producerLabels := map [string ]string {
562
+ "my-unique-label" : "log-producer" ,
563
+ }
564
+
565
+ common .RequireNoError (t , c .GetClient ().Create (ctx , & output ))
566
+ flow := v1beta1.Flow {
567
+ ObjectMeta : metav1.ObjectMeta {
568
+ Name : flowName ,
569
+ Namespace : ns ,
570
+ },
571
+ Spec : v1beta1.FlowSpec {
572
+ Match : []v1beta1.Match {
573
+ {
574
+ Select : & v1beta1.Select {
575
+ Labels : producerLabels ,
576
+ },
577
+ },
578
+ },
579
+ LocalOutputRefs : []string {output .Name },
580
+ },
581
+ }
582
+ common .RequireNoError (t , c .GetClient ().Create (ctx , & flow ))
583
+
584
+ aggregatorLabels := map [string ]string {
585
+ "app.kubernetes.io/name" : "fluentd" ,
586
+ "app.kubernetes.io/component" : "fluentd" ,
587
+ }
588
+ operatorLabels := map [string ]string {
589
+ "app.kubernetes.io/name" : releaseNameOverride ,
590
+ }
591
+
592
+ go setup .LogProducer (t , c .GetClient (), setup .LogProducerOptionFunc (func (options * setup.LogProducerOptions ) {
593
+ options .Namespace = ns
594
+ options .Labels = producerLabels
595
+ }))
596
+
597
+ require .Eventually (t , func () bool {
598
+ if operatorRunning := cond .AnyPodShouldBeRunning (t , c .GetClient (), client .MatchingLabels (operatorLabels ))(); ! operatorRunning {
599
+ t .Log ("waiting for the operator" )
600
+ return false
601
+ }
602
+ if producerRunning := cond .AnyPodShouldBeRunning (t , c .GetClient (), client .MatchingLabels (producerLabels ))(); ! producerRunning {
603
+ t .Log ("waiting for the producer" )
604
+ return false
605
+ }
606
+ if aggregatorRunning := cond .AnyPodShouldBeRunning (t , c .GetClient (), client .MatchingLabels (aggregatorLabels )); ! aggregatorRunning () {
607
+ t .Log ("waiting for the aggregator" )
608
+ return false
609
+ }
610
+
611
+ return logging .Status .ProblemsCount == 0
612
+ }, 5 * time .Minute , 3 * time .Second )
613
+ }, func (t * testing.T , c common.Cluster ) error {
614
+ path := filepath .Join (TestTempDir , fmt .Sprintf ("cluster-%s.log" , t .Name ()))
615
+ t .Logf ("Printing cluster logs to %s" , path )
616
+ return c .PrintLogs (common.PrintLogConfig {
617
+ Namespaces : []string {ns , "default" },
618
+ FilePath : path ,
619
+ Limit : 100 * 1000 ,
620
+ })
621
+ }, func (o * cluster.Options ) {
622
+ if o .Scheme == nil {
623
+ o .Scheme = runtime .NewScheme ()
624
+ }
625
+ common .RequireNoError (t , v1beta1 .AddToScheme (o .Scheme ))
626
+ common .RequireNoError (t , apiextensionsv1 .AddToScheme (o .Scheme ))
627
+ common .RequireNoError (t , appsv1 .AddToScheme (o .Scheme ))
628
+ common .RequireNoError (t , batchv1 .AddToScheme (o .Scheme ))
629
+ common .RequireNoError (t , corev1 .AddToScheme (o .Scheme ))
630
+ common .RequireNoError (t , rbacv1 .AddToScheme (o .Scheme ))
631
+ })
632
+ }
0 commit comments