Commit 0271c52
authored
Issue # : aws-controllers-k8s/community#1946
RCA:
Following CR currently fails to adopt the existing FlowLog resource.
```
apiVersion: services.k8s.aws/v1alpha1
kind: AdoptedResource
metadata:
name: flowlog1
spec:
aws:
nameOrID: fl-xxxxxx
kubernetes:
group: ec2.services.k8s.aws
kind: FlowLog
metadata:
name: flowlog-adopted
namespace: default
```
The error
```
"error": "FlowLog.ec2.services.k8s.aws "my-resource" is invalid: [spec.resourceID: Required value, spec.resourceType: Required value]"}
```
comes from https://github.com/aws-controllers-k8s/runtime/blob/main/pkg/runtime/adoption_reconciler.go#L157
`SetIdentifiers` function needs to have code to fill up `required` values of the CR so as to solve this issue.
Solution:
2 new fields are defined as `ResourceID` and `ResourceType` and they are initialized in `SetIdentifiers` function. These fields need to part of `additionalKeys` field of `AdoptedResource` CR for `FlowLog`.
The new CR looks like,
```
apiVersion: services.k8s.aws/v1alpha1
kind: AdoptedResource
metadata:
name: flowlog1
spec:
aws:
nameOrID: fl-xxxxx
additionalKeys:
ResourceID: vpc-xxxxxx
ResourceType: VPC
kubernetes:
group: ec2.services.k8s.aws
kind: FlowLog
metadata:
name: flowlog-adopted
namespace: default
```
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 374304e commit 0271c52
File tree
5 files changed
+24
-6
lines changed- apis/v1alpha1
- pkg/resource/flow_log
- templates/hooks/flow_log
5 files changed
+24
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
343 | 345 | | |
344 | 346 | | |
345 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
343 | 345 | | |
344 | 346 | | |
345 | 347 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments