Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic setting for DiskCircuitBreaker default disk shortage thre… #1532

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

package org.opensearch.ml.breaker;

import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_DISK_SHORTAGE_THRESHOLD;

import java.io.File;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;

import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.Settings;
import org.opensearch.ml.common.exception.MLException;

/**
Expand All @@ -21,6 +25,7 @@ public class DiskCircuitBreaker extends ThresholdCircuitBreaker<Long> {
public static final long DEFAULT_DISK_SHORTAGE_THRESHOLD = 5L;
private static final long GB = 1024 * 1024 * 1024;
private String diskDir;
private volatile Long diskShortageThreshold = 5L;

public DiskCircuitBreaker(String diskDir) {
super(DEFAULT_DISK_SHORTAGE_THRESHOLD);
Expand All @@ -32,6 +37,13 @@ public DiskCircuitBreaker(long threshold, String diskDir) {
this.diskDir = diskDir;
}

public DiskCircuitBreaker(Settings settings, ClusterService clusterService, String diskDir) {
super(DEFAULT_DISK_SHORTAGE_THRESHOLD);
this.diskDir = diskDir;
this.diskShortageThreshold = ML_COMMONS_DISK_SHORTAGE_THRESHOLD.get(settings);
clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_DISK_SHORTAGE_THRESHOLD, it -> diskShortageThreshold = it);
}

@Override
public String getName() {
return ML_DISK_CB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ private MLCommonsSettings() {}
Setting.Property.Dynamic
);

public static final Setting<Long> ML_COMMONS_DISK_SHORTAGE_THRESHOLD = Setting
.longSetting("plugins.ml_commons.disk_shortage_threshold", 5L, 1L, 10L, Setting.Property.NodeScope, Setting.Property.Dynamic);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about rename the setting name?

Suggested change
.longSetting("plugins.ml_commons.disk_shortage_threshold", 5L, 1L, 10L, Setting.Property.NodeScope, Setting.Property.Dynamic);
.longSetting("plugins.ml_commons.disk_space_threshold", 5L, 1L, 10L, Setting.Property.NodeScope, Setting.Property.Dynamic);

public static final Setting<Boolean> ML_COMMONS_MEMORY_FEATURE_ENABLED = ConversationalIndexConstants.ML_COMMONS_MEMORY_FEATURE_ENABLED;

// Feature flag for enabling search processors for Retrieval Augmented Generation using OpenSearch and Remote Inference.
Expand Down
Loading