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

feat: show status.labelSelector for CloneSet #4839

Merged
merged 1 commit into from Apr 19, 2024

Conversation

veophi
Copy link

@veophi veophi commented Apr 17, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Signed-off-by: 孙伟祥 <sunweixiang@xiaohongshu.com>
@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 17, 2024
@karmada-bot
Copy link
Collaborator

Welcome @veophi! It looks like this is your first PR to karmada-io/karmada 🎉

@karmada-bot karmada-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 17, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.10%. Comparing base (fdad87e) to head (9bcd852).
Report is 2 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4839      +/-   ##
==========================================
- Coverage   53.11%   53.10%   -0.01%     
==========================================
  Files         250      250              
  Lines       20351    20351              
==========================================
- Hits        10810    10808       -2     
- Misses       8824     8826       +2     
  Partials      717      717              
Flag Coverage Δ
unittests 53.10% <ø> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RainbowMango
Copy link
Member

Thanks @veophi, I notice you are from the openkruise community, so it makes sense for you to maintain the resource customizations of apps.kruise.io.

/assign @yike21 @chaunceyjiang
To take a look, and do we need to update the tests as well?

@yike21
Copy link
Member

yike21 commented Apr 17, 2024

/assign @yike21 @chaunceyjiang To take a look, and do we need to update the tests as well?

From the code it looks fine, I'll do the test asap!

Glad to see your contribution! @veophi

Copy link
Member

@yike21 yike21 left a comment

Choose a reason for hiding this comment

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

The status.labelSelector field of cloneset is equal to the items in .spec.selector.matchLabels spliced together with ','. According to description, it has to do with the hpa feature of CloneSet.
The changes in customizations.yaml has been verified.

$ karmadactl version
karmadactl version: version.Info{GitVersion:"v1.7.0-alpha.1-1044-g5f4ff2435", GitCommit:"5f4ff24353409cd190537e45478d9c6ce6a3d370", GitTreeState:"clean", BuildDate:"2024-04-18T14:35:01Z", GoVersion:"go1.22.2", Compiler:"gc", Platform:"linux/amd64"}

# Execute the statusReflection rule
$ karmadactl interpret -f customizations.yaml --operation interpretStatus --observed-file testdata/observed-cloneset-nginx.yaml
---
# [1/1] status:
availableReplicas: 2
currentRevision: sample-59df6bd888
expectedUpdatedReplicas: 2
labelSelector: app=sample,test=cloneset
observedGeneration: 1
readyReplicas: 2
replicas: 2
updateRevision: sample-59df6bd888
updatedReadyReplicas: 2
updatedReplicas: 2

# Execute the statusAggregation rule
$ karmadactl interpret -f customizations.yaml --operation aggregateStatus --observed-file testdata/observed-cloneset-nginx.yaml --status-file testdata/status-file.yaml
---
# [1/1] aggregatedStatus:
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
    generation: 1
    labels:
        app: sample
    name: sample
    namespace: test-cloneset
spec:
    replicas: 2
    selector:
        matchLabels:
            app: sample
            test: cloneset
    template:
        metadata:
            labels:
                app: sample
                test: cloneset
        spec:
            containers:
                - env:
                    - name: logData
                      valueFrom:
                        configMapKeyRef:
                            key: log
                            name: mysql-config
                    - name: lowerData
                      valueFrom:
                        configMapKeyRef:
                            key: lower
                            name: mysql-config
                  image: nginx:alpine
                  name: nginx
            volumes:
                - configMap:
                    name: my-sample-config
                  name: configmap
status:
    availableReplicas: 4
    collisionCount: 0
    currentRevision: sample-59df6bd888
    expectedUpdatedReplicas: 4
    labelSelector: app=sample,test=cloneset
    observedGeneration: 1
    readyReplicas: 4
    replicas: 4
    updateRevision: sample-59df6bd888
    updatedReadyReplicas: 4
    updatedReplicas: 4

And the test-data need to be updated. I will do it soon.

@yike21
Copy link
Member

yike21 commented Apr 18, 2024

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 18, 2024
@RainbowMango
Copy link
Member

Thank you @yike21 .

And the test-data need to be updated. I will do it soon.

Seems we still lack of a mechanism to run these test automatically?

@RainbowMango
Copy link
Member

/assign @chaunceyjiang

@yike21
Copy link
Member

yike21 commented Apr 18, 2024

Seems we still lack of a mechanism to run these test automatically?

The tests are executed automatically. The test program ensures that the resourcecustomizations directory is structured with the test files and that the karmadactl interpert is executed without errors. This is useful when adding a new customizaitons.yaml for thirdparty CRD.

However, when an existing customizations.yaml for some thirdparty CRD is modified, the testdata related may need to be analyzed and modified again to characterize the new interpretation rules.

@RainbowMango
Copy link
Member

Get it. Thanks for the explanation. We have tests and they work as expected, we just need to add new fields to them, as #4849 does.

Copy link
Member

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

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

Thanks~

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chaunceyjiang

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:

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 19, 2024
@karmada-bot karmada-bot merged commit 20bb7a7 into karmada-io:master Apr 19, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants