Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix workload reconcile error when revision enable trait is attached #797

Merged
merged 1 commit into from
Dec 21, 2020

Conversation

wonderflow
Copy link
Collaborator

@wonderflow wonderflow commented Dec 21, 2020

the bug occurs when revisionEnabled trait is used.

Reproduce workflow, apply following yaml one by one:

apiVersion: core.oam.dev/v1alpha2
kind: TraitDefinition
metadata:
  annotations:
    definition.oam.dev/description: '`Scaler` is used to configure replicas for your
      service.'
  name: scaler
spec:
  definitionRef:
    name: manualscalertraits.core.oam.dev
  revisionEnabled: true
  workloadRefPath: spec.workloadRef
apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
  name: example-component
spec:
  workload:
    apiVersion: core.oam.dev/v1alpha2
    kind: ContainerizedWorkload
    spec:
      containers:
        - name: wordpress
          image: wordpress:4.6.1-apache
          ports:
            - containerPort: 80
              name: wordpress
          env:
            - name: TEST_ENV
              value: test
apiVersion: core.oam.dev/v1alpha2
kind: ApplicationConfiguration
metadata:
  name: example-appconfig
spec:
  components:
    - componentName: example-component
      revisionName: example-component-v1
      traits:
        - trait:
            apiVersion: core.oam.dev/v1alpha2
            kind: ManualScalerTrait
            spec:
              replicaCount: 3

Then the appconfig will always reporting error:

  conditions:
  - lastTransitionTime: "2020-12-21T11:07:19Z"
    message: 'cannot apply components: cannot apply trait "core.oam.dev/v1alpha2"
      "ManualScalerTrait" "": cannot get object: resource name may not be empty'
    reason: ReconcileError
    status: "False"
    type: Synced
  dependency: {}
  observedGeneration: 1

The core reason is we fogort to add name when existing workload is exist:

image

This error happens but the workload is still created successfully, so our normal e2e test won't work. I wrote a new test for this case.

@wonderflow wonderflow changed the title fix workload can not be update when revision enable trait is attached fix workload reconcile error when revision enable trait is attached Dec 21, 2020
@codecov
Copy link

codecov bot commented Dec 21, 2020

Codecov Report

Merging #797 (7609da2) into master (04868d2) will increase coverage by 0.19%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #797      +/-   ##
==========================================
+ Coverage   34.33%   34.52%   +0.19%     
==========================================
  Files          95       95              
  Lines        8399     8399              
==========================================
+ Hits         2884     2900      +16     
+ Misses       5191     5175      -16     
  Partials      324      324              
Flag Coverage Δ
unittests 34.52% <100.00%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...am.dev/v1alpha2/applicationconfiguration/render.go 86.25% <100.00%> (+0.62%) ⬆️
...plicationconfiguration/applicationconfiguration.go 84.29% <0.00%> (+5.78%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04868d2...7609da2. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants