Skip to content

Reused errdefs define error#7871

Merged
AkihiroSuda merged 1 commit intocontainerd:mainfrom
yanggangtony:error-def
Dec 27, 2022
Merged

Reused errdefs define error#7871
AkihiroSuda merged 1 commit intocontainerd:mainfrom
yanggangtony:error-def

Conversation

@yanggangtony
Copy link
Copy Markdown
Contributor

@yanggangtony yanggangtony commented Dec 27, 2022

Signed-off-by: yanggang [email protected]

Reused define error in package 'errdefs' , like errdefs.ErrNotFound and errdefs.ErrAlreadyExists, errdefs.ErrNotImplemented

@k8s-ci-robot
Copy link
Copy Markdown

Hi @yanggangtony. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Copy Markdown
Member

@dcantah dcantah left a comment

Choose a reason for hiding this comment

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

LGTM on green

Comment on lines -51 to -56
var (
// ErrNotFound represents an error returned when object not found in meta store
ErrNotFound = errors.New("not found")
// ErrAlreadyExists represents an error returned when object can't be duplicated in meta store
ErrAlreadyExists = errors.New("object already exists")
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, one comment. There's a small chance, but just to be safe in case anyone was relying on these in some package, could you just assign these to errdefs.ErrNotFound and errdefs.ErrNotImplemented

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dcantah
Thanks for review that.
I think you point is good.
I had updated it..
thanks for that..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do not guarantee the Go API stability, and it is unlikely that somebody is depending on these variables. Also it is quite easy for such potential users to apply this change.

// ErrAlreadyExists represents an error returned when object can't be duplicated in meta store
ErrAlreadyExists = errors.New("object already exists")
ErrAlreadyExists = errdefs.ErrAlreadyExists
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just remove these variables from the snapshots/devmapper pkg?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The author did actually in the first iteration, to be safe I said maybe we can just assign them to the errdefs equivalents. I think it's probably fine to get rid of though, we don't have any callers here that check for these, was mostly thinking external, but not sure what someone would even be doing calling things from snapshotter/devmapper

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've seen folks rely on some pretty strange implementation details, so I always err on the side of safety 🤣

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

😋😋
for now, containerd 1.x , keep compatible is good.
Maybe we can delete these dead code in 2.x?

@AkihiroSuda AkihiroSuda merged commit bae8fb9 into containerd:main Dec 27, 2022
@yanggangtony yanggangtony deleted the error-def branch November 25, 2023 00:56
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.

4 participants