config_schema.go 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. package maintenance
  2. import (
  3. "github.com/seaweedfs/seaweedfs/weed/admin/config"
  4. )
  5. // Type aliases for backward compatibility
  6. type ConfigFieldType = config.FieldType
  7. type ConfigFieldUnit = config.FieldUnit
  8. type ConfigField = config.Field
  9. // Constant aliases for backward compatibility
  10. const (
  11. FieldTypeBool = config.FieldTypeBool
  12. FieldTypeInt = config.FieldTypeInt
  13. FieldTypeDuration = config.FieldTypeDuration
  14. FieldTypeInterval = config.FieldTypeInterval
  15. FieldTypeString = config.FieldTypeString
  16. FieldTypeFloat = config.FieldTypeFloat
  17. )
  18. const (
  19. UnitSeconds = config.UnitSeconds
  20. UnitMinutes = config.UnitMinutes
  21. UnitHours = config.UnitHours
  22. UnitDays = config.UnitDays
  23. UnitCount = config.UnitCount
  24. UnitNone = config.UnitNone
  25. )
  26. // Function aliases for backward compatibility
  27. var (
  28. SecondsToIntervalValueUnit = config.SecondsToIntervalValueUnit
  29. IntervalValueUnitToSeconds = config.IntervalValueUnitToSeconds
  30. )
  31. // MaintenanceConfigSchema defines the schema for maintenance configuration
  32. type MaintenanceConfigSchema struct {
  33. config.Schema // Embed common schema functionality
  34. }
  35. // GetMaintenanceConfigSchema returns the schema for maintenance configuration
  36. func GetMaintenanceConfigSchema() *MaintenanceConfigSchema {
  37. return &MaintenanceConfigSchema{
  38. Schema: config.Schema{
  39. Fields: []*config.Field{
  40. {
  41. Name: "enabled",
  42. JSONName: "enabled",
  43. Type: config.FieldTypeBool,
  44. DefaultValue: true,
  45. Required: false,
  46. DisplayName: "Enable Maintenance System",
  47. Description: "When enabled, the system will automatically scan for and execute maintenance tasks",
  48. HelpText: "Toggle this to enable or disable the entire maintenance system",
  49. InputType: "checkbox",
  50. CSSClasses: "form-check-input",
  51. },
  52. {
  53. Name: "scan_interval_seconds",
  54. JSONName: "scan_interval_seconds",
  55. Type: config.FieldTypeInterval,
  56. DefaultValue: 30 * 60, // 30 minutes in seconds
  57. MinValue: 1 * 60, // 1 minute
  58. MaxValue: 24 * 60 * 60, // 24 hours
  59. Required: true,
  60. DisplayName: "Scan Interval",
  61. Description: "How often to scan for maintenance tasks",
  62. HelpText: "The system will check for new maintenance tasks at this interval",
  63. Placeholder: "30",
  64. Unit: config.UnitMinutes,
  65. InputType: "interval",
  66. CSSClasses: "form-control",
  67. },
  68. {
  69. Name: "worker_timeout_seconds",
  70. JSONName: "worker_timeout_seconds",
  71. Type: config.FieldTypeInterval,
  72. DefaultValue: 5 * 60, // 5 minutes
  73. MinValue: 1 * 60, // 1 minute
  74. MaxValue: 60 * 60, // 1 hour
  75. Required: true,
  76. DisplayName: "Worker Timeout",
  77. Description: "How long to wait for worker heartbeat before considering it inactive",
  78. HelpText: "Workers that don't send heartbeats within this time are considered offline",
  79. Placeholder: "5",
  80. Unit: config.UnitMinutes,
  81. InputType: "interval",
  82. CSSClasses: "form-control",
  83. },
  84. {
  85. Name: "task_timeout_seconds",
  86. JSONName: "task_timeout_seconds",
  87. Type: config.FieldTypeInterval,
  88. DefaultValue: 2 * 60 * 60, // 2 hours
  89. MinValue: 10 * 60, // 10 minutes
  90. MaxValue: 24 * 60 * 60, // 24 hours
  91. Required: true,
  92. DisplayName: "Task Timeout",
  93. Description: "Maximum time allowed for a task to complete",
  94. HelpText: "Tasks that exceed this duration will be marked as failed",
  95. Placeholder: "2",
  96. Unit: config.UnitHours,
  97. InputType: "interval",
  98. CSSClasses: "form-control",
  99. },
  100. {
  101. Name: "retry_delay_seconds",
  102. JSONName: "retry_delay_seconds",
  103. Type: config.FieldTypeInterval,
  104. DefaultValue: 15 * 60, // 15 minutes
  105. MinValue: 1 * 60, // 1 minute
  106. MaxValue: 24 * 60 * 60, // 24 hours
  107. Required: true,
  108. DisplayName: "Retry Delay",
  109. Description: "How long to wait before retrying a failed task",
  110. HelpText: "Failed tasks will be retried after this delay",
  111. Placeholder: "15",
  112. Unit: config.UnitMinutes,
  113. InputType: "interval",
  114. CSSClasses: "form-control",
  115. },
  116. {
  117. Name: "max_retries",
  118. JSONName: "max_retries",
  119. Type: config.FieldTypeInt,
  120. DefaultValue: 3,
  121. MinValue: 0,
  122. MaxValue: 10,
  123. Required: true,
  124. DisplayName: "Max Retries",
  125. Description: "Maximum number of times to retry a failed task",
  126. HelpText: "Tasks that fail more than this many times will be marked as permanently failed",
  127. Placeholder: "3",
  128. Unit: config.UnitCount,
  129. InputType: "number",
  130. CSSClasses: "form-control",
  131. },
  132. {
  133. Name: "cleanup_interval_seconds",
  134. JSONName: "cleanup_interval_seconds",
  135. Type: config.FieldTypeInterval,
  136. DefaultValue: 24 * 60 * 60, // 24 hours
  137. MinValue: 1 * 60 * 60, // 1 hour
  138. MaxValue: 7 * 24 * 60 * 60, // 7 days
  139. Required: true,
  140. DisplayName: "Cleanup Interval",
  141. Description: "How often to run maintenance cleanup operations",
  142. HelpText: "Removes old task records and temporary files at this interval",
  143. Placeholder: "24",
  144. Unit: config.UnitHours,
  145. InputType: "interval",
  146. CSSClasses: "form-control",
  147. },
  148. {
  149. Name: "task_retention_seconds",
  150. JSONName: "task_retention_seconds",
  151. Type: config.FieldTypeInterval,
  152. DefaultValue: 7 * 24 * 60 * 60, // 7 days
  153. MinValue: 1 * 24 * 60 * 60, // 1 day
  154. MaxValue: 30 * 24 * 60 * 60, // 30 days
  155. Required: true,
  156. DisplayName: "Task Retention",
  157. Description: "How long to keep completed task records",
  158. HelpText: "Task history older than this duration will be automatically deleted",
  159. Placeholder: "7",
  160. Unit: config.UnitDays,
  161. InputType: "interval",
  162. CSSClasses: "form-control",
  163. },
  164. {
  165. Name: "global_max_concurrent",
  166. JSONName: "global_max_concurrent",
  167. Type: config.FieldTypeInt,
  168. DefaultValue: 10,
  169. MinValue: 1,
  170. MaxValue: 100,
  171. Required: true,
  172. DisplayName: "Global Max Concurrent Tasks",
  173. Description: "Maximum number of maintenance tasks that can run simultaneously across all workers",
  174. HelpText: "Limits the total number of maintenance operations to control system load",
  175. Placeholder: "10",
  176. Unit: config.UnitCount,
  177. InputType: "number",
  178. CSSClasses: "form-control",
  179. },
  180. },
  181. },
  182. }
  183. }