-
Notifications
You must be signed in to change notification settings - Fork 163
/
atomic_release.go
561 lines (487 loc) · 22.6 KB
/
atomic_release.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
/*
Copyright 2022 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package reconcile
import (
"context"
"errors"
"fmt"
"strings"
"time"
"helm.sh/helm/v3/pkg/kube"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/runtime/conditions"
"github.com/fluxcd/pkg/runtime/logger"
"github.com/fluxcd/pkg/runtime/patch"
"github.com/fluxcd/pkg/ssa/jsondiff"
v2 "github.com/fluxcd/helm-controller/api/v2"
"github.com/fluxcd/helm-controller/internal/action"
"github.com/fluxcd/helm-controller/internal/diff"
"github.com/fluxcd/helm-controller/internal/digest"
interrors "github.com/fluxcd/helm-controller/internal/errors"
"github.com/fluxcd/helm-controller/internal/postrender"
)
// OwnedConditions is a list of Condition types owned by the HelmRelease object.
var OwnedConditions = []string{
v2.ReleasedCondition,
v2.RemediatedCondition,
v2.TestSuccessCondition,
meta.ReconcilingCondition,
meta.ReadyCondition,
meta.StalledCondition,
}
var (
// ErrExceededMaxRetries is returned when there are no remaining retry
// attempts for the provided release config.
ErrExceededMaxRetries = errors.New("exceeded maximum retries")
// ErrMustRequeue is returned when the caller must requeue the object
// to continue the reconciliation process.
ErrMustRequeue = errors.New("must requeue")
// ErrMissingRollbackTarget is returned when the rollback target is missing.
ErrMissingRollbackTarget = errors.New("missing target release for rollback")
// ErrUnknownReleaseStatus is returned when the release status is unknown
// and cannot be acted upon.
ErrUnknownReleaseStatus = errors.New("unknown release status")
// ErrUnknownRemediationStrategy is returned when the remediation strategy
// is unknown.
ErrUnknownRemediationStrategy = errors.New("unknown remediation strategy")
)
// AtomicRelease is an ActionReconciler which implements an atomic release
// strategy similar to Helm's `--atomic`, but with more advanced state
// determination. It determines the next action to take based on the current
// state of the Request.Object and other data, and the state of the Helm
// release.
//
// This process will continue until an action is called multiple times, no
// action remains, or a remediation action is called. In which case, the process
// will stop to be resumed at a later time or be checked upon again, by e.g. a
// requeue.
//
// Before running the ActionReconciler for the next action, the object is
// marked with Reconciling=True and the status is patched.
// This condition is removed when the ActionReconciler process is done.
//
// When it determines the object is out of remediation retries, the object
// is marked with Stalled=True.
//
// The status conditions are summarized into a Ready condition when no actions
// to be run remain, to ensure any transient error is cleared.
//
// Any returned error other than ErrExceededMaxRetries should be retried by the
// caller as soon as possible, preferably with a backoff strategy. In case of
// ErrMustRequeue, it is advised to requeue the object outside the interval
// to ensure continued progress.
//
// The caller is expected to patch the object one last time with the
// Request.Object result to persist the final observation. As there is an
// expectation they will need to patch the object anyway to e.g. update the
// ObservedGeneration.
//
// For more information on the individual ActionReconcilers, refer to their
// documentation.
type AtomicRelease struct {
patchHelper *patch.SerialPatcher
configFactory *action.ConfigFactory
eventRecorder record.EventRecorder
strategy releaseStrategy
fieldManager string
}
// NewAtomicRelease returns a new AtomicRelease reconciler configured with the
// provided values.
func NewAtomicRelease(patchHelper *patch.SerialPatcher, cfg *action.ConfigFactory, recorder record.EventRecorder, fieldManager string) *AtomicRelease {
return &AtomicRelease{
patchHelper: patchHelper,
eventRecorder: recorder,
configFactory: cfg,
strategy: &cleanReleaseStrategy{},
fieldManager: fieldManager,
}
}
// releaseStrategy defines the continue-stop behavior of the reconcile loop.
type releaseStrategy interface {
// MustContinue should be called before running the current action, and
// returns true if the caller must proceed.
MustContinue(current ReconcilerType, previous ReconcilerTypeSet) bool
// MustStop should be called after running the current action, and returns
// true if the caller must stop.
MustStop(current ReconcilerType, previous ReconcilerTypeSet) bool
}
// cleanReleaseStrategy is a releaseStrategy which will only execute the
// (remaining) actions for a single release. Effectively, this means it will
// only run any action once during a reconcile attempt, and stops after running
// a remediation action.
type cleanReleaseStrategy ReconcilerTypeSet
// MustContinue returns if previous does not contain current.
func (cleanReleaseStrategy) MustContinue(current ReconcilerType, previous ReconcilerTypeSet) bool {
return !previous.Contains(current)
}
// MustStop returns true if current equals ReconcilerTypeRemediate.
func (cleanReleaseStrategy) MustStop(current ReconcilerType, _ ReconcilerTypeSet) bool {
switch current {
case ReconcilerTypeRemediate:
return true
default:
return false
}
}
func (r *AtomicRelease) Reconcile(ctx context.Context, req *Request) error {
log := ctrl.LoggerFrom(ctx).V(logger.InfoLevel)
var (
previous ReconcilerTypeSet
next ActionReconciler
)
for {
select {
case <-ctx.Done():
if errors.Is(ctx.Err(), context.Canceled) || errors.Is(ctx.Err(), context.DeadlineExceeded) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
// If the context is canceled, we still need to persist any
// last observation before returning. If the patch fails, we
// log the error and return the original context cancellation
// error.
if err := r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner(r.fieldManager)); err != nil {
log.Error(err, "failed to patch HelmRelease after context cancellation")
}
cancel()
}
return fmt.Errorf("atomic release canceled: %w", ctx.Err())
default:
// Determine the current state of the Helm release.
log.V(logger.DebugLevel).Info("determining current state of Helm release")
state, err := DetermineReleaseState(ctx, r.configFactory, req)
if err != nil {
conditions.MarkFalse(req.Object, meta.ReadyCondition, "StateError", "Could not determine release state: %s", err)
return fmt.Errorf("cannot determine release state: %w", err)
}
// Determine the next action to run based on the current state.
log.V(logger.DebugLevel).Info("determining next Helm action based on current state")
if next, err = r.actionForState(ctx, req, state); err != nil {
if errors.Is(err, ErrExceededMaxRetries) {
conditions.MarkStalled(req.Object, "RetriesExceeded", "Failed to %s after %d attempt(s)",
req.Object.Status.LastAttemptedReleaseAction, req.Object.GetActiveRemediation().GetFailureCount(req.Object))
return err
}
if errors.Is(err, ErrMissingRollbackTarget) {
conditions.MarkStalled(req.Object, "MissingRollbackTarget", "Failed to perform remediation: %s", err)
return err
}
return err
}
// If there is no next action, we are done.
if next == nil {
conditions.Delete(req.Object, meta.ReconcilingCondition)
// Always summarize; this ensures we restore transient errors
// written to Ready.
summarize(req)
// remove stale post-renderers digest on successful reconciliation.
if conditions.IsReady(req.Object) {
req.Object.Status.ObservedPostRenderersDigest = ""
if req.Object.Spec.PostRenderers != nil {
// Update the post-renderers digest if the post-renderers exist.
req.Object.Status.ObservedPostRenderersDigest = postrender.Digest(digest.Canonical, req.Object.Spec.PostRenderers).String()
}
}
return nil
}
// If we are not allowed to run the next action, we are done for now...
if !r.strategy.MustContinue(next.Type(), previous) {
log.V(logger.DebugLevel).Info(
fmt.Sprintf("instructed to stop before running %s action reconciler %s", next.Type(), next.Name()),
)
if remediation := req.Object.GetActiveRemediation(); remediation == nil || !remediation.RetriesExhausted(req.Object) {
conditions.MarkReconciling(req.Object, meta.ProgressingWithRetryReason, "%s", conditions.GetMessage(req.Object, meta.ReadyCondition))
return ErrMustRequeue
}
conditions.Delete(req.Object, meta.ReconcilingCondition)
return nil
}
// Mark the release as reconciling before we attempt to run the action.
// This to show continuous progress, as Helm actions can be long-running.
reconcilingMsg := fmt.Sprintf("Running '%s' action with timeout of %s",
next.Name(), timeoutForAction(next, req.Object).String())
conditions.MarkReconciling(req.Object, meta.ProgressingReason, "%s", reconcilingMsg)
// If the next action is a release action, we can mark the release
// as progressing in terms of readiness as well. Doing this for any
// other action type is not useful, as it would potentially
// overwrite more important failure state from an earlier action.
if next.Type() == ReconcilerTypeRelease {
conditions.MarkUnknown(req.Object, meta.ReadyCondition, meta.ProgressingReason, "%s", reconcilingMsg)
}
// Patch the object to reflect the new condition.
if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner(r.fieldManager)); err != nil {
return err
}
// Run the action sub-reconciler.
log.Info(fmt.Sprintf("running '%s' action with timeout of %s", next.Name(), timeoutForAction(next, req.Object).String()))
if err = next.Reconcile(ctx, req); err != nil {
if conditions.IsReady(req.Object) {
conditions.MarkFalse(req.Object, meta.ReadyCondition, "ReconcileError", "%s", err)
}
return err
}
// If we must stop after running the action, we are done for now...
if r.strategy.MustStop(next.Type(), previous) {
log.V(logger.DebugLevel).Info(fmt.Sprintf(
"instructed to stop after running %s action reconciler %s", next.Type(), next.Name()),
)
remediation := req.Object.GetActiveRemediation()
if remediation == nil || !remediation.RetriesExhausted(req.Object) {
conditions.MarkReconciling(req.Object, meta.ProgressingWithRetryReason, "%s", conditions.GetMessage(req.Object, meta.ReadyCondition))
return ErrMustRequeue
}
// Check if retries have exhausted after remediation for early
// stall condition detection.
if remediation != nil && remediation.RetriesExhausted(req.Object) {
conditions.MarkStalled(req.Object, "RetriesExceeded", "Failed to %s after %d attempt(s)",
req.Object.Status.LastAttemptedReleaseAction, req.Object.GetActiveRemediation().GetFailureCount(req.Object))
return ErrExceededMaxRetries
}
conditions.Delete(req.Object, meta.ReconcilingCondition)
return nil
}
// Append the type to the set of action types we have performed.
previous = append(previous, next.Type())
// Patch the release to reflect progress.
if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner(r.fieldManager)); err != nil {
return err
}
}
}
}
// actionForState determines the next action to run based on the current state.
func (r *AtomicRelease) actionForState(ctx context.Context, req *Request, state ReleaseState) (ActionReconciler, error) {
log := ctrl.LoggerFrom(ctx)
// Determine whether we may need to force a release action.
// We do this before determining the next action to run, as otherwise we may
// end up running a Helm upgrade (due to e.g. ReleaseStatusUnmanaged) and
// then forcing an upgrade (due to the release now being in
// ReleaseStatusInSync with a yet unhandled force request).
forceRequested := v2.ShouldHandleForceRequest(req.Object)
switch state.Status {
case ReleaseStatusInSync:
log.Info("release in-sync with desired state")
// Remove all history up to the previous release action.
// We need to continue to hold on to the previous release result
// to ensure we can e.g. roll back when tests are enabled without
// any further changes to the release.
ignoreFailures := req.Object.GetTest().IgnoreFailures
if remediation := req.Object.GetActiveRemediation(); remediation != nil {
ignoreFailures = remediation.MustIgnoreTestFailures(req.Object.GetTest().IgnoreFailures)
}
req.Object.Status.History.Truncate(ignoreFailures)
if forceRequested {
log.Info(msgWithReason("forcing upgrade for in-sync release", "force requested through annotation"))
return NewUpgrade(r.configFactory, r.eventRecorder), nil
}
// Since the release is in-sync, remove any remediated condition if
// present and replace it with upgrade succeeded condition.
// This can happen when the current release, which is the result of a
// rollback remediation, matches the new desired configuration due to
// having the same chart version and values. As a result, we are already
// in-sync without performing a release action.
if conditions.IsTrue(req.Object, v2.RemediatedCondition) {
cur := req.Object.Status.History.Latest()
msg := fmt.Sprintf(fmtUpgradeSuccess, cur.FullReleaseName(), cur.VersionedChartName())
replaceCondition(req.Object, v2.RemediatedCondition, v2.ReleasedCondition, v2.UpgradeSucceededReason, msg, metav1.ConditionTrue)
}
return nil, nil
case ReleaseStatusLocked:
log.Info(msgWithReason("release locked", state.Reason))
return NewUnlock(r.configFactory, r.eventRecorder), nil
case ReleaseStatusAbsent:
log.Info(msgWithReason("release not installed", state.Reason))
if req.Object.GetInstall().GetRemediation().RetriesExhausted(req.Object) {
if forceRequested {
log.Info(msgWithReason("forcing install while out of retries", "force requested through annotation"))
return NewInstall(r.configFactory, r.eventRecorder), nil
}
return nil, fmt.Errorf("%w: cannot install release", ErrExceededMaxRetries)
}
return NewInstall(r.configFactory, r.eventRecorder), nil
case ReleaseStatusUnmanaged:
log.Info(msgWithReason("release not managed by controller", state.Reason))
// Clear the history as we can no longer rely on it.
req.Object.Status.ClearHistory()
return NewUpgrade(r.configFactory, r.eventRecorder), nil
case ReleaseStatusOutOfSync:
log.Info(msgWithReason("release out-of-sync with desired state", state.Reason))
if req.Object.GetUpgrade().GetRemediation().RetriesExhausted(req.Object) {
if forceRequested {
log.Info(msgWithReason("forcing upgrade while out of retries", "force requested through annotation"))
return NewUpgrade(r.configFactory, r.eventRecorder), nil
}
return nil, fmt.Errorf("%w: cannot upgrade release", ErrExceededMaxRetries)
}
return NewUpgrade(r.configFactory, r.eventRecorder), nil
case ReleaseStatusDrifted:
log.Info(msgWithReason("detected changes in cluster state", diff.SummarizeDiffSetBrief(state.Diff)))
for _, change := range state.Diff {
switch change.Type {
case jsondiff.DiffTypeCreate:
log.V(logger.DebugLevel).Info("resource deleted",
"resource", diff.ResourceName(change.DesiredObject))
case jsondiff.DiffTypeUpdate:
patch := change.Patch
if change.DesiredObject.GetObjectKind().GroupVersionKind().Kind == "Secret" {
patch = jsondiff.MaskSecretPatchData(change.Patch)
}
log.V(logger.DebugLevel).Info("resource modified",
"resource", diff.ResourceName(change.DesiredObject),
"patch", patch)
}
}
r.eventRecorder.Eventf(req.Object, corev1.EventTypeWarning, "DriftDetected",
"Cluster state of release %s has drifted from the desired state:\n%s",
req.Object.Status.History.Latest().FullReleaseName(), diff.SummarizeDiffSet(state.Diff),
)
if req.Object.GetDriftDetection().GetMode() == v2.DriftDetectionEnabled {
return NewCorrectClusterDrift(r.configFactory, r.eventRecorder, state.Diff, kube.ManagedFieldsManager), nil
}
return nil, nil
case ReleaseStatusUntested:
log.Info(msgWithReason("release has not been tested", state.Reason))
// Since an untested release indicates that the release is already
// in-sync, remove any remediated condition if present and replace it
// with upgrade succeeded condition.
// This can happen when an untested current release, which is the result
// of a rollback remediation, matches the new desired configuration due
// to having the same chart version and values, and has test enabled. As
// a result, we are already in-sync without performing a release action,
// the existing release needs to undergo testing.
if conditions.IsTrue(req.Object, v2.RemediatedCondition) {
cur := req.Object.Status.History.Latest()
msg := fmt.Sprintf(fmtUpgradeSuccess, cur.FullReleaseName(), cur.VersionedChartName())
replaceCondition(req.Object, v2.RemediatedCondition, v2.ReleasedCondition, v2.UpgradeSucceededReason, msg, metav1.ConditionTrue)
}
return NewTest(r.configFactory, r.eventRecorder), nil
case ReleaseStatusFailed:
log.Info(msgWithReason("release is in a failed state", state.Reason))
remediation := req.Object.GetActiveRemediation()
// If there is no active remediation strategy, we can only attempt to
// upgrade the release to see if that fixes the problem.
if remediation == nil {
log.V(logger.DebugLevel).Info("no active remediation strategy")
return NewUpgrade(r.configFactory, r.eventRecorder), nil
}
// If there is no failure count, the conditions under which the failure
// occurred must have changed.
// Attempt to upgrade the release to see if the problem is resolved.
// This ensures that after a configuration change, the release is
// attempted again.
if remediation.GetFailureCount(req.Object) <= 0 {
log.Info("release conditions have changed since last failure")
return NewUpgrade(r.configFactory, r.eventRecorder), nil
}
// If the force annotation is set, we can attempt to upgrade the release
// without any further checks.
if forceRequested {
log.Info(msgWithReason("forcing upgrade for failed release", "force requested through annotation"))
return NewUpgrade(r.configFactory, r.eventRecorder), nil
}
// We have exhausted the number of retries for the remediation
// strategy.
if remediation.RetriesExhausted(req.Object) && !remediation.MustRemediateLastFailure() {
return nil, fmt.Errorf("%w: cannot remediate failed release", ErrExceededMaxRetries)
}
// Reset the history up to the point where the failure occurred.
// This ensures we do not accumulate a long history of failures.
req.Object.Status.History.Truncate(remediation.MustIgnoreTestFailures(req.Object.GetTest().IgnoreFailures))
switch remediation.GetStrategy() {
case v2.RollbackRemediationStrategy:
// Verify the previous release is still in storage and unmodified
// before instructing to roll back to it.
prev := req.Object.Status.History.Previous(remediation.MustIgnoreTestFailures(req.Object.GetTest().IgnoreFailures))
if _, err := action.VerifySnapshot(r.configFactory.Build(nil), prev); err != nil {
if errors.Is(err, action.ErrReleaseNotFound) {
// If the rollback target is missing, we cannot roll back
// to it and must fail.
return nil, fmt.Errorf("%w: cannot remediate failed release", ErrMissingRollbackTarget)
}
if interrors.IsOneOf(err, action.ErrReleaseDisappeared, action.ErrReleaseNotObserved, action.ErrReleaseDigest) {
// If the rollback target is in any way corrupt,
// the most correct remediation is to reattempt the upgrade.
log.Info(msgWithReason("unable to verify previous release in storage to roll back to", err.Error()))
return NewUpgrade(r.configFactory, r.eventRecorder), nil
}
// This may be a temporary error, return it to retry.
return nil, fmt.Errorf("cannot verify previous release to roll back to: %w", err)
}
return NewRollbackRemediation(r.configFactory, r.eventRecorder), nil
case v2.UninstallRemediationStrategy:
return NewUninstallRemediation(r.configFactory, r.eventRecorder), nil
default:
return nil, fmt.Errorf("%w: %s", ErrUnknownRemediationStrategy, remediation.GetStrategy())
}
default:
return nil, fmt.Errorf("%w: %s", ErrUnknownReleaseStatus, state.Status)
}
}
func (r *AtomicRelease) Name() string {
return "atomic-release"
}
func (r *AtomicRelease) Type() ReconcilerType {
return ReconcilerTypeRelease
}
func msgWithReason(msg, reason string) string {
if reason != "" {
return fmt.Sprintf("%s: %s", msg, reason)
}
return msg
}
func inStringSlice(ss []string, str string) (pos int, ok bool) {
for k, s := range ss {
if strings.EqualFold(s, str) {
return k, true
}
}
return -1, false
}
func timeoutForAction(action ActionReconciler, obj *v2.HelmRelease) time.Duration {
switch action.(type) {
case *Install:
return obj.GetInstall().GetTimeout(obj.GetTimeout()).Duration
case *Upgrade:
return obj.GetUpgrade().GetTimeout(obj.GetTimeout()).Duration
case *Test:
return obj.GetTest().GetTimeout(obj.GetTimeout()).Duration
case *RollbackRemediation:
return obj.GetRollback().GetTimeout(obj.GetTimeout()).Duration
case *UninstallRemediation:
return obj.GetUninstall().GetTimeout(obj.GetTimeout()).Duration
default:
return obj.GetTimeout().Duration
}
}
// replaceCondition replaces existing target condition with replacement
// condition, if present, for the given values, retaining the
// LastTransitionTime.
func replaceCondition(obj *v2.HelmRelease, target string, replacement string, reason string, msg string, status metav1.ConditionStatus) {
c := conditions.Get(obj, target)
if c != nil {
// Remove any existing replacement condition to retain the
// LastTransitionTime set here. If the state of the new condition
// changes an existing condition, the LastTransitionTime is updated to
// the current time.
// Refer https://github.com/fluxcd/pkg/blob/runtime/v0.43.0/runtime/conditions/setter.go#L54-L55.
conditions.Delete(obj, replacement)
c.Status = status
c.Type = replacement
c.Reason = reason
c.Message = msg
conditions.Set(obj, c)
conditions.Delete(obj, target)
}
}