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 deprecated iobundle type #4634

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

christoph-zededa
Copy link
Contributor

@christoph-zededa christoph-zededa commented Feb 20, 2025

pillar/types: check for deprecated IoBundle Types

so far only for IoUSB is checked

IoUsb should not be used anymore in favor of IoUsbController and
IoUsbDevice

also make spdx checker ignore 'do-not-edit' files.

will be used in the following commits

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
@christoph-zededa christoph-zededa force-pushed the check_deprecated_iobundle_type branch 2 times, most recently from 49e5d68 to 8cc307e Compare February 20, 2025 13:18
@christoph-zededa christoph-zededa marked this pull request as ready for review February 20, 2025 14:00
@rene
Copy link
Contributor

rene commented Feb 20, 2025

@christoph-zededa , although IoUSB is deprecated, is there any use case where IoUSB can still be used? I'm wondering if these changes can break systems using old device models + EVE with IoUsbController?

@christoph-zededa
Copy link
Contributor Author

@christoph-zededa , although IoUSB is deprecated, is there any use case where IoUSB can still be used? I'm wondering if these changes can break systems using old device models + EVE with IoUsbController?

I added be643f3 to remove all remaining uses of types.IoUSB.
It should not break it, but starting the edge app will fail: https://github.com/lf-edge/eve/blob/master/pkg/pillar/cmd/domainmgr/domainmgr.go#L1481

@@ -111,6 +111,10 @@ file_to_be_checked() {
return 1
fi
done
if grep -qi "do not edit" "$file";
Copy link
Member

Choose a reason for hiding this comment

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

Which files exactly are you referring to?

Even if a file is generated by a tool, I still think it should contain the header—it's recommended so we know the consequences of using that generating tool. While I agree that we can (and already do) ignore some generated files, we can still add headers to files that come from tools we maintain ourselves.

Could you clarify which specific files you have in mind here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iotype_string.go

Copy link
Member

Choose a reason for hiding this comment

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

COuld we change it to "Code generated by.*stringer"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,55 @@
// Code generated by "stringer --type IoType"; DO NOT EDIT.
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, I didn't know about that tool—I've always handled it manually. While it looks useful, I'm wondering how maintainable it is. If we change an enum, will the tool be run automatically? If not, then we shouldn't really treat the output as entirely auto-generated, and we’d need to maintain it ourselves. If it is run automatically, then we can skip the header.

So, I see two options:

  1. Automate the tool run so we don't need a header, or
  2. Treat the file as manually maintained and add the header.

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'm wondering how maintainable it is

it throws a compile error if one makes incompatible changes

Copy link
Member

Choose a reason for hiding this comment

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

And after that, one has to go and fix it manually. So. it's not rerun automatically. So, it's manually maintained file =)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We also have lots of other auto-generated files checked in.

Copy link
Member

Choose a reason for hiding this comment

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

Like under vendors and API? Or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, eve-api is probably the biggest chunk (another case are all these draw.io diagrams).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps a small argument for checking in the generated code is that if you use an IDE outside of the build container then some source files are missing and your IDE may become unhappy; also people running go test on their system directly have to create these files first.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't see this custom String() function earlier. Doesn't the golang built-in String() for an enum produce the correct output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately not, that's why they created https://pkg.go.dev/golang.org/x/tools/cmd/stringer

ioBundle := &aa.IoBundleList[i]
ioBundle.Error.removeByType(ErrIOBundleDeprecatedType{})

if ioBundle.Type == IoUSB {
Copy link
Member

Choose a reason for hiding this comment

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

Where exactly does this type originate? Could it come from the controller or from persistent storage? If it can be stored and then a user updates EVE to a newer version, might they encounter this error? Or is it only ever set by our internal code, making it impossible for an older or external value to appear?

If it can come from an older source, is there any way we could safely handle unknown types — perhaps trying to guess the correct type and logging a warning—rather than breaking the system that was previously running without issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is derived from an eve-api type: PhyIoUSB = 2;

Copy link
Contributor Author

@christoph-zededa christoph-zededa Feb 21, 2025

Choose a reason for hiding this comment

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

Nobody is reading these warnings ;-) - see also #4634 (comment)

Afaik the commercial users got informed about the change.

Copy link
Member

Choose a reason for hiding this comment

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

Afaik the commercial users got informed about the change.

Unfortunately, it does not prevent them from making mistakes and then requesting fixes from the engineering... We know such cases =(

Copy link
Contributor

Choose a reason for hiding this comment

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

I must have missed something in the past reviews/discussions and I don't recall us communicating to users that all existing models which published in the controllers (including the eden model files which we can change) need to be changed from IoTypeUsb to IoTypeUsbController.

I thought we introduced IoTypeUsbController as a more clear name, but that existing uses of IoTypeUSb would be interpreted to mean the same thing as IoTypeUsbController. If that is not the case I think we will break existing usage.
Let's set up some time on Monday to talk about this. Perhaps I'm missing something.

@christoph-zededa
Copy link
Contributor Author

Alternatives:

@OhmSpectator
Copy link
Member

I would like @eriknordmark to share his experience in handling such situations. I don't think it's the first time we have to introduce a potentially breaking change.

@OhmSpectator
Copy link
Member

@christoph-zededa, in general, how did you come to the idea of this change? Is it related to some issue?

@christoph-zededa
Copy link
Contributor Author

@christoph-zededa, in general, how did you come to the idea of this change? Is it related to some issue?

It is because of two issues I saw this week:

  1. Somebody had an edge application that expects IoUsb and another one that expects IoUsbDevice and they were wondering what they should do in the model manifest to be able to run both.
  2. [12.0-stable] Revert "domainmgr: do pci-reserve on start of edge app" #4633 - and they were using IoUsb and were wondering why the behavior is different on EVE 12.x vs 13.x and I think with IoUsbController the behavior would not have been different - see https://github.com/lf-edge/eve/blob/master/pkg/pillar/cmd/domainmgr/domainmgr.go#L1399

these files have been auto-generated and IMHO do not pass the
threshold of originality and so do not need a copyright

moreover it is a hassle to manually add the copyright every time again

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
so far only for IoUSB is checked

IoUsb should not be used anymore in favor of IoUsbController and
IoUsbDevice

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
that is either IoUSBController or IoUSBDevice

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
to hopefully fix flaky test in the future

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
@christoph-zededa christoph-zededa force-pushed the check_deprecated_iobundle_type branch from dedad09 to 4691a87 Compare February 21, 2025 17:37
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.

4 participants