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

Check the length of parts while using ParseNamespacedName and ParseNamespacedNameContainer #2141

Merged
merged 32 commits into from Aug 4, 2021

Conversation

FingerLeader
Copy link
Member

@FingerLeader FingerLeader commented Jul 22, 2021

What problem does this PR solve?

Issue Number: close #1933

Problem Summary:

What is changed and how it works?

Before returning value, check the length of parts to avoid panic.

Checklist

Tests

  • Unit test
  • E2E test
  • Manual test (add detailed scripts or steps below)
  • No code

@ti-chi-bot
Copy link
Member

Welcome @FingerLeader!

It looks like this is your first PR to chaos-mesh/chaos-mesh 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to chaos-mesh/chaos-mesh. 😃

@cwen0 cwen0 requested a review from YangKeao July 22, 2021 08:33
Signed-off-by: FingerLeader <FingerLeader@gmail.com>
FingerLeader and others added 3 commits July 22, 2021 19:36
Signed-off-by: FingerLeader <FingerLeader@gmail.com>

add length check of parts
* fix: deadline reconciler, keep deadline exceed with true

Signed-off-by: STRRL <str_ruiling@outlook.com>

* chore: enriching log things

Signed-off-by: STRRL <str_ruiling@outlook.com>

* test: testcases about this issue

Signed-off-by: STRRL <str_ruiling@outlook.com>

* test: finish TODO

Signed-off-by: STRRL <str_ruiling@outlook.com>

* test: finished TODO

Signed-off-by: STRRL <str_ruiling@outlook.com>

* chore: refine codes and appending test case

Signed-off-by: STRRL <str_ruiling@outlook.com>

* chore: make linters happy

Signed-off-by: STRRL <str_ruiling@outlook.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Signed-off-by: FingerLeader <wanxfinger@gmail.com>
@YangKeao
Copy link
Member

/run-e2e-tests

@codecov-commenter
Copy link

codecov-commenter commented Jul 22, 2021

Codecov Report

Merging #2141 (7192928) into master (7e9ff3f) will decrease coverage by 12.81%.
The diff coverage is 39.32%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #2141       +/-   ##
===========================================
- Coverage   55.78%   42.96%   -12.82%     
===========================================
  Files          68      128       +60     
  Lines        4383     8865     +4482     
===========================================
+ Hits         2445     3809     +1364     
- Misses       1768     4727     +2959     
- Partials      170      329      +159     
Impacted Files Coverage Δ
api/v1alpha1/awschaos_types.go 0.00% <0.00%> (ø)
api/v1alpha1/dnschaos_type.go 0.00% <0.00%> (ø)
api/v1alpha1/dnschaos_webhook.go 0.00% <0.00%> (ø)
api/v1alpha1/gcpchaos_types.go 0.00% <0.00%> (ø)
api/v1alpha1/httpchaos_types.go 0.00% <0.00%> (ø)
api/v1alpha1/httpchaos_webhook.go 0.00% <0.00%> (ø)
api/v1alpha1/iochaos_types.go 0.00% <0.00%> (-40.00%) ⬇️
api/v1alpha1/jvmchaos_webhook.go 0.00% <0.00%> (ø)
api/v1alpha1/kernelchaos_types.go 0.00% <0.00%> (-20.00%) ⬇️
api/v1alpha1/kinds.go 23.52% <0.00%> (-3.14%) ⬇️
... and 188 more

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 9d8c35b...7192928. Read the comment docs.

@YangKeao
Copy link
Member

/run-e2e-tests

@FingerLeader
Copy link
Member Author

/run-e2e-tests

1 similar comment
@STRRL
Copy link
Member

STRRL commented Jul 26, 2021

/run-e2e-tests

@ti-chi-bot ti-chi-bot added size/XL and removed size/S labels Jul 26, 2021
}, strings.Join(parts[2:], "")
Namespace: "",
Name: "",
}, "", errors.New("Too Few Parts of NamespacedName")
Copy link

Choose a reason for hiding this comment

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

ST1005: error strings should not be capitalized
(at-me in a reply with help or ignore)

@FingerLeader
Copy link
Member Author

Hi @FingerLeader ,

I've been reverted the unexpected changes towards some files, and I have some suggestions for git operations:

  1. check out a specific branch for changes, rather than directly using the master branch of your forked repo, and each branch should only do one thing, after the PR merged, the branch should be also deleted;
  2. try git diff xxx > patch and git apply patch such techniques if you want to quickly apply some changes on the source commit/branch/tag/files;

Happy hack!

Thanks for your suggestion! I'll have a try next time

controllers/common/fx.go Outdated Show resolved Hide resolved
podId, containerName, err := controller.ParseNamespacedNameContainer(record.Id)
if err != nil {
// TODO: organize the error in a better way
err = NewFailToFindContainer(pod.Namespace, pod.Name, containerName, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's still an issue.

@FingerLeader
Copy link
Member Author

/run-e2e-test

@Colstuwjx
Copy link
Contributor

The file mode changes are unexpected behavior, please revert them, @FingerLeader.

@FingerLeader
Copy link
Member Author

Actually, I don't know why the file modes are changed. After reseting my branch to 084d57a, the modes are still change to 10755 when I commit the branch.

@Colstuwjx
Copy link
Contributor

I wonder if it's due to sth like git index cache, you could try the following commands to rollback to the upstream branch state:

git remote add upstream git@github.com:chaos-mesh/chaos-mesh.git
git fetch upstream
git diff -p -R --no-ext-diff --no-color upstream/master| grep -E "^(diff|(old|new) mode)" --color=never > patch
git apply patch

For a simple solution about this, I think you could just delete your local repo and re-clone it?

Signed-off-by: FingerLeader <wanxfinger@gmail.com>
@FingerLeader
Copy link
Member Author

I set filemode = false in .git/config, and it seems work.

Signed-off-by: FingerLeader <wanxfinger@gmail.com>
@FingerLeader
Copy link
Member Author

/run-e2e-test

Copy link
Contributor

@Colstuwjx Colstuwjx left a comment

Choose a reason for hiding this comment

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

LGTM!

@FingerLeader
Copy link
Member Author

LGTM!

It's really a long way to get this LGTM. Thanks for your help!

@YangKeao
Copy link
Member

YangKeao commented Aug 3, 2021

So len(parts) > 1 (which includes xx/xx/xx) are all regarded as a valid NamespacedName?

@STRRL suggested that the xx/xx/xx input should be illegal for the ParseNamespacedName. Will you modify it in the future PR or just prefer the current choice?

@FingerLeader
Copy link
Member Author

So len(parts) > 1 (which includes xx/xx/xx) are all regarded as a valid NamespacedName?

@STRRL suggested that the xx/xx/xx input should be illegal for the ParseNamespacedName. Will you modify it in the future PR or just prefer the current choice?

But IOChaos uses ParseNamespacedName with input in the format of xx/xx/xx, I have no idea about solving this now. I perfer to modify this PR first. And I'll try to find a method to select correct function according to Chaos' typy later.

Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

@YangKeao
Copy link
Member

YangKeao commented Aug 4, 2021

But IOChaos uses ParseNamespacedName with input in the format of xx/xx/xx, I have no idea about solving this now. I perfer to modify this PR first. And I'll try to find a method to select correct function according to Chaos' typy later.

Please also record an issue as the TODO (just in case you forget).

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 209de76

@YangKeao
Copy link
Member

YangKeao commented Aug 4, 2021

/merge

@ti-chi-bot ti-chi-bot merged commit cff3ed6 into chaos-mesh:master Aug 4, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-1.2 failed

@ti-srebot
Copy link
Contributor

cherry pick to release-2.0 failed

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

Successfully merging this pull request may close these issues.

Check the length of array before using it in ParseNamespacedName and ParseNamespacedNameContainer functions
9 participants