Skip to content

Commit fbeb6cd

Browse files
vlsingle, vmsingle: do not mount emptyDir if data volume is present in
1 parent 8272559 commit fbeb6cd

File tree

8 files changed

+527
-375
lines changed

8 files changed

+527
-375
lines changed

api/operator/v1/vlagent_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ type VLAgentSpec struct {
5555
// PodDisruptionBudget created by operator
5656
// +optional
5757
PodDisruptionBudget *vmv1beta1.EmbeddedPodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
58-
// StatefulStorage configures storage for StatefulSet
58+
// Storage configures storage for StatefulSet
5959
// +optional
6060
Storage *vmv1beta1.StorageSpec `json:"storage,omitempty"`
61-
// StatefulRollingUpdateStrategy allows configuration for strategyType
61+
// RollingUpdateStrategy allows configuration for strategyType
6262
// set it to RollingUpdate for disabling operator statefulSet rollingUpdate
6363
// +optional
6464
RollingUpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"rollingUpdateStrategy,omitempty"`

config/crd/overlay/crd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ spec:
12551255
type: integer
12561256
rollingUpdateStrategy:
12571257
description: |-
1258-
StatefulRollingUpdateStrategy allows configuration for strategyType
1258+
RollingUpdateStrategy allows configuration for strategyType
12591259
set it to RollingUpdate for disabling operator statefulSet rollingUpdate
12601260
type: string
12611261
runtimeClassName:
@@ -1345,7 +1345,7 @@ spec:
13451345
type: object
13461346
x-kubernetes-preserve-unknown-fields: true
13471347
storage:
1348-
description: StatefulStorage configures storage for StatefulSet
1348+
description: Storage configures storage for StatefulSet
13491349
properties:
13501350
disableMountSubPath:
13511351
description: |-

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ aliases:
1414
## tip
1515

1616
* FEATURE: [converter](https://docs.victoriametrics.com/operator/integrations/prometheus/#objects-conversion): support `spec.limit`, `spec.labels`, `spec.query_offset` and `spec.group[*].keep_firing_for` PrometheusRule properties conversion to VMRule. Related issue [#1485](https://github.com/VictoriaMetrics/operator/issues/1485).
17+
* BUGFIX: [vmsingle](https://docs.victoriametrics.com/operator/resources/vmsingle/) and [vlsingle](https://docs.victoriametrics.com/operator/resources/vlsingle/): do not mount emptydir if storage data volume is already present in volumes list. Now it's impossible to mount external PVC without overriding default storageDataPath using `spec.extraArgs` and without having unneeded emptydir listed among pod volumes. Related issues [#1477](https://github.com/VictoriaMetrics/operator/issues/1477).
1718
* BUGFIX: [config-reloader](https://github.com/VictoriaMetrics/operator/tree/master/cmd/config-reloader): fixed config reloader command line arguments override. Related issue [#1378](https://github.com/VictoriaMetrics/operator/issues/1478).
1819

1920
## [v0.61.2](https://github.com/VictoriaMetrics/operator/releases/tag/v0.61.2)

docs/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ Appears in: [VLAgent](#vlagent)
251251
| replicaCount<a href="#vlagentspec-replicacount" id="vlagentspec-replicacount">#</a><br/>_integer_ | _(Optional)_<br/>ReplicaCount is the expected size of the Application. |
252252
| resources<a href="#vlagentspec-resources" id="vlagentspec-resources">#</a><br/>_[ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core)_ | _(Optional)_<br/>Resources container resource request and limits, https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/<br />if not defined default resources from operator config will be used |
253253
| revisionHistoryLimitCount<a href="#vlagentspec-revisionhistorylimitcount" id="vlagentspec-revisionhistorylimitcount">#</a><br/>_integer_ | _(Optional)_<br/>The number of old ReplicaSets to retain to allow rollback in deployment or<br />maximum number of revisions that will be maintained in the Deployment revision history.<br />Has no effect at StatefulSets<br />Defaults to 10. |
254-
| rollingUpdateStrategy<a href="#vlagentspec-rollingupdatestrategy" id="vlagentspec-rollingupdatestrategy">#</a><br/>_[StatefulSetUpdateStrategyType](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetupdatestrategytype-v1-apps)_ | _(Optional)_<br/>StatefulRollingUpdateStrategy allows configuration for strategyType<br />set it to RollingUpdate for disabling operator statefulSet rollingUpdate |
254+
| rollingUpdateStrategy<a href="#vlagentspec-rollingupdatestrategy" id="vlagentspec-rollingupdatestrategy">#</a><br/>_[StatefulSetUpdateStrategyType](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetupdatestrategytype-v1-apps)_ | _(Optional)_<br/>RollingUpdateStrategy allows configuration for strategyType<br />set it to RollingUpdate for disabling operator statefulSet rollingUpdate |
255255
| runtimeClassName<a href="#vlagentspec-runtimeclassname" id="vlagentspec-runtimeclassname">#</a><br/>_string_ | _(Optional)_<br/>RuntimeClassName - defines runtime class for kubernetes pod.<br />https://kubernetes.io/docs/concepts/containers/runtime-class/ |
256256
| schedulerName<a href="#vlagentspec-schedulername" id="vlagentspec-schedulername">#</a><br/>_string_ | _(Optional)_<br/>SchedulerName - defines kubernetes scheduler name |
257257
| secrets<a href="#vlagentspec-secrets" id="vlagentspec-secrets">#</a><br/>_string array_ | _(Optional)_<br/>Secrets is a list of Secrets in the same namespace as the Application<br />object, which shall be mounted into the Application container<br />at /etc/vm/secrets/SECRET_NAME folder |
258258
| securityContext<a href="#vlagentspec-securitycontext" id="vlagentspec-securitycontext">#</a><br/>_[SecurityContext](#securitycontext)_ | _(Optional)_<br/>SecurityContext holds pod-level security attributes and common container settings.<br />This defaults to the default PodSecurityContext. |
259259
| serviceAccountName<a href="#vlagentspec-serviceaccountname" id="vlagentspec-serviceaccountname">#</a><br/>_string_ | _(Optional)_<br/>ServiceAccountName is the name of the ServiceAccount to use to run the pods |
260260
| serviceScrapeSpec<a href="#vlagentspec-servicescrapespec" id="vlagentspec-servicescrapespec">#</a><br/>_[VMServiceScrapeSpec](#vmservicescrapespec)_ | _(Optional)_<br/>ServiceScrapeSpec that will be added to vlagent VMServiceScrape spec |
261261
| serviceSpec<a href="#vlagentspec-servicespec" id="vlagentspec-servicespec">#</a><br/>_[AdditionalServiceSpec](#additionalservicespec)_ | _(Optional)_<br/>ServiceSpec that will be added to vlagent service spec |
262-
| storage<a href="#vlagentspec-storage" id="vlagentspec-storage">#</a><br/>_[StorageSpec](#storagespec)_ | _(Optional)_<br/>StatefulStorage configures storage for StatefulSet |
262+
| storage<a href="#vlagentspec-storage" id="vlagentspec-storage">#</a><br/>_[StorageSpec](#storagespec)_ | _(Optional)_<br/>Storage configures storage for StatefulSet |
263263
| syslogSpec<a href="#vlagentspec-syslogspec" id="vlagentspec-syslogspec">#</a><br/>_[SyslogServerSpec](#syslogserverspec)_ | _(Optional)_<br/>SyslogSpec defines syslog listener configuration |
264264
| terminationGracePeriodSeconds<a href="#vlagentspec-terminationgraceperiodseconds" id="vlagentspec-terminationgraceperiodseconds">#</a><br/>_integer_ | _(Optional)_<br/>TerminationGracePeriodSeconds period for container graceful termination |
265265
| tolerations<a href="#vlagentspec-tolerations" id="vlagentspec-tolerations">#</a><br/>_[Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#toleration-v1-core) array_ | _(Optional)_<br/>Tolerations If specified, the pod's tolerations. |

internal/controller/operator/factory/build/container.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,3 +535,47 @@ func AddSyslogTLSConfigToVolumes(dstVolumes []corev1.Volume, dstMounts []corev1.
535535
}
536536
return dstVolumes, dstMounts
537537
}
538+
539+
func StorageVolumeMountsTo(volumes []corev1.Volume, mounts []corev1.VolumeMount, pvcSrc *corev1.PersistentVolumeClaimVolumeSource, volumeName, storagePath string) ([]corev1.Volume, []corev1.VolumeMount) {
540+
var alreadyMounted bool
541+
for _, volumeMount := range mounts {
542+
if volumeMount.Name == volumeName {
543+
alreadyMounted = true
544+
break
545+
}
546+
}
547+
if !alreadyMounted {
548+
mounts = append(mounts, corev1.VolumeMount{
549+
Name: volumeName,
550+
MountPath: storagePath,
551+
})
552+
}
553+
if pvcSrc != nil {
554+
volumes = append(volumes, corev1.Volume{
555+
Name: volumeName,
556+
VolumeSource: corev1.VolumeSource{
557+
PersistentVolumeClaim: pvcSrc,
558+
},
559+
})
560+
return volumes, mounts
561+
}
562+
563+
var volumePresent bool
564+
for _, volume := range volumes {
565+
if volume.Name == volumeName {
566+
volumePresent = true
567+
break
568+
}
569+
}
570+
if volumePresent {
571+
return volumes, mounts
572+
}
573+
574+
volumes = append(volumes, corev1.Volume{
575+
Name: volumeName,
576+
VolumeSource: corev1.VolumeSource{
577+
EmptyDir: &corev1.EmptyDirVolumeSource{},
578+
},
579+
})
580+
return volumes, mounts
581+
}

0 commit comments

Comments
 (0)