WebDiscover: allow setting labels when enrolling aws app#50976
WebDiscover: allow setting labels when enrolling aws app#50976
Conversation
| return api | ||
| .post(cfg.getAwsAppAccessUrl(integrationName), req) | ||
| .then(makeApp); | ||
| } | ||
|
|
||
| return ( | ||
| api | ||
| .post(cfg.getAwsAppAccessUrlV2(integrationName), req) | ||
| .then(makeApp) | ||
| // TODO(kimlisa): DELETE IN 19.0 | ||
| .catch(withUnsupportedLabelFeatureErrorConversion) | ||
| ); |
There was a problem hiding this comment.
i think the new UI should always use the new endpoint regardless if labels exist or not. The only time an "old" endpoint should be used is if we want some sort of graceful fallback in some feature which we don't care about here.
go all in!
There was a problem hiding this comment.
i might be just confused, but i added the fallback so that the user has the option to proceed without the labels if they keep hitting the old proxy?
There was a problem hiding this comment.
Thats right. But this block of code reads like it will hit v1 if they didnt add any labels. I think they should always hit v2 even without labels
There was a problem hiding this comment.
But this block of code reads like it will hit v1 if they didnt add any labels.
i think that's okay, since either endpoint in new proxy uses the same handler
I think they should always hit v2 even without labels
hrm, but what if they hit an old proxy? get an error, and they get stuck? (the fallback is then to just remove labels and it will use the old endpoint in case it hits the old proxy again)
There was a problem hiding this comment.
i mean they should always hit v2 as the happy path, even if they dont want to add labels. they are optional, so they should always go v2 since v2 should be able to handle it.
if the web hits the 404, they can be given the option to fallback to v1, sure. but we should never be hitting v1 if we havent already got the 404
There was a problem hiding this comment.
ah i think i finally understand the problem. calling v1 without labels will have issues once we remove the old endpoint, great catch 👍
ec3e23d to
db5de3c
Compare
db5de3c to
0e1787d
Compare
0e1787d to
42721df
Compare
| const [requiresProxyUpgrade, setRequiresProxyUpgrade] = useState(false); | ||
|
|
||
| const [attempt, createApp] = useAsync(async () => { | ||
| const labelsMap: Record<string, string> = {}; | ||
| labels.forEach(l => (labelsMap[l.name] = l.value)); | ||
| try { | ||
| const app = await integrationService.createAwsAppAccess( | ||
| awsIntegration.name | ||
| ); | ||
| let app: App; | ||
| if (requiresProxyUpgrade && !labels.length) { | ||
| app = await integrationService.createAwsAppAccess(awsIntegration.name); | ||
| } else { | ||
| app = await integrationService.createAwsAppAccessV2( | ||
| awsIntegration.name, | ||
| { labels: labelsMap } | ||
| ); | ||
| } | ||
| updateAgentMeta({ | ||
| ...agentMeta, | ||
| app, | ||
| resourceName: app.name, | ||
| }); | ||
| } catch (err) { | ||
| if (err.message.includes(ProxyRequiresUpgrade)) { | ||
| setRequiresProxyUpgrade(true); | ||
| } | ||
| emitErrorEvent(err.message); | ||
| throw err; | ||
| } | ||
| }); |
There was a problem hiding this comment.
Make V2 the first API call the default one here as well? And looks like we can remove the const [requiresProxyUpgrade, setRequiresProxyUpgrade] = useState(false); state.
const [attempt, createApp] = useAsync(async () => {
const labelsMap: Record<string, string> = {};
labels.forEach(l => (labelsMap[l.name] = l.value));
let app: App;
try {
app = await integrationService.createAwsAppAccessV2(
awsIntegration.name,
{ labels: labelsMap }
);
}
} catch (err) {
if (err.message.includes(ProxyRequiresUpgrade)) {
try {
// retry to V1 endpoint
app = await integrationService.createAwsAppAccess(awsIntegration.name);
} catch (e) {
emitErrorEvent(err.message);
throw err;
}
emitErrorEvent(err.message);
throw err;
}
updateAgentMeta({
...agentMeta,
app,
resourceName: app.name,
});
});
we can abstract v1 async call so catch(err) block is a bit simpler.
There was a problem hiding this comment.
hrmmm, wouldn't this re-try for the user? i think it's better if user intentionally retries (by removing labels, which means they understand labels aren't going to be added) or abort altogether
There was a problem hiding this comment.
You are right this auto retries. Also letting user manually do that is a good idea.
I didn't see any label/copy updated for user based on requiresProxyUpgrade so recommended that alternative.
How would the retry UX look like?
There was a problem hiding this comment.
here is a recording of retry (the error message is there after the first attempt that seemed to have cut off from recording):
Screen.Recording.2025-01-13.at.10.09.52.PM.mov
I didn't see any label/copy updated for user based on requiresProxyUpgrade so recommended that alternative.
unless you feel strongly, i will leave it as is. i think it makes things too complicated
There was a problem hiding this comment.
Gotcha. That looks good to me. The only extra thing I could suggest is to mark the labels fields as error so it becomes more apparent but i wouldn't stress that if it begs more changes. Its good as is too.
* WebDiscover: allow setting labels when enrolling aws app * Address CRs
* WebDiscover: allow setting labels when enrolling aws app * Address CRs
* WebDiscover: allow setting labels when enrolling aws app * Address CRs
…ingle resource enroll (#51038) * WebDiscover: allow setting resource labels when enrolling single eks, rds, server, kube (#50606) * WebDiscover: Allow setting labels when enrolling single web application (#50853) * Allow labels for generic add web app flow * Update test * WebDiscover: allow setting labels when enrolling aws app (#50976) * WebDiscover: allow setting labels when enrolling aws app * Address CRs * Web: Fix v1 fallback with v2 endpoints (#51058) * Implement a fallback hook for re-use * Split v1 and v2 endpoints into separate funcs * Provide fallback for create app access * Provide fallback for join token suspender * Provide fallback for eks * Provide fallback for app * Address CRs
* WebDiscover: allow setting labels when enrolling aws app * Address CRs
…al#50976) * WebDiscover: allow setting labels when enrolling aws app * Address CRs
part of #46976
requires #50975
with some labels
changelog: Adds support for defining labels in the web UI for AWS console access application