Skip to content

Add maintenance notifications in PAC portal during any related mainte…#73

Open
vikasbolla wants to merge 1 commit intoIBM:mainfrom
vikasbolla:add_maintenance_notification
Open

Add maintenance notifications in PAC portal during any related mainte…#73
vikasbolla wants to merge 1 commit intoIBM:mainfrom
vikasbolla:add_maintenance_notification

Conversation

@vikasbolla
Copy link
Copy Markdown
Collaborator

@vikasbolla vikasbolla commented Apr 14, 2026

Added functionality to display maintenance notifications to PAC users. There is seperate page for admin to manage create, edit, delete, enable/disable maintenance windows.

  • Notifications appear 24 hours before maintenance starts
  • Visible during maintenance window
  • Automatically disappear after end time
  • overlapping is not allowed, so if admin tries to create new window with time overlapping with existing windows, in that case, we throw error saying to use same window to update the maintenance.

@vikasbolla vikasbolla force-pushed the add_maintenance_notification branch 4 times, most recently from d044d95 to e096e8e Compare April 15, 2026 04:35
@vikasbolla vikasbolla marked this pull request as ready for review April 15, 2026 04:40
Copy link
Copy Markdown
Member

@mayuka-c mayuka-c left a comment

Choose a reason for hiding this comment

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

I'm thinking of this approach than logging to cluster and updating env causing downtime.

  • Maybe maintain the maintainence state in backend mongoDB with (start date, end date, isMaintainence).
  • Expose a POST API (strictly restricted to admin), so that the admin can just make API call to update or give them a small toggle button in Admin personna (Enable maintaince or not).
  • In UI this would greatly simplify as you just need to make the GET call and if yes provide them the maintainence banner.

Comment thread web/.env Outdated
Comment thread web/.env Outdated
Comment thread web/src/components/MaintenanceNotification.jsx Outdated
Comment thread web/src/components/MaintenanceNotification.jsx Outdated
@vikasbolla vikasbolla force-pushed the add_maintenance_notification branch 4 times, most recently from e32999f to 339ba3f Compare April 17, 2026 12:06
Copy link
Copy Markdown
Member

@mayuka-c mayuka-c left a comment

Choose a reason for hiding this comment

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

If possible can we split the PR into 2, first the backend and then the UI changes. Will be easier to review.
Didnt get time to review UI code, will check it later.

Overall approach looks good.

Comment thread web/.env Outdated
authorized.POST("/feedbacks", services.CreateFeedback)

// maintenance notification related endpoints
authorized.GET("/maintenance", services.GetMaintenanceWindows)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldnt GetAllMaintenances be only admin route?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No, We need this call to get the maintenance windows and show the active one to the users

Comment on lines +31 to +34
// MaintenanceListResponse is the public response for listing all maintenance windows
type MaintenanceListResponse struct {
Maintenances []MaintenanceResponse `json:"maintenances"`
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

List of all maintenances is not required for public, this would be required for admin only for auditing or some other purposes

logger.Error("failed to create event", zap.Error(err))
}
}()
eventLog := fmt.Sprintf("Maintenance window created by admin %s (ID: %s, Enabled: %v)",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we have the message too here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

you mean log message?

Comment on lines +321 to +325
if err := dbCon.DeleteMaintenanceWindow(id); err != nil {
logger.Error("failed to delete maintenance window from db", zap.Error(err))
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to delete maintenance window"})
return
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the delete, I feel like doing soft delete with "deleted_at" might be useful, this would help maybe for auditing to know how many maintainces happened for last 6 months etc

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ha true, makes sense, will update this, thanks

Comment on lines +120 to +124
// Validate time range
if request.EndTime.Before(request.StartTime) || request.EndTime.Equal(request.StartTime) {
c.JSON(http.StatusBadRequest, gin.H{"error": "end_time must be after start_time"})
return
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel at a given time only one maintainence window can be active. So if a maintainence is already active, then do not allow one more maintainence to be created

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

But,I feel we need to allow them creating them new maintenance if they are at difference timestamp but not allow to multiple maintenance notifications to display to users if the time overlaps.

Comment on lines +192 to +196
var request models.MaintenanceUpdateRequest
if err := utils.BindAndValidate(c, &request); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request body"})
return
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similarly in update, you can enable a maintaince window if there are no other maintaince window active

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Same here, we can restrict enabling or creating a maintenance window if the time overlaps

Comment on lines +299 to +301
func DeleteMaintenanceWindow(c *gin.Context) {
logger := log.GetLogger()
id := c.Param("id")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm wondering do we even need DeleteMaintenance endpoint, as an admin we give them the option to disable the maintainence window and do not require to delete it.

So I feel we just need to add a TTL, lets say if the maintainence is disabled for more than 1year, then simply delete from DB.

Comment on lines +210 to +216
// Validate time range if both times are provided
if !request.StartTime.IsZero() && !request.EndTime.IsZero() {
if request.EndTime.Before(request.StartTime) || request.EndTime.Equal(request.StartTime) {
c.JSON(http.StatusBadRequest, gin.H{"error": "end_time must be after start_time"})
return
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we restrict the end time to maybe lets say 15 days since the start time since it was created. Otherwise admin might simply keep updating the same maintainence object over and over which will lose the track of how many maintainence windows were created?

@vikasbolla vikasbolla force-pushed the add_maintenance_notification branch 9 times, most recently from 6ff5563 to bdfc702 Compare April 22, 2026 06:20
…nance window

Signed-off-by: Vikas <vikas.satyanarayana.bolla@ibm.com>
@vikasbolla vikasbolla force-pushed the add_maintenance_notification branch from bdfc702 to 59adc2f Compare April 22, 2026 07:03
Copy link
Copy Markdown
Member

@mayuka-c mayuka-c left a comment

Choose a reason for hiding this comment

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

A minor comment. Rest LGTM

Comment on lines +36 to +37
// Check if admin wants all windows
showAll := c.Query("all") == "true"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we make this admin only check that is only admin can use this "all" query?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Query param is passed from frontend only for admin

Copy link
Copy Markdown
Member

@mayuka-c mayuka-c left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants