(ctx context.Context, rep repo.DirectRepositoryWriter)
| 156 | } |
| 157 | |
| 158 | func (c *commandMaintenanceSet) run(ctx context.Context, rep repo.DirectRepositoryWriter) error { |
| 159 | p, err := maintenance.GetParams(ctx, rep) |
| 160 | if err != nil { |
| 161 | return errors.Wrap(err, "unable to get current parameters") |
| 162 | } |
| 163 | |
| 164 | s, err := maintenance.GetSchedule(ctx, rep) |
| 165 | if err != nil { |
| 166 | return errors.Wrap(err, "unable to get current parameters") |
| 167 | } |
| 168 | |
| 169 | var changedParams, changedSchedule bool |
| 170 | |
| 171 | c.setMaintenanceOwnerFromFlags(ctx, p, rep, &changedParams) |
| 172 | c.setMaintenanceEnabledAndIntervalFromFlags(ctx, &p.QuickCycle, "quick", c.maintenanceSetEnableQuick, c.maintenanceSetQuickFrequency, &changedParams) |
| 173 | c.setMaintenanceEnabledAndIntervalFromFlags(ctx, &p.FullCycle, "full", c.maintenanceSetEnableFull, c.maintenanceSetFullFrequency, &changedParams) |
| 174 | c.setLogCleanupParametersFromFlags(ctx, p, &changedParams) |
| 175 | c.setListBlobsParallelismFromFlags(ctx, p, &changedParams) |
| 176 | c.setMaintenanceObjectLockExtendFromFlags(ctx, p, &changedParams) |
| 177 | |
| 178 | if pauseDuration := c.maintenanceSetPauseQuick; pauseDuration != -1 { |
| 179 | s.NextQuickMaintenanceTime = rep.Time().Add(pauseDuration) |
| 180 | changedSchedule = true |
| 181 | |
| 182 | log(ctx).Infof("Quick maintenance paused until %v", formatTimestamp(s.NextQuickMaintenanceTime)) |
| 183 | } |
| 184 | |
| 185 | if pauseDuration := c.maintenanceSetPauseFull; pauseDuration != -1 { |
| 186 | s.NextFullMaintenanceTime = rep.Time().Add(pauseDuration) |
| 187 | changedSchedule = true |
| 188 | |
| 189 | log(ctx).Infof("Full maintenance paused until %v", formatTimestamp(s.NextFullMaintenanceTime)) |
| 190 | } |
| 191 | |
| 192 | if !changedParams && !changedSchedule { |
| 193 | return errors.New("no changes specified") |
| 194 | } |
| 195 | |
| 196 | blobCfg, err := rep.FormatManager().BlobCfgBlob(ctx) |
| 197 | if err != nil { |
| 198 | return errors.Wrap(err, "blob configuration") |
| 199 | } |
| 200 | |
| 201 | if err = maintenance.CheckExtendRetention(ctx, blobCfg, p); err != nil { |
| 202 | return errors.Wrap(err, "unable to apply maintenance changes") |
| 203 | } |
| 204 | |
| 205 | if changedSchedule { |
| 206 | if err := maintenance.SetSchedule(ctx, rep, s); err != nil { |
| 207 | return errors.Wrap(err, "unable to set schedule") |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | if changedParams { |
| 212 | if err := maintenance.SetParams(ctx, rep, p); err != nil { |
| 213 | return errors.Wrap(err, "unable to set params") |
| 214 | } |
| 215 | } |
nothing calls this directly
no test coverage detected