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

🌱 Use utilyaml to collect agent manifests in remote cluster #71

Merged

Conversation

Danil-Grigorev
Copy link
Contributor

kind/cleanup

What this PR does / why we need it:
Using CAPI utilyaml to collect and apply raw manifests from import endpoint.

  • Improve logging
  • Reduce number of remote cluster requests from 2 to 1 (Create)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Checklist:

  • squashed commits into logical changes
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@Danil-Grigorev Danil-Grigorev added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Aug 11, 2023
@Danil-Grigorev Danil-Grigorev requested a review from a team as a code owner August 11, 2023 13:42
Name: obj.GetName(),
}, u)
err := c.Create(ctx, obj)
if client.IgnoreAlreadyExists(err) != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats the difference between this check and the apierrors.IsAlreadyExists below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first one filters out the AlreadyExists error, and returns all other error types or nil. The other one specifically checks for the error being of type AlreadyExist. I hoped this will be more readable, but may be it isn’t. Can change to err != nil for the second one, it is equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

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

we could move maybe this:

if apierrors.IsAlreadyExists(err) {} up to check for api errors and later check for err != nil since it will be not api errors anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ve updated the implementation. Though this change brings no functional difference, just the code style.

Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
@alexander-demicev alexander-demicev merged commit a805f3c into rancher:main Aug 24, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants