Skip to content

Commit ac8b92a

Browse files
committed
improve comments
1 parent 6edde34 commit ac8b92a

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

pkg/component/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"strings"
1212
)
1313

14-
// TODO: consolidate all the util files into an own internal reuse packages
14+
// TODO: consolidate all the util files into an internal reuse package
1515

1616
func ref[T any](x T) *T {
1717
return &x

pkg/manifests/helm/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func NewHelmGenerator(fsys fs.FS, chartPath string, clnt client.Client) (*HelmGe
178178
return nil, err
179179
}
180180
// Note: we use absolute paths (instead of relative ones) as template names
181-
// because the 'Template' builtin needs that to work properly
181+
// because the 'Template' builtin variable needs that to work properly
182182
t = t.New(include)
183183
if _, err := t.Parse(string(raw)); err != nil {
184184
return nil, err

pkg/manifests/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"k8s.io/apimachinery/pkg/runtime"
1010
)
1111

12+
// TODO: consolidate all the util files into an internal reuse package
13+
1214
// Deep-merge two maps with the usual logic and return the result.
1315
// The first map (x) must be deeply JSON (i.e. consist deeply of JSON values only).
1416
// The maps given as input will not be changed.

pkg/reconciler/reconciler.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ func NewReconciler(name string, clnt cluster.Client, options ReconcilerOptions)
186186
//
187187
// Objects will be applied and deleted in waves, according to their apply/delete order. Objects which specify a purge order will be deleted from the cluster at the
188188
// end of the wave specified as purge order; other than redundant objects, a purged object will remain as Completed in the inventory;
189-
// and it might be re-applied/re-purged in case it runs out of sync.
189+
// and it might be re-applied/re-purged in case it runs out of sync. Within a wave, objects are processed following a certain internal order;
190+
// in particular, instances of types which are part of the wave are processed only if all other objects in that wave have a ready state.
190191
//
191192
// This method will change the passed inventory (add or remove elements, change elements). If Apply() returns true, then all objects are successfully reconciled;
192193
// otherwise, if it returns false, the caller should recall it timely, until it returns true. In any case, the passed inventory should match the state of the
@@ -293,11 +294,11 @@ func (r *Reconciler) Apply(ctx context.Context, inventory *[]*InventoryItem, obj
293294
// - have a namespace set although they are not namespaced
294295
// - do not have a namespace set although they are namespaced
295296
// which exactly happens if
296-
// 1. the object is incorrectly specified
297+
// 1. the object is incorrectly specified and
297298
// 2. calling RESTMapping() above returned a NoMatchError (i.e. the type is currently not known to the api server) and
298-
// 3. the type belongs to a (new) api service which is part of this component
299+
// 3. the type belongs to a (new) api service which is part of the inventory
299300
// such entries can cause trouble, e.g. because InventoryItem.Match() might not work reliably ...
300-
// TODO: should we allow at all that api services and according instances are part of the same component?
301+
// TODO: should we allow at all that api services and according instances are deployed together?
301302

302303
// validate annotations
303304
for _, object := range objects {
@@ -394,9 +395,10 @@ func (r *Reconciler) Apply(ctx context.Context, inventory *[]*InventoryItem, obj
394395
case ReconcilePolicyOnObjectOrComponentChange:
395396
digest = fmt.Sprintf("%s@%d", digest, componentRevision)
396397
case ReconcilePolicyOnce:
397-
// note: if the object already existed with a different reconcile policy, then it will get reconciled one (and only one) more time
398398
digest = "__once__"
399399
}
400+
// note: if the effective reconcile policy of an object changes, it will always be reconciled at least one more time;
401+
// this is in particular the case if the policy changes from or to ReconcilePolicyOnce.
400402

401403
// if item was not found, append an empty item
402404
if item == nil {
@@ -763,6 +765,15 @@ func (r *Reconciler) Apply(ctx context.Context, inventory *[]*InventoryItem, obj
763765
return numUnready == 0, nil
764766
}
765767

768+
// Delete objects stored in the inventory from the target cluster and maintain inventory.
769+
// Objects will be deleted in waves, according to their delete order (as stored in the inventory); that means, the deletion of
770+
// objects having a certain delete order will only start if all objects with lower delete order are gone. Within a wave, objects are
771+
// deleted following a certain internal ordering; in particular, if there are instances of types which are part of the wave, then these
772+
// instances will be deleted first; only if all such instances are gone, the remaining objects of the wave will be deleted.
773+
//
774+
// This method will change the passed inventory (remove elements, change elements). If Delete() returns true, then all objects are gone; otherwise,
775+
// if it returns false, the caller should recall it timely, until it returns true. In any case, the passed inventory should match the state of the
776+
// inventory after the previous invocation of Delete(); usually, the caller saves the inventory after calling Delete(), and loads it before calling Delete().
766777
func (r *Reconciler) Delete(ctx context.Context, inventory *[]*InventoryItem) (bool, error) {
767778
log := log.FromContext(ctx)
768779

@@ -842,6 +853,9 @@ func (r *Reconciler) Delete(ctx context.Context, inventory *[]*InventoryItem) (b
842853
return len(*inventory) == 0, nil
843854
}
844855

856+
// Check if the object set defined by inventory is ready for deletion; that means: check if the inventory contains
857+
// types (as custom resource definition or from an api service), while there exist instances of these types in the cluster,
858+
// which are not contained in the inventory.
845859
func (r *Reconciler) IsDeletionAllowed(ctx context.Context, inventory *[]*InventoryItem) (bool, string, error) {
846860
for _, item := range *inventory {
847861
switch {

pkg/reconciler/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"github.com/sap/component-operator-runtime/pkg/types"
2626
)
2727

28+
// TODO: consolidate all the util files into an internal reuse package
29+
2830
func ref[T any](x T) *T {
2931
return &x
3032
}

0 commit comments

Comments
 (0)