Skip to content

Commit a4be130

Browse files
PoeppingTbrtrvn
authored andcommitted
Address PR comments.
This commit allows for FSX ONTAP if Linux/EC2 are selected and fixes a small bug with the filesystem type selection where the radio buttons were showing if "Provision a FileSystem" was not selected. This commit also makes changes to the structuring of the FILESYSTEM_TYPES constants to allow for different form validation depending on whether the FSX_ONTAP OS is WINDOWS or LINUX.
1 parent 82528d8 commit a4be130

File tree

6 files changed

+98
-29
lines changed

6 files changed

+98
-29
lines changed

client/web/src/settings/ApplicationComponent.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import globalConfig from '../config/appConfig'
2626
import AppSettingsSubform from './AppSettingsSubform'
2727
import BillingSubform from './BillingSubform'
2828
import ServicesComponent from './ServicesComponent'
29-
import { FILESYSTEM_DEFAULTS, FILESYSTEM_TYPES } from './components/filesystem'
29+
import { FILESYSTEM_DEFAULTS, FILESYSTEM_TYPES, OS_TO_FS_TYPES } from './components/filesystem'
3030

3131
import { dismissConfigError, dismissConfigMessage } from './ducks'
3232

@@ -69,7 +69,7 @@ export function ApplicationComponent(props) {
6969
window.scrollTo(0, 0)
7070
}
7171

72-
const generateAppConfigOrDefaultInitialValuesForTier = (tierValues, defaultValues) => {
72+
const generateAppConfigOrDefaultInitialValuesForTier = (tierValues, defaultValues, os) => {
7373
let filesystem = {
7474
...FILESYSTEM_DEFAULTS,
7575
...defaultValues.filesystem,
@@ -84,11 +84,14 @@ export function ApplicationComponent(props) {
8484
...defaults,
8585
filesystem: filesystem,
8686
}
87+
88+
let filesystemType = OS_TO_FS_TYPES[os]?.filter(type => type.configId === tierValues.filesystem?.type)[0]?.id || ''
89+
8790
return {
8891
...uncleanedInitialTierValues,
8992
provisionDb: !!tierValues.database,
9093
provisionFS: !!tierValues.filesystem,
91-
filesystemType: tierValues.filesystem?.type || '',
94+
filesystemType: filesystemType,
9295
filesystem: splitWeeklyMaintenanceTime(uncleanedInitialTierValues.filesystem),
9396
}
9497
}
@@ -144,11 +147,11 @@ export function ApplicationComponent(props) {
144147
}
145148
const windowsVersion = os === WINDOWS ? thisService.operatingSystem : ''
146149
let defaultTierName = tiers.filter(t => t.defaultTier)[0].name
147-
let defaultTierValues = generateAppConfigOrDefaultInitialValuesForTier(Object.assign({}, thisService?.tiers[defaultTierName]), {})
150+
let defaultTierValues = generateAppConfigOrDefaultInitialValuesForTier(Object.assign({}, thisService?.tiers[defaultTierName]), {}, os)
148151
let initialTierValues = {}
149152
for (var i = 0; i < tiers.length; i++) {
150153
var tierName = tiers[i].name
151-
initialTierValues[tierName] = generateAppConfigOrDefaultInitialValuesForTier(Object.assign({}, thisService?.tiers[tierName]), defaultTierValues)
154+
initialTierValues[tierName] = generateAppConfigOrDefaultInitialValuesForTier(Object.assign({}, thisService?.tiers[tierName]), defaultTierValues, os)
152155
}
153156
return {
154157
...thisService,

client/web/src/settings/ApplicationContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ export function ApplicationContainer(props) {
162162
weeklyMaintenanceTime,
163163
...cleanedFs
164164
} = filesystem
165-
cleanedFs.type = filesystemType
165+
cleanedFs.type = FILESYSTEM_TYPES[filesystemType].configId
166166
if (weeklyMaintenanceDay && weeklyMaintenanceTime) {
167167
cleanedFs.weeklyMaintenanceTime = `${weeklyMaintenanceDay}:${getFormattedTime(weeklyMaintenanceTime)}`
168168
}
169-
let wantedKeys = Object.keys(FILESYSTEM_TYPES[cleanedFs.type].defaults)
169+
let wantedKeys = Object.keys(FILESYSTEM_TYPES[filesystemType].defaults)
170170
Object.keys(cleanedFs).forEach(k => {
171171
if (!wantedKeys.includes(k) && k !== 'type') {
172172
delete cleanedFs[k]

client/web/src/settings/TierServiceSettingsSubform.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,24 @@ const TierServiceSettingsSubform = (props) => {
3838

3939
const formikTierPrefix = formikServicePrefix + '.tiers[' + selectedTier + ']'
4040

41-
// set compute size if default exists and this tier doesn't
42-
if (!!!serviceValues?.tiers[selectedTier]?.computeSize && !!serviceValues?.tiers[defaultTier]?.computeSize) {
43-
// set instance to default if it doesn't exist already
44-
setFieldValue(formikTierPrefix + '.computeSize', serviceValues?.tiers[defaultTier]?.computeSize)
45-
}
41+
if (!!serviceValues?.tiers) {
42+
// set compute size if default exists and this tier doesn't
43+
if (!!!serviceValues?.tiers[selectedTier]?.computeSize && !!serviceValues?.tiers[defaultTier]?.computeSize) {
44+
// set instance to default if it doesn't exist already
45+
setFieldValue(formikTierPrefix + '.computeSize', serviceValues?.tiers[defaultTier]?.computeSize)
46+
}
4647

47-
// set min if default exists and this tier doesn't
48-
if (!!!serviceValues?.tiers[selectedTier]?.min && !!serviceValues?.tiers[defaultTier]?.min) {
49-
// set instance to default if it doesn't exist already
50-
setFieldValue(formikTierPrefix + '.min', serviceValues?.tiers[defaultTier]?.min)
51-
}
48+
// set min if default exists and this tier doesn't
49+
if (!!!serviceValues?.tiers[selectedTier]?.min && !!serviceValues?.tiers[defaultTier]?.min) {
50+
// set instance to default if it doesn't exist already
51+
setFieldValue(formikTierPrefix + '.min', serviceValues?.tiers[defaultTier]?.min)
52+
}
5253

53-
// set max if default exists and this tier doesn't
54-
if (!!!serviceValues?.tiers[selectedTier]?.max && !!serviceValues?.tiers[defaultTier]?.max) {
55-
// set instance to default if it doesn't exist already
56-
setFieldValue(formikTierPrefix + '.max', serviceValues?.tiers[defaultTier]?.max)
54+
// set max if default exists and this tier doesn't
55+
if (!!!serviceValues?.tiers[selectedTier]?.max && !!serviceValues?.tiers[defaultTier]?.max) {
56+
// set instance to default if it doesn't exist already
57+
setFieldValue(formikTierPrefix + '.max', serviceValues?.tiers[defaultTier]?.max)
58+
}
5759
}
5860

5961
return (
@@ -108,6 +110,7 @@ const TierServiceSettingsSubform = (props) => {
108110
label="Minimum Instance Count"
109111
name={formikTierPrefix + '.min'}
110112
type="number"
113+
min="0"
111114
/>
112115
</Col>
113116
<Col>
@@ -116,6 +119,7 @@ const TierServiceSettingsSubform = (props) => {
116119
label="Maximum Instance Count"
117120
name={formikTierPrefix + '.max'}
118121
type="number"
122+
min="0"
119123
/>
120124
</Col>
121125
</Row>
@@ -131,6 +135,7 @@ const TierServiceSettingsSubform = (props) => {
131135
serviceValues?.tiers[selectedTier]?.provisionFS
132136
}
133137
containerOs={serviceValues?.operatingSystem}
138+
containerLaunchType={serviceValues?.ecsLaunchType}
134139
filesystemType={serviceValues?.tiers[selectedTier]?.filesystemType}
135140
setFieldValue={props.setFieldValue}
136141
></FileSystemSubform>

client/web/src/settings/components/filesystem/FileSystemSubform.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const FilesystemType = (props) => {
6161
id={"fs-" + fs.id + "-" + props.formikTierPrefix}
6262
name={props.formikTierPrefix + ".filesystemType"}
6363
value={fs.id}
64-
disabled={props.isLocked}
64+
disabled={!fs.enabled(props.containerOs, props.containerLaunchType)}
6565
/>
6666
<Label className="form-check-label" check htmlFor={"fs-" + fs.id + "-" + props.formikTierPrefix}>
6767
<CIcon icon={fs.icon} /> {fs.name}
@@ -80,7 +80,7 @@ class EmptyComponent extends React.Component {
8080
export default class FileSystemSubform extends React.Component {
8181
render() {
8282
var FsComponent = (!!this.props.filesystemType && FILESYSTEM_TYPES[this.props.filesystemType])
83-
? FILESYSTEM_TYPES[this.props.filesystemType].component
83+
? FILESYSTEM_TYPES[this.props.filesystemType].component
8484
: EmptyComponent
8585
return (
8686
<Fragment>
@@ -94,7 +94,9 @@ export default class FileSystemSubform extends React.Component {
9494
name={this.props.formikTierPrefix + '.provisionFS'}
9595
label="Provision a File System for the application."
9696
/>
97-
<FilesystemType {...this.props}></FilesystemType>
97+
{this.props.provisionFs && (
98+
<FilesystemType {...this.props}></FilesystemType>
99+
)}
98100
{this.props.provisionFs && this.props.filesystemType && (
99101
<FsComponent {...this.props}></FsComponent>
100102
)}
@@ -111,6 +113,7 @@ FileSystemSubform.propTypes = {
111113
provisionFs: PropTypes.bool,
112114
filesystemType: PropTypes.string,
113115
containerOs: PropTypes.string,
116+
containerLaunchType: PropTypes.string,
114117
isLocked: PropTypes.bool,
115118
filesystem: PropTypes.object,
116119
formik: PropTypes.object,

client/web/src/settings/components/filesystem/FsxOntapFilesystemOptions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ export default class FsxOntapFilesystemOptions extends React.Component {
230230
</Row>
231231
<Row>
232232
<Col xs={6}>
233+
{this.props.containerOs === "WINDOWS" && (
233234
<SaasBoostSelect
234235
id={
235236
props.formikTierPrefix + '.filesystem.windowsMountDrive'
@@ -260,6 +261,7 @@ export default class FsxOntapFilesystemOptions extends React.Component {
260261
<option value="Y:">Y:</option>
261262
<option value="Z:">Z:</option>
262263
</SaasBoostSelect>
264+
)}
263265
</Col>
264266
<Col xs={6}>
265267
<SaasBoostInput

client/web/src/settings/components/filesystem/index.js

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const FILESYSTEM_TYPES = {
2626
"name": "EFS",
2727
"icon": cibAmazonAws,
2828
"component": EfsFilesystemOptions,
29+
"enabled": (os, launchType) => os === "LINUX",
2930
"defaults": {
3031
mountPoint: '',
3132
lifecycle: 'NEVER',
@@ -50,6 +51,7 @@ export const FILESYSTEM_TYPES = {
5051
"name": "FSX Windows",
5152
"icon": cibWindows,
5253
"component": FsxWindowsFilesystemOptions,
54+
"enabled": (os, launchType) => os === "WINDOWS",
5355
"defaults": {
5456
mountPoint: '',
5557
storageGb: 32,
@@ -87,11 +89,64 @@ export const FILESYSTEM_TYPES = {
8789
.required('Windows mount drive is required'),
8890
})
8991
},
90-
"FSX_ONTAP": {
91-
"id": "FSX_ONTAP",
92+
"FSX_ONTAP_LINUX": {
93+
"configId": "FSX_ONTAP",
94+
"id": "FSX_ONTAP_LINUX",
9295
"name": "FSX Ontap",
9396
"icon": cilViewQuilt,
9497
"component": FsxOntapFilesystemOptions,
98+
"enabled": (os, launchType) => os === "LINUX" && launchType === "EC2",
99+
"defaults": {
100+
mountPoint: '',
101+
storageGb: 1024,
102+
throughputMbs: 128,
103+
backupRetentionDays: 7,
104+
dailyBackupTime: '01:00',
105+
weeklyMaintenanceTime: '07:01:00',
106+
weeklyMaintenanceDay: '1',
107+
volumeSize: 40
108+
},
109+
"validationSchema": Yup.object({
110+
mountPoint: Yup.string()
111+
.matches(/^(\/[a-zA-Z._-]+)*$/, 'Invalid path. Ex: /mnt')
112+
.max(100, "The full path can't exceed 100 characters in length")
113+
.test(
114+
'subdirectories',
115+
'The path can only include up to four subdirectories',
116+
(val) => (val?.match(/\//g) || []).length <= 4
117+
)
118+
.required(),
119+
storageGb: Yup.number()
120+
.required()
121+
.min(1024, 'Storage minimum is 1024 GB')
122+
.max(196608, 'Storage maximum is 196,608 GB'),
123+
throughputMbs: Yup.number()
124+
.required()
125+
.min(128, 'Throughput minimum is 128 MB/s')
126+
.max(2048, 'Throughput maximum is 2048 MB/s'),
127+
backupRetentionDays: Yup.number()
128+
.required()
129+
.min(7, 'Minimum retention time is 7 days')
130+
.max(35, 'Maximum retention time is 35 days'),
131+
dailyBackupTime: Yup.string()
132+
.required('Daily backup time is required'),
133+
weeklyMaintenanceTime: Yup.string()
134+
.required('Weekly maintenance time is required'),
135+
windowsMountDrive: Yup.string()
136+
.required('Windows mount drive is required'),
137+
volumeSize: Yup.number()
138+
.required()
139+
.min(0, 'Volume Size must be a positive number')
140+
.max(196608, 'Volume size maximum is 196,608 GB')
141+
})
142+
},
143+
"FSX_ONTAP_WINDOWS": {
144+
"configId": "FSX_ONTAP",
145+
"id": "FSX_ONTAP_WINDOWS",
146+
"name": "FSX Ontap",
147+
"icon": cilViewQuilt,
148+
"component": FsxOntapFilesystemOptions,
149+
"enabled": (os, launchType) => os === "WINDOWS",
95150
"defaults": {
96151
mountPoint: '',
97152
storageGb: 1024,
@@ -131,7 +186,7 @@ export const FILESYSTEM_TYPES = {
131186
volumeSize: Yup.number()
132187
.required()
133188
.min(0, 'Volume Size must be a positive number')
134-
.max(196608, 'Volume size maximum is 196.608 GB')
189+
.max(196608, 'Volume size maximum is 196,608 GB')
135190
})
136191
}
137192
}
@@ -144,10 +199,11 @@ export const FILESYSTEM_DEFAULTS = Object.assign(Object.keys(FILESYSTEM_TYPES)
144199

145200
export const OS_TO_FS_TYPES = {
146201
"LINUX": [
147-
FILESYSTEM_TYPES.EFS
202+
FILESYSTEM_TYPES.EFS,
203+
FILESYSTEM_TYPES.FSX_ONTAP_LINUX,
148204
],
149205
"WINDOWS": [
150206
FILESYSTEM_TYPES.FSX_WINDOWS,
151-
FILESYSTEM_TYPES.FSX_ONTAP,
207+
FILESYSTEM_TYPES.FSX_ONTAP_WINDOWS,
152208
]
153209
}

0 commit comments

Comments
 (0)