Skip to content

Commit

Permalink
CORE-2011 Add tools.default_selected_max_cpus config
Browse files Browse the repository at this point in the history
Updated the app launch form to use the tools.default_selected_max_cpus
config value when no default max is returned by the API.
  • Loading branch information
psarando committed Sep 30, 2024
1 parent f406be6 commit 1238e0b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ module.exports = withBundleAnalyzer({
SESSION_POLL_INTERVAL_MS: config.has("sessions.poll_interval_ms")
? config.get("sessions.poll_interval_ms")
: 5000,
TOOLS_DEFAULT_SELECTED_MAX_CPUS: config.has(
"tools.default_selected_max_cpus"
)
? config.get("tools.default_selected_max_cpus")
: 4,
TOOLS_ADMIN_MAX_CPU_LIMIT: config.has("tools.admin.max_cpu_limit")
? config.get("tools.admin.max_cpu_limit")
: 8,
Expand Down
7 changes: 4 additions & 3 deletions src/components/apps/launch/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ const initAppLaunchValues = (
notify,
notifyPeriodic,
periodicPeriod,
defaultMaxCpuCores = 4,
defaultSelectedMaxCpus,
defaultMaxCpuCores = defaultSelectedMaxCpus,
defaultOutputDir,
app: { id, version_id, system_id, name, requirements, groups },
}
) => {
// If no default_max_cpu_cores is returned from the API,
// then use the default from params (if it's less than the actual max)
// so the max is not automatically selected in the launch form.
// then use the default from configs (if it's less than the actual max)
// so the max is not automatically submitted by the services.
const reqInitValues = requirements?.map(
({
step_number,
Expand Down
2 changes: 2 additions & 0 deletions src/components/apps/launch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const Launch = ({
const notifyPeriodic = !!preferences?.enablePeriodicEmailNotification;
const periodicPeriod = preferences?.periodicNotificationPeriod || 14400;

const defaultSelectedMaxCpus = config?.tools?.default_selected_max_cpus;
const defaultMaxCPUCores = config?.tools?.private.max_cpu_limit;
const defaultMaxMemory = config?.tools?.private.max_memory_limit;
const defaultMaxDiskSpace = config?.tools?.private.max_disk_limit;
Expand Down Expand Up @@ -148,6 +149,7 @@ const Launch = ({
defaultMaxCPUCores={defaultMaxCPUCores}
defaultMaxMemory={defaultMaxMemory}
defaultMaxDiskSpace={defaultMaxDiskSpace}
defaultSelectedMaxCpus={defaultSelectedMaxCpus}
app={app}
appError={submissionError}
loading={loading}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ function MyApp({ Component, pageProps }) {
poll_interval_ms: publicRuntimeConfig.SESSION_POLL_INTERVAL_MS,
};
const tools = {
default_selected_max_cpus:
publicRuntimeConfig.TOOLS_DEFAULT_SELECTED_MAX_CPUS,
admin: {
max_cpu_limit: publicRuntimeConfig.TOOLS_ADMIN_MAX_CPU_LIMIT,
max_memory_limit:
Expand Down
9 changes: 9 additions & 0 deletions stories/apps/launch/DEWordCount.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const DEWordCount = ({
loading,
loadingError,
submissionError,
defaultSelectedMaxCpus,
defaultMaxCPUCores,
defaultMaxMemory,
defaultMaxDiskSpace,
Expand Down Expand Up @@ -59,6 +60,7 @@ export const DEWordCount = ({
app={!loadingError && app}
loading={loading}
appError={appError || (loadingError && errorObject)}
defaultSelectedMaxCpus={defaultSelectedMaxCpus}
defaultMaxCPUCores={defaultMaxCPUCores}
defaultMaxMemory={defaultMaxMemory}
defaultMaxDiskSpace={defaultMaxDiskSpace}
Expand Down Expand Up @@ -120,6 +122,12 @@ DEWordCount.argTypes = {
type: "boolean",
},
},
defaultSelectedMaxCpus: {
name: "Default Selected Max CPU Cores",
control: {
type: "number",
},
},
defaultMaxCPUCores: {
name: "Max CPU Cores",
control: {
Expand Down Expand Up @@ -147,6 +155,7 @@ DEWordCount.args = {
loading: false,
loadingError: false,
submissionError: false,
defaultSelectedMaxCpus: 4,
defaultMaxCPUCores: 8,
defaultMaxMemory: 4 * constants.ONE_GiB,
defaultMaxDiskSpace: 64 * constants.ONE_GiB,
Expand Down
1 change: 1 addition & 0 deletions stories/configMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default {
trash_path: "/iplant/trash/home/de-irods",
},
tools: {
default_selected_max_cpus: 4,
admin: {
max_cpu_limit: 48,
max_memory_limit: 244 * constants.ONE_GiB,
Expand Down

0 comments on commit 1238e0b

Please sign in to comment.