Skip to content

Commit

Permalink
Merge pull request #356 from frezes/bugfix/rulerOptions
Browse files Browse the repository at this point in the history
fix rulerOptions missing dataVolume
  • Loading branch information
benjaminhuo authored Sep 14, 2023
2 parents 6373a06 + e7052d4 commit ef731a0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/whizard/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ maintainers:
email: [email protected]
- name: junot
email: [email protected]
version: 0.9.2
version: 0.9.3
appVersion: "latest"
3 changes: 2 additions & 1 deletion charts/whizard/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ controllerManager:
fsGroup: 0

dataVolume:
emptyDir: {}
emptyDir:
sizeLimit: 500Mi # The size limit of emptyDir volume.

prometheusConfigReloader:
image:
Expand Down
6 changes: 6 additions & 0 deletions pkg/controllers/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func newTestConfig() (*Config, error) {
var stabilizationWindowSeconds int32 = 300
var cpuAverageUtilization int32 = 80
var memAverageUtilization int32 = 80
var sizeLimit = resource.MustParse("500Mi")
var conf = &Config{
KubernetesOptions: &k8s.KubernetesOptions{
KubeConfig: "/Users/frezes/.kube/config",
Expand Down Expand Up @@ -173,6 +174,11 @@ func newTestConfig() (*Config, error) {
LogLevel: "info",
LogFormat: "logfmt",
},
DataVolume: &v1alpha1.KubernetesVolume{
EmptyDir: &corev1.EmptyDirVolumeSource{
SizeLimit: &sizeLimit,
},
},
PrometheusConfigReloader: options.SidecarOptions{
Image: "kubesphere/prometheus-config-reloader:v0.55.1",
Resources: corev1.ResourceRequirements{
Expand Down
22 changes: 22 additions & 0 deletions pkg/controllers/monitoring/options/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ func (o *RouterOptions) AddFlags(fs *pflag.FlagSet, ro *RouterOptions) {
type RulerOptions struct {
CommonOptions `json:",inline" yaml:",inline" mapstructure:",squash"`

DataVolume *v1alpha1.KubernetesVolume `json:"dataVolume,omitempty" yaml:"dataVolume,omitempty"`

PrometheusConfigReloader SidecarOptions `json:"prometheusConfigReloader,omitempty" yaml:"prometheusConfigReloader,omitempty"`
RulerQueryProxy SidecarOptions `json:"rulerQueryProxy" yaml:"rulerQueryProxy,omitempty"`
RulerWriteProxy SidecarOptions `json:"rulerWriteProxy" yaml:"rulerWriteProxy,omitempty"`
Expand Down Expand Up @@ -546,6 +548,22 @@ func (o *RulerOptions) ApplyTo(options *RulerOptions) {
o.RulerQueryProxy.ApplyTo(&options.RulerQueryProxy)
o.RulerWriteProxy.ApplyTo(&options.RulerWriteProxy)

if o.DataVolume != nil {
if options.DataVolume == nil {
options.DataVolume = o.DataVolume
} else {
if o.DataVolume.PersistentVolumeClaim != nil {
options.DataVolume.PersistentVolumeClaim = o.DataVolume.PersistentVolumeClaim
}
if o.DataVolume.PersistentVolumeClaimRetentionPolicy != nil {
options.DataVolume.PersistentVolumeClaimRetentionPolicy = o.DataVolume.PersistentVolumeClaimRetentionPolicy
}
if o.DataVolume.EmptyDir != nil {
options.DataVolume.EmptyDir = o.DataVolume.EmptyDir
}
}
}

if *o.Shards != 0 {
options.Shards = o.Shards
}
Expand Down Expand Up @@ -580,6 +598,10 @@ func (o *RulerOptions) Override(spec *v1alpha1.RulerSpec) {
o.PrometheusConfigReloader.Override(&spec.PrometheusConfigReloader)
o.RulerQueryProxy.Override(&spec.RulerQueryProxy)

if spec.DataVolume == nil {
spec.DataVolume = o.DataVolume
}

if spec.Shards == nil {
spec.Shards = o.Shards
}
Expand Down

0 comments on commit ef731a0

Please sign in to comment.