-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Add worker maintenance mode functionality to Edge3 provider UI #55301
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
base: main
Are you sure you want to change the base?
Add worker maintenance mode functionality to Edge3 provider UI #55301
Conversation
dheerajturaga
commented
Sep 5, 2025
- Add POST /edge_worker/ui/worker/{worker_name}/maintenance endpoint to request maintenance mode
- Add DELETE /edge_worker/ui/worker/{worker_name}/maintenance endpoint to exit maintenance mode
- Add maintenance request form with required comment field (max 1024 chars)
- Add maintenance state handling for all maintenance-related worker states
- Add proper error handling and user feedback for maintenance operations
- Add worker existence validation and database session management
- Remove authentication dependencies for UI maintenance endpoints
- Update frontend to show maintenance controls based on worker state
- Format maintenance comments with timestamps for audit trail



- Add POST /edge_worker/ui/worker/{worker_name}/maintenance endpoint to request maintenance mode - Add DELETE /edge_worker/ui/worker/{worker_name}/maintenance endpoint to exit maintenance mode - Add maintenance request form with required comment field (max 1024 chars) - Add maintenance state handling for all maintenance-related worker states - Add proper error handling and user feedback for maintenance operations - Add worker existence validation and database session management - Remove authentication dependencies for UI maintenance endpoints - Update frontend to show maintenance controls based on worker state - Format maintenance comments with timestamps for audit trail
4fc6780
to
39024c2
Compare
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.
Very cool! I also wanted to get started with the maintenance but you opened the PR faster. Cool!
Functionally the skeleton is working.
Sorry about the many comments, don't be afraid. If too much then let me know and I can also contribute to this as this is an important feature urgently needed in UI for Airflow 3.1 release.
providers/edge3/src/airflow/providers/edge3/worker_api/routes/ui.py
Outdated
Show resolved
Hide resolved
|
||
@ui_router.post( | ||
"/worker/{worker_name}/maintenance", | ||
) |
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.
To ensure this API is not "public/open" but authenticated, please add the access check
) | |
dependencies=[ | |
Depends(requires_access_view(access_view=AccessView.JOBS)), | |
], | |
) |
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.
@jscheffl , I already tried this and I was not able to get the post and delete to work. I keep getting 401 not authorized and I was not able to figure out how to provide proper authorization.
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.
Good. But still needed. Probably because you implemented the manual authentication in the service accessor.
Can you attempt it via the axios generated code? If then not working, please push and I can help fixing.
|
||
@ui_router.delete( | ||
"/worker/{worker_name}/maintenance", | ||
) |
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.
Same as above
) | |
dependencies=[ | |
Depends(requires_access_view(access_view=AccessView.JOBS)), | |
], | |
) |
providers/edge3/src/airflow/providers/edge3/worker_api/routes/ui.py
Outdated
Show resolved
Hide resolved
providers/edge3/src/airflow/providers/edge3/worker_api/routes/ui.py
Outdated
Show resolved
Hide resolved
} | ||
return ( | ||
<Button size="sm" colorScheme="blue" onClick={() => setActiveMaintenanceForm(workerName)}> | ||
Enter Maintenance |
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.
Instead of (like in the 2.x legacy UI) rendering buttons with text - have you considered we use icons like in other tables/lists in the core UI?
Like here, icons on the right side:
For maintenance the icon https://react-icons.github.io/react-icons/search/#q=HiOutlineWrenchScrewdriver might be suitable (using this already for the state display)
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.
To exit maintenance e.g. the icon HiOutlineArrowRightStartOnRectangle or vsc/VscDebugRestart could be suitable
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've updated to use the icons but I was not able to get tooltips working. It seems causing a Minified React Error 130
}; | ||
|
||
return ( | ||
<VStack gap={2} align="stretch"> |
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.
As with react we have much more cool widgets and options compared to legacy 2.x UI, how about making this a modal dialog?
Can also be extracted as a component into a separate tsx file to be used as <MaintenanceForm worker={ worker } />
<Box fontSize="sm" whiteSpace="pre-wrap"> | ||
{worker.maintenance_comments || "No comment"} | ||
</Box> | ||
<Button size="sm" colorScheme="blue" onClick={() => exitMaintenance(workerName)}> |
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.
If we make this UI form now "right" I assume we should add some kind of confirmation dialog/modal such that the user needs to confirm via a "are you sure you want to exit maintenance for worker XYZ? (yes/no)"
state === "maintenance pending" || | ||
state === "maintenance mode" || | ||
state === "maintenance request" || | ||
state === "maintenance exit" || |
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 think when maintenance exit is already there as status we do not need to present the "Exit" button again, it is just pending that the worker fetches this.
state === "maintenance exit" || |
|
||
return ( | ||
<VStack gap={2} align="stretch"> | ||
<Textarea |
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.
Would be a cool improvement over 2.x UI to be able to use Markdown rendering here? WDYT? We might need to clone the component from core-ui. Might be also a beautification as a follow-up PR.
Remove explicit session.commit() calls - let SQLAlchemy handle transactions
- Move MaintenanceRequest class to datamodels_ui.py for better organization - Remove explicit session.commit() calls, let SQLAlchemy handle transactions - Extract OperationsCell and MaintenanceForm into separate component file - Clean up unused imports in WorkerPage.tsx - Improve code modularity and maintainability
…tenance operations - Use useUiServiceRequestWorkerMaintenance and useUiServiceExitWorkerMaintenance hooks - Remove manual fetch implementation with CSRF token handling - Simplify error handling using React Query's onSuccess/onError callbacks - Improve type safety with generated API client - Reduce bundle size and code complexity - Maintain same functionality with cleaner, more maintainable code