Skip to content

Commit

Permalink
Merge pull request #593 from psarando/CORE-2011-max-cpu-submissions
Browse files Browse the repository at this point in the history
CORE-2011 Update setting max CPUs in app launch form
  • Loading branch information
psarando authored Oct 1, 2024
2 parents 77e8b40 + 1238e0b commit 2ab6899
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 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
11 changes: 9 additions & 2 deletions src/components/apps/launch/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,28 @@ const initAppLaunchValues = (
notify,
notifyPeriodic,
periodicPeriod,
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 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,
max_cpu_cores,
default_max_cpu_cores = 0,
default_max_cpu_cores = max_cpu_cores < defaultMaxCpuCores
? max_cpu_cores
: defaultMaxCpuCores,
default_cpu_cores = 0,
default_memory = 0,
default_disk_space = 0,
}) => ({
step_number,
max_cpu_cores: default_max_cpu_cores || max_cpu_cores,
max_cpu_cores: default_max_cpu_cores,
min_cpu_cores: default_cpu_cores,
min_memory_limit: default_memory,
min_disk_space: default_disk_space,
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 2ab6899

Please sign in to comment.