Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
Use AppConfig's generation to get latest dependency only
Browse files Browse the repository at this point in the history
- pass AC's generation into child objects' labels
- check generation in getting data input
  • Loading branch information
hongchaodeng committed Sep 28, 2020
1 parent 02cd150 commit a35dd79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/controller/v1alpha2/applicationconfiguration/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"strconv"

runtimev1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
"github.com/crossplane/crossplane-runtime/pkg/fieldpath"
Expand Down Expand Up @@ -136,6 +137,7 @@ func (r *components) renderComponent(ctx context.Context, acc v1alpha2.Applicati
oam.LabelAppComponent: acc.ComponentName,
oam.LabelAppComponentRevision: componentRevisionName,
oam.LabelOAMResourceType: oam.ResourceTypeWorkload,
oam.LabelAppGeneration: strconv.FormatInt(ac.Generation, 10),
}
util.AddLabels(w, compInfoLabels)

Expand Down Expand Up @@ -494,9 +496,14 @@ func (r *components) getDataInput(ctx context.Context, s *dagSource, ac *unstruc
u.SetGroupVersionKind(obj.GroupVersionKind())
err := r.client.Get(ctx, key, u)
if err != nil {
reason := fmt.Sprintf("failed to get object (%s)", key.String())
reason := fmt.Sprintf("failed to get object (%s): %v", key.String(), err)
return nil, false, reason, errors.Wrap(resource.IgnoreNotFound(err), reason)
}
//
if u.GetLabels()[oam.LabelAppGeneration] != strconv.FormatInt(ac.GetGeneration(), 10) {
return nil, false, "generation not match", nil
}

paved := fieldpath.Pave(u.UnstructuredContent())
pavedAC := fieldpath.Pave(ac.UnstructuredContent())

Expand Down
2 changes: 2 additions & 0 deletions pkg/oam/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const (
LabelAppComponent = "app.oam.dev/component"
// LabelAppComponentRevision records the revision name of Component
LabelAppComponentRevision = "app.oam.dev/revision"
// LabelAppGeneration records the generation of AppConfig
LabelAppGeneration = "app.oam.dev/generation"
// LabelOAMResourceType whether a CR is workload or trait
LabelOAMResourceType = "app.oam.dev/resourceType"
)
Expand Down

0 comments on commit a35dd79

Please sign in to comment.