-
Notifications
You must be signed in to change notification settings - Fork 738
fix(smus): unble to refresh status on newly created App bug #8258
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
Conversation
|
| let app | ||
| if (this.spaceApp.App?.AppName) { | ||
| app = await this.client.describeApp({ | ||
| DomainId: this.spaceApp.DomainId, | ||
| AppName: this.spaceApp.App?.AppName, | ||
| AppType: this.spaceApp?.SpaceSettingsSummary?.AppType, | ||
| SpaceName: this.spaceApp.SpaceName, | ||
| }) | ||
| } else if (this.spaceApp.DomainId && this.spaceApp.SpaceName) { | ||
| app = await this.client.getAppBySpace(this.spaceApp.DomainId, this.spaceApp.SpaceName) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add unit tests?
| if (!this.spaceApp.App) { | ||
| this.spaceApp.App = spaceApp.App | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what circumstances will this apply, and what problem is this addressing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this resolve the edge case when this.spaceApp.App is null.
where it is unable to update the status of the app if app is null because current logic to update the app is only updating it's status as a string, if the App object itself is null, then we can not update its status
public setSpaceStatus(spaceStatus: string, appStatus: string) {
this.spaceApp.Status = spaceStatus
if (this.spaceApp.App) {
this.spaceApp.App.Status = appStatus
}
}
| } | ||
|
|
||
| public updateSpace(spaceApp: SagemakerSpaceApp) { | ||
| if (!this.spaceApp.App) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment to clarify when this will happen, finding it hard to understand.
I know not from this change but spaceApp.App just feels very confusing, if there is scope to rename to better variables, we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, do you have any suggestions to replace "spaceApp", basically spaceApp is a space that have a App as one of the variables attached to it.
we would also need to change the name for the SagemakerSpaceApp type:
export interface SagemakerSpaceApp extends SpaceDetails {
App?: AppDetails
DomainSpaceKey: string
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about type: "SagemakerSpaceDetails", variable just: "space" or "spaceDetails"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that SagemakerSpace is the class name, so the current naming can be more confusing, like:
SagemakerSpace.spaceApp.App.AppName
a lot of spaces and apps
what about:
SagemakerSpace.spaceDetails.appDetails.AppName
| this.contextValue = this.getContext() | ||
| } | ||
|
|
||
| public updateSpace(spaceApp: SagemakerSpaceApp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When all is this invoked and why does it help in this case?
| SpaceName: this.spaceApp.SpaceName, | ||
| }) | ||
| let app | ||
| if (this.spaceApp.App?.AppName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments to clarify such conditional statements. Helps preserve context
| }) | ||
| } else if (this.spaceApp.DomainId && this.spaceApp.SpaceName) { | ||
| app = await this.client.getAppBySpace(this.spaceApp.DomainId, this.spaceApp.SpaceName) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else? Are there other possible cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no other cases, gonna add error handling for else case
| return this.makeRequest(DeleteAppCommand, request) | ||
| } | ||
|
|
||
| public async getAppBySpace(domainId: string, spaceName: string): Promise<AppDetails | undefined> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit : Can just rename this to listAppsForSpace so it describes what it does.
| const appsList = await this.listApps({ DomainIdEquals: domainId, SpaceNameEquals: spaceName }) | ||
| .flatten() | ||
| .promise() | ||
| return appsList[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess currently it is one app for a space, add a comment to clarify maybe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes current one app for one space, gonna add inline comment
| // AWS DescribeSpace API returns full details with property names like 'SpaceSettings' | ||
| // but our internal SagemakerSpaceApp type expects 'SpaceSettingsSummary' (from ListSpaces API) | ||
| // We destructure and rename properties to maintain type compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this, should we just make the above List alone? IIUC they are calling DescribeApp and then converting response to mach ListApps response structure? Am I understanding this wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might simplify the above logic if so, thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point.
I think we may want to do use ListSpaces alone for spaces two:
now we are converting SpaceSettings (DescribeSpace) to SpaceSettingsSummary (ListSpace).
so we get rid of the DescribeApp, and only ListApps?:
let app
if (this.spaceApp.DomainId && this.spaceApp.SpaceName) {
app = await this.client.listAppForSpace(this.spaceApp.DomainId, this.spaceApp.SpaceName)
} else {
logger.error(
`updateSpaceAppStatus: unable to get app, [AppName: ${this.spaceApp.App?.AppName}], [DomainId: ${this.spaceApp.DomainId}], [SpaceName: ${this.spaceApp.SpaceName}]`
)
throw new ToolkitError(
`Cannot update app status without [AppName: ${this.spaceApp.App?.AppName}] or [DomainId: ${this.spaceApp.DomainId} and SpaceName: ${this.spaceApp.SpaceName}]`
)
}bb83761 to
01db476
Compare
| assert.strictEqual(updateSpaceArgs.SpaceSharingSettingsSummary, undefined) | ||
| }) | ||
|
|
||
| it('should use listAppForSpace when AppName is not available', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer the same condition but feel free to update in some other PR.
vpbhargav
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test for both SMUS and SM AI thoroughly.
| let app | ||
| if (this.spaceApp.DomainId && this.spaceApp.SpaceName) { | ||
| app = await this.client.listAppForSpace(this.spaceApp.DomainId, this.spaceApp.SpaceName) | ||
| } else { | ||
| logger.error( | ||
| `updateSpaceAppStatus: unable to get app, [DomainId: ${this.spaceApp.DomainId}], [SpaceName: ${this.spaceApp.SpaceName}]` | ||
| ) | ||
| throw new ToolkitError( | ||
| `Cannot update app status without [DomainId: ${this.spaceApp.DomainId} and SpaceName: ${this.spaceApp.SpaceName}]` | ||
| ) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
const app = (this.spaceApp.DomainId && this.spaceApp.SpaceName) ? await this.client.listAppForSpace(this.spaceApp.DomainId, this.spaceApp.SpaceName) : undefined
if (!app) {
logger.error(
`updateSpaceAppStatus: unable to get app, [DomainId: ${this.spaceApp.DomainId}], [SpaceName: ${this.spaceApp.SpaceName}]`
)
throw new ToolkitError(
`Cannot update app status without [DomainId: ${this.spaceApp.DomainId} and SpaceName: ${this.spaceApp.SpaceName}]`
)
}
8a84918 to
7fd8d39
Compare
Problem
Remote connection failed due to not able to refresh the status of a newly created App because it is not mapped to the space corresponding to it.
Solution
ListApp instead of DescribeApp when the space doesn't have a App mapping to it
feature/xbranches will not be squash-merged at release time.