-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add log retention for database logger (#8622)
* feat: add task log retention * update from comments * move migration * fix for tests * test changes and docs edits --------- Co-authored-by: Saloni Gupta <[email protected]>
- Loading branch information
1 parent
8f5de35
commit 85bb3c8
Showing
37 changed files
with
3,417 additions
and
2,273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
:orphan: | ||
|
||
**New Features** | ||
|
||
- Logging: Add a configuration option, ``logging_retention``, to the server configuration file with | ||
options for scheduling (``schedule``) log cleanup, and for selecting the number of ``days`` to | ||
retain logs. Experiments can override the default log retention settings provided by the server | ||
by specifying ``log_retention_days`` in the experiment configuration. Valid values for retention | ||
days range from ``-1`` to ``32767``, and schedules must adhere to a valid cron expression or | ||
duration format. If retention days is set to ``-1``, logs will be retained indefinitely. | ||
Conversely, setting retention days to 0 will result in logs being deleted during the next | ||
scheduled log cleanup. Additionally, administrators can manually initiate log retention cleanup | ||
using the ``det master cleanup-logs command``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package internal | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/determined-ai/determined/master/internal/cluster" | ||
"github.com/determined-ai/determined/master/internal/grpcutil" | ||
"github.com/determined-ai/determined/master/internal/logretention" | ||
"github.com/determined-ai/determined/proto/pkg/apiv1" | ||
) | ||
|
||
func (a *apiServer) CleanupLogs( | ||
ctx context.Context, req *apiv1.CleanupLogsRequest, | ||
) (*apiv1.CleanupLogsResponse, error) { | ||
u, _, err := grpcutil.GetUser(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
// Check if the user has permission to update the server config, then they should be able to | ||
// change the schedule and cleanup logs immediately. | ||
// TODO: Update to IsClusterAdmin eventually. | ||
permErr, err := cluster.AuthZProvider.Get().CanUpdateMasterConfig(ctx, u) | ||
if err != nil { | ||
return nil, err | ||
} else if permErr != nil { | ||
return nil, permErr | ||
} | ||
|
||
removed, err := logretention.DeleteExpiredTaskLogs(ctx, a.m.taskSpec.LogRetentionDays) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &apiv1.CleanupLogsResponse{RemovedCount: removed}, nil | ||
} |
Oops, something went wrong.