Skip to content

Conversation

@hippogr
Copy link
Contributor

@hippogr hippogr commented Oct 29, 2025

List user's history jobs which in the virtual clusters that have been removed from the service.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for tracking and using historical Virtual Cluster (VC) access for users. When users query their jobs, they can now see jobs from VCs they previously had access to, not just their current VCs.

Key changes:

  • Added history_vclist field to user schema to store historical VC access
  • Implemented getHistoryVCs() function that retrieves VCs from user's job history and group memberships
  • Modified job listing logic to include historical VCs alongside current VCs

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/rest-server/src/utils/manager/user/user.js Added history_vclist field to user schema validation
src/rest-server/src/utils/manager/user/crudK8sSecret.js Implemented getHistoryVCs() function and updated create/read/update operations to populate and persist historical VC list
src/rest-server/src/models/v2/job/k8s.js Added listVCsFromJob() function to retrieve unique VCs from a user's job history
src/rest-server/src/controllers/v2/user.js Added getUserHistoryVCs() controller function and initialized history_vclist in user creation
src/rest-server/src/controllers/v2/job.js Updated job list logic to merge current and historical VCs for filtering
Comments suppressed due to low confidence (1)

src/rest-server/src/controllers/v2/job.js:53

  • Variable currentvcs is used like a local variable, but is missing a declaration.
    currentvcs = await userController.getUserVCs(username);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

try {
return await groupModel.getGroupVCs(group);
} catch (error) {
console.error(`Failed to fetch VCs for group ${group}:`, error);
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the logger instance instead of console.error for consistency with the rest of the codebase. Change to logger.error(...).

Suggested change
console.error(`Failed to fetch VCs for group ${group}:`, error);
logger.error(`Failed to fetch VCs for group ${group}:`, error);

Copilot uses AI. Check for mistakes.

const username = req[userProperty].username;
myvcs = await userController.getUserVCs(username);
currentvcs = await userController.getUserVCs(username);
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing variable declaration keyword. Add const or let before currentvcs to avoid creating an implicit global variable.

Suggested change
currentvcs = await userController.getUserVCs(username);
let currentvcs = await userController.getUserVCs(username);

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +58
}
else {
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The else should be on the same line as the closing brace of the if statement for consistency with JavaScript style conventions: } else {

Suggested change
}
else {
} else {

Copilot uses AI. Check for mistakes.
res.json(data);
});

const get = asyncHandler(async (req, res) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other api includes: get/update/getConfig/getevents//getlogs still no access controller, they're independent with listjobs

'userName',
'virtualCluster',
],
where: { userName: username },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it's a database, is it possible to select virtualcluster directly?

return await groupModel.getGroupVCs(group);
} catch (error) {
console.error(`Failed to fetch VCs for group ${group}:`, error);
return []; // Return an empty array on failure
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not return vcsFromJob?

const vcSet = new Set();
const vcPromises = grouplist.map(async group => {
try {
return await groupModel.getGroupVCs(group);
Copy link

@yukirora yukirora Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why history vc get from group info,is it get current vcs or get history vcs from secret?

async function getHistoryVCs(name, grouplist, retrieveFromHistory=true) {
// Retrieve VC list from the user's job history
let vcsFromJob = [];
if (retrieveFromHistory) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if not retrieveFromHistory, if will only return the vcs in getGroupVCs? it should return original historyvcs in secret + getGroupVCs?

@yukirora
Copy link

yukirora commented Nov 4, 2025

and here is a question, if a user had one vc, but currently the vcs still work, but admin delete this user from this vc, under current design, it still has access to this vc's jobs, this seems not make sense

@yukirora yukirora mentioned this pull request Nov 4, 2025
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants