Skip to content

Conversation

vijtrip2
Copy link
Contributor

@vijtrip2 vijtrip2 commented Jul 26, 2021

Issue #, if available: aws-controllers-k8s/community#812

Description of changes:

  • Initial implementation of AWSResourceManager.LateInitialize() method code generator
  • Adds two new hooks late_initialize_pre_read_one & late_initialize_post_read_one
  • Introduces new LateInitializeConfig with DelaySeconds as single parameter
  • Corresponding runtime PR : Initial changes for late initializing resource fields. runtime#37

Testing

  • Unit Tests Successful
➜  code-generator git:(li-mlp) ✗ make test
go test -tags codegen ./...
?       github.com/aws-controllers-k8s/code-generator/cmd/ack-generate  [no test files]
?       github.com/aws-controllers-k8s/code-generator/cmd/ack-generate/command  [no test files]
ok      github.com/aws-controllers-k8s/code-generator/pkg/generate/ack  2.346s
ok      github.com/aws-controllers-k8s/code-generator/pkg/generate/code 17.798s
?       github.com/aws-controllers-k8s/code-generator/pkg/generate/config       [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/generate/crossplane   [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/generate/olm  [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/generate/templateset  [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/metadata      [no test files]
ok      github.com/aws-controllers-k8s/code-generator/pkg/model 14.671s
ok      github.com/aws-controllers-k8s/code-generator/pkg/model/multiversion    5.152s
ok      github.com/aws-controllers-k8s/code-generator/pkg/names (cached)
?       github.com/aws-controllers-k8s/code-generator/pkg/testutil      [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/util  [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/version       [no test files]

  • Controller generation successful
➜  code-generator git:(li-mlp) ✗ make build-controller                
building ack-generate ... ok.
installing controller-gen v0.6.1 ... ok.
Copying common custom resource definitions into ecr
Building Kubernetes API objects for ecr
Generating deepcopy code for ecr
Generating custom resource definitions for ecr
Building service controller for ecr
Generating RBAC manifests for ecr
Running gofmt against generated code for ecr

  • Sample generated code for ecr repository
// LateInitialize returns an acktypes.AWSResource after setting the late initialized
// fields from the readOne call. This method will initialize the optional fields
// which were not provided by the k8s user but were defaulted by the AWS service.
// If there are no such fields to be initialized, the returned object is similar to
// object passed in the parameter.
func (rm *resourceManager) LateInitialize(
	ctx context.Context,
	res acktypes.AWSResource,
) (acktypes.AWSResource, error) {
	rlog := ackrtlog.FromContext(ctx)
	// If there are no fields to late initialize, do nothing
	if len(lateInitializeFieldNames) == 0 {
		rlog.Debug("no late initialization required.")
		return res, nil
	}
	r := rm.concreteResource(res)
	if r.ko == nil {
		// Should never happen... if it does, it's buggy code.
		panic("resource manager's LateInitialize() method received resource with nil CR object")
	}
	koWithDefaults := r.ko.DeepCopy()
	latestWithDefaults := &resource{koWithDefaults}
	lateInitConditionReason := ""
	lateInitConditionMessage := ""

	observed, err := rm.sdkFind(ctx, latestWithDefaults)
	if err != nil {
		lateInitConditionMessage = "Unable to complete Read operation required for late initialization"
		lateInitConditionReason = "Late Initialization Failure"
		ackcondition.SetLateInitialized(latestWithDefaults, corev1.ConditionFalse, &lateInitConditionMessage, &lateInitConditionReason)
		return latestWithDefaults, ackrequeue.NeededAfter(err, time.Duration(0)*time.Second)
	}
	observedKo := observed.ko
	if observedKo.Spec.Name != nil && koWithDefaults.Spec.Name == nil {
		koWithDefaults.Spec.Name = observedKo.Spec.Name
	}

	incompleteInitialization := rm.incompleteLateInitialization(latestWithDefaults)
	if incompleteInitialization {
		// Add the condition with LateInitialized=False
		lateInitConditionMessage = "Late initialization did not complete, requeuing with delay of 5 seconds"
		lateInitConditionReason = "Delayed Late Initialization"
		ackcondition.SetLateInitialized(latestWithDefaults, corev1.ConditionFalse, &lateInitConditionMessage, &lateInitConditionReason)
		return latestWithDefaults, ackrequeue.NeededAfter(nil, time.Duration(5)*time.Second)
	}
	// Set LateIntialized condition to True
	lateInitConditionMessage = "Late initialization successful"
	lateInitConditionReason = "Late initialization successful"
	ackcondition.SetLateInitialized(latestWithDefaults, corev1.ConditionTrue, &lateInitConditionMessage, &lateInitConditionReason)
	return latestWithDefaults, nil
}

// incompleteLateInitialization return true if there are fields which were supposed to be
// late initialized but are not. If all the fields are late initialized, false is returned
func (rm *resourceManager) incompleteLateInitialization(
	latestWithDefaults *resource,
) bool {
	ko := latestWithDefaults.ko
	if ko.Spec.Name == nil {
		return true
	}
	return false

}
  • local-kind-e2e-test logs
                                                                                                    │
│ 2021-07-26T19:38:08.701Z    DEBUG    ackrt    > r.Sync    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "kind": "Repository" │
│ 2021-07-26T19:38:08.701Z    DEBUG    ackrt    >> rm.ReadOne    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": f │
│ 2021-07-26T19:38:08.701Z    DEBUG    ackrt    >>> rm.sdkFind    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted":  │
│ 2021-07-26T19:38:09.641Z    DEBUG    ackrt    <<< rm.sdkFind    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted":  │
│ 2021-07-26T19:38:09.641Z    DEBUG    ackrt    << rm.ReadOne    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": f │
│ 2021-07-26T19:38:09.641Z    DEBUG    ackrt    >> r.setResourceManaged    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_a │
│ 2021-07-26T19:38:09.641Z    DEBUG    ackrt    >>> kc.Patch (metadata + spec)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2" │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    <<< kc.Patch (metadata + spec)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2" │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    marked resource as managed    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "i │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    << r.setResourceManaged    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_a │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    >> rm.Create    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": fa │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    >>> rm.sdkCreate    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted" │
│ 2021-07-26T19:38:09.725Z    DEBUG    ackrt    <<< rm.sdkCreate    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted" │
│ 2021-07-26T19:38:09.725Z    DEBUG    ackrt    << rm.Create    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": fa │
│ 2021-07-26T19:38:09.725Z    INFO    ackrt    created new resource    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopt │
│ 2021-07-26T19:38:09.725Z    DEBUG    ackrt    >> rm.LateInitialize    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adop │
│ 2021-07-26T19:38:09.725Z    INFO    ackrt    calculated late initialization delay is 0 seconds    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "re │
│ 2021-07-26T19:38:09.725Z    DEBUG    ackrt    >>> rm.sdkFind    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted":  │
│ 2021-07-26T19:38:09.748Z    DEBUG    ackrt    <<< rm.sdkFind    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted":  │
│ 2021-07-26T19:38:09.748Z    DEBUG    ackrt    << rm.LateInitialize    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adop │
│ 2021-07-26T19:38:09.748Z    DEBUG    ackrt    >> r.patchResourceMetadataAndSpec    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west │
│ 2021-07-26T19:38:09.748Z    DEBUG    ackrt    >>> kc.Patch (metadata + spec)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2" │
│ 2021-07-26T19:38:09.758Z    DEBUG    ackrt    <<< kc.Patch (metadata + spec)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2" │
│ 2021-07-26T19:38:09.759Z    DEBUG    ackrt    patched resource metadata and spec    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-wes │
│ 2021-07-26T19:38:09.759Z    DEBUG    ackrt    << r.patchResourceMetadataAndSpec    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west │
│ 2021-07-26T19:38:09.759Z    DEBUG    ackrt    >> r.patchResourceStatus    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_ │
│ 2021-07-26T19:38:09.759Z    DEBUG    ackrt    >>> kc.Patch (status)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_ado │
│ 2021-07-26T19:38:09.794Z    DEBUG    ackrt    <<< kc.Patch (status)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_ado │
│ 2021-07-26T19:38:09.795Z    DEBUG    ackrt    patched resource status    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_a │
│ 2021-07-26T19:38:09.795Z    DEBUG    ackrt    << r.patchResourceStatus    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_ │
│ 2021-07-26T19:38:09.795Z    DEBUG    ackrt    < r.Sync    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": false, │
│ 2021-07-26T19:38:09.795Z    DEBUG    controller-runtime.controller    Successfully Reconciled    {"controller": "repository", "request": "default/ecr-repository-wy6n6wjm8"}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@vijtrip2 vijtrip2 added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2021
@ack-bot ack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2021
@vijtrip2 vijtrip2 added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2021
@vijtrip2 vijtrip2 requested a review from jaypipes July 26, 2021 07:37
@ack-bot ack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2021
@vijtrip2 vijtrip2 added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2021
@ack-bot ack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 27, 2021
@vijtrip2
Copy link
Contributor Author

IMO, this PR should be good to review, merge now.
The only TODO left is implementing retry-backoff strategy for late initialization which I will start working on as part of aws-controllers-k8s/community#879 and send in a separate PR.

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niice! Great start on this @vijtrip2!
I left few comments below

@vijtrip2 vijtrip2 requested a review from a-hilaly July 27, 2021 23:42
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM! 👍

Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this implementation could be significantly simpler... with virtually no code-generating changes needed at all.

@vijtrip2 vijtrip2 requested a review from jaypipes August 3, 2021 22:07
ack-bot pushed a commit to aws-controllers-k8s/runtime that referenced this pull request Aug 12, 2021
Issue: aws-controllers-k8s/community#812

Changes:
* Introduce new condition ConditionTypeLateInitialized
* Update reconciler to invoke `AWSResourceManager.LateInitialize()` method

------------------
Corresponding Code generator PR: aws-controllers-k8s/code-generator#138
Please do not merge until code generator PR is merged

------------------
Testing

* Unit tests successful
```
➜  runtime git:(li-mlp) ✗ make test
building mocks for pkg/types ... ok.
building mocks for k8s.io/apimachinery/pkg/apis/meta/v1 ... ok.
building mocks for k8s.io/apimachinery/runtime ... ok.
building mocks for k8s.io/apimachinery/runtime/schema ... ok.
building mocks for sigs.k8s.io/controller-runtime/pkg/client ... ok.
go test  ./...
?       github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1       [no test files]
?       github.com/aws-controllers-k8s/runtime/mocks/apimachinery/pkg/apis/meta/v1      [no test files]
?       github.com/aws-controllers-k8s/runtime/mocks/apimachinery/pkg/runtime   [no test files]
?       github.com/aws-controllers-k8s/runtime/mocks/apimachinery/pkg/runtime/schema    [no test files]
?       github.com/aws-controllers-k8s/runtime/mocks/controller-runtime/pkg/client      [no test files]
?       github.com/aws-controllers-k8s/runtime/mocks/pkg/types  [no test files]
ok      github.com/aws-controllers-k8s/runtime/pkg/compare      (cached)
ok      github.com/aws-controllers-k8s/runtime/pkg/condition    (cached)
?       github.com/aws-controllers-k8s/runtime/pkg/config       [no test files]
?       github.com/aws-controllers-k8s/runtime/pkg/errors       [no test files]
?       github.com/aws-controllers-k8s/runtime/pkg/metrics      [no test files]
ok      github.com/aws-controllers-k8s/runtime/pkg/requeue      (cached)
ok      github.com/aws-controllers-k8s/runtime/pkg/runtime      1.287s
ok      github.com/aws-controllers-k8s/runtime/pkg/runtime/cache        (cached)
?       github.com/aws-controllers-k8s/runtime/pkg/runtime/log  [no test files]
?       github.com/aws-controllers-k8s/runtime/pkg/types        [no test files]
ok      github.com/aws-controllers-k8s/runtime/pkg/util (cached)
?       github.com/aws-controllers-k8s/runtime/pkg/webhook      [no test files]

```

* local-kind-e2e-test logs
```
                                                                                                    │
│ 2021-07-26T19:38:08.701Z    DEBUG    ackrt    > r.Sync    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "kind": "Repository" │
│ 2021-07-26T19:38:08.701Z    DEBUG    ackrt    >> rm.ReadOne    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": f │
│ 2021-07-26T19:38:08.701Z    DEBUG    ackrt    >>> rm.sdkFind    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted":  │
│ 2021-07-26T19:38:09.641Z    DEBUG    ackrt    <<< rm.sdkFind    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted":  │
│ 2021-07-26T19:38:09.641Z    DEBUG    ackrt    << rm.ReadOne    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": f │
│ 2021-07-26T19:38:09.641Z    DEBUG    ackrt    >> r.setResourceManaged    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_a │
│ 2021-07-26T19:38:09.641Z    DEBUG    ackrt    >>> kc.Patch (metadata + spec)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2" │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    <<< kc.Patch (metadata + spec)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2" │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    marked resource as managed    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "i │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    << r.setResourceManaged    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_a │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    >> rm.Create    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": fa │
│ 2021-07-26T19:38:09.694Z    DEBUG    ackrt    >>> rm.sdkCreate    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted" │
│ 2021-07-26T19:38:09.725Z    DEBUG    ackrt    <<< rm.sdkCreate    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted" │
│ 2021-07-26T19:38:09.725Z    DEBUG    ackrt    << rm.Create    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": fa │
│ 2021-07-26T19:38:09.725Z    INFO    ackrt    created new resource    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopt │
│ 2021-07-26T19:38:09.725Z    DEBUG    ackrt    >> rm.LateInitialize    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adop │
│ 2021-07-26T19:38:09.725Z    INFO    ackrt    calculated late initialization delay is 0 seconds    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "re │
│ 2021-07-26T19:38:09.725Z    DEBUG    ackrt    >>> rm.sdkFind    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted":  │
│ 2021-07-26T19:38:09.748Z    DEBUG    ackrt    <<< rm.sdkFind    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted":  │
│ 2021-07-26T19:38:09.748Z    DEBUG    ackrt    << rm.LateInitialize    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adop │
│ 2021-07-26T19:38:09.748Z    DEBUG    ackrt    >> r.patchResourceMetadataAndSpec    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west │
│ 2021-07-26T19:38:09.748Z    DEBUG    ackrt    >>> kc.Patch (metadata + spec)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2" │
│ 2021-07-26T19:38:09.758Z    DEBUG    ackrt    <<< kc.Patch (metadata + spec)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2" │
│ 2021-07-26T19:38:09.759Z    DEBUG    ackrt    patched resource metadata and spec    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-wes │
│ 2021-07-26T19:38:09.759Z    DEBUG    ackrt    << r.patchResourceMetadataAndSpec    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west │
│ 2021-07-26T19:38:09.759Z    DEBUG    ackrt    >> r.patchResourceStatus    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_ │
│ 2021-07-26T19:38:09.759Z    DEBUG    ackrt    >>> kc.Patch (status)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_ado │
│ 2021-07-26T19:38:09.794Z    DEBUG    ackrt    <<< kc.Patch (status)    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_ado │
│ 2021-07-26T19:38:09.795Z    DEBUG    ackrt    patched resource status    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_a │
│ 2021-07-26T19:38:09.795Z    DEBUG    ackrt    << r.patchResourceStatus    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_ │
│ 2021-07-26T19:38:09.795Z    DEBUG    ackrt    < r.Sync    {"kind": "Repository", "namespace": "default", "name": "ecr-repository-wy6n6wjm8", "generation": 1, "account": "309117047740", "role": "", "region": "us-west-2", "is_adopted": false, │
│ 2021-07-26T19:38:09.795Z    DEBUG    controller-runtime.controller    Successfully Reconciled    {"controller": "repository", "request": "default/ecr-repository-wy6n6wjm8"}
```
@jaypipes
Copy link
Collaborator

@vijtrip2 OK, I just cut the v0.10.0 release of ACK runtime with the related LateInitialize changes. Please update this PR to bring in a new ACK runtime go.mod dependency, update the pkg/generate/ack/runtime_test.go as needed and update the Makefile version.

@vijtrip2
Copy link
Contributor Author

@vijtrip2 OK, I just cut the v0.10.0 release of ACK runtime with the related LateInitialize changes. Please update this PR to bring in a new ACK runtime go.mod dependency, update the pkg/generate/ack/runtime_test.go as needed and update the Makefile version.

@jaypipes , Done.
Also ran go mod tidy
ack/runtime_test.go was already updated with rm.LateInitialize() method, so no change needed there. make test is successful.

Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vijtrip2 this is very close. I have one requested change to make in this PR (see inline, it's about returning just latest, err instead of a requeue needed when we error in the ReadOne call...)

@vijtrip2
Copy link
Contributor Author

@vijtrip2 this is very close. I have one requested change to make in this PR (see inline, it's about returning just latest, err instead of a requeue needed when we error in the ReadOne call...)

Done.

➜  code-generator git:(li-mlp) ✗ make test
go test -tags codegen ./...
?       github.com/aws-controllers-k8s/code-generator/cmd/ack-generate  [no test files]
?       github.com/aws-controllers-k8s/code-generator/cmd/ack-generate/command  [no test files]
ok      github.com/aws-controllers-k8s/code-generator/pkg/generate/ack  (cached)
ok      github.com/aws-controllers-k8s/code-generator/pkg/generate/code (cached)
?       github.com/aws-controllers-k8s/code-generator/pkg/generate/config       [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/generate/crossplane   [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/generate/olm  [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/generate/templateset  [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/metadata      [no test files]
ok      github.com/aws-controllers-k8s/code-generator/pkg/model (cached)
ok      github.com/aws-controllers-k8s/code-generator/pkg/model/multiversion    (cached)
ok      github.com/aws-controllers-k8s/code-generator/pkg/names (cached)
?       github.com/aws-controllers-k8s/code-generator/pkg/testutil      [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/util  [no test files]
?       github.com/aws-controllers-k8s/code-generator/pkg/version       [no test files]
➜  code-generator git:(li-mlp) ✗ export SERVICE=ecr
➜  code-generator git:(li-mlp) ✗ make build-controller
building ack-generate ... ok.
Copying common custom resource definitions into ecr
Building Kubernetes API objects for ecr
Generating deepcopy code for ecr
Generating custom resource definitions for ecr
Building service controller for ecr
Generating RBAC manifests for ecr
Running gofmt against generated code for ecr
➜  code-generator git:(li-mlp) ✗ cd ../ecr-controller 
➜  ecr-controller git:(ack-main) ✗ make test
go test -v ./...
?       github.com/aws-controllers-k8s/ecr-controller/apis/v1alpha1     [no test files]
?       github.com/aws-controllers-k8s/ecr-controller/cmd/controller    [no test files]
?       github.com/aws-controllers-k8s/ecr-controller/pkg/resource      [no test files]
?       github.com/aws-controllers-k8s/ecr-controller/pkg/resource/repository   [no test files]
?       github.com/aws-controllers-k8s/ecr-controller/pkg/version       [no test files]
➜  ecr-controller git:(ack-main) ✗ 

@vijtrip2 vijtrip2 requested a review from jaypipes August 13, 2021 22:44
Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm OK with this functionally, thank you @vijtrip2 :)

In a future PR, please wrap code and code comments at 80 chars to follow the existing style as much as possible (80 chars makes demo and screen-sharing of the code easier since it allows the code to fit in a single screen without horizontal scrolling, FWIW).

@jaypipes
Copy link
Collaborator

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 16, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Aug 16, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, jaypipes, RedbackThomson, vijtrip2

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [A-Hilaly,RedbackThomson,jaypipes,vijtrip2]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit afa7fe0 into aws-controllers-k8s:main Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants