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

YAML files: ignore files inside automation sub-folder #4291

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Jul 1, 2024

Also ignore unreachable files

Signed-off-by: Laurent Garnier lg.hc@free.fr

Also ignore unreachable files

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo lolodomo requested a review from a team as a code owner July 1, 2024 18:58
@lolodomo
Copy link
Contributor Author

lolodomo commented Jul 1, 2024

Handles user feedbacks testing OH 4.2 milestone 4.

First user reported these logs:

[INFO ] [aml.internal.YamlModelRepositoryImpl] - Adding YAML model automation/js/node_modules/@jamescoyle/vue-icon/pnpm-lock
 [WARN ] [aml.internal.YamlModelRepositoryImpl] - Version is missing or not a number in model automation/js/node_modules/@jamescoyle/vue-icon/pnpm-lock. Ignoring it.

Second user reported this exception:

2024-06-30 19:53:56.878 [ERROR] [aml.internal.YamlModelRepositoryImpl] - bundle org.openhab.core.model.yaml:4.2.0.M4 (217)[org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl(246)] : Error during instantiation of the implementation object

java.lang.reflect.InvocationTargetException: null

	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]

	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]

	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]

	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]

	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]

	at org.apache.felix.scr.impl.inject.internal.ComponentConstructorImpl.newInstance(ComponentConstructorImpl.java:326) ~[bundleFile:?]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:286) [bundleFile:?]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:115) [bundleFile:?]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:1002) [bundleFile:?]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:975) [bundleFile:?]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:776) [bundleFile:?]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:674) [bundleFile:?]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:437) [bundleFile:?]

	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:671) [bundleFile:?]

	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:310) [bundleFile:?]

	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:593) [bundleFile:?]

	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:74) [bundleFile:?]

	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:460) [bundleFile:?]

	at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) [bundleFile:?]

	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) [bundleFile:?]

	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) [bundleFile:?]

	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:488) [osgi.core-8.0.0.jar:?]

	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:420) [osgi.core-8.0.0.jar:?]

	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [osgi.core-8.0.0.jar:?]

	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450) [osgi.core-8.0.0.jar:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:949) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:229) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:138) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:130) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:217) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.container.Module.publishEvent(Module.java:499) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.container.Module.start(Module.java:486) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1783) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) [org.eclipse.osgi-3.18.0.jar:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) [org.eclipse.osgi-3.18.0.jar:?]

Caused by: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: /etc/openhab/_infdb/20240630

	at java.nio.file.FileTreeIterator.fetchNextIfNeeded(FileTreeIterator.java:87) ~[?:?]

	at java.nio.file.FileTreeIterator.hasNext(FileTreeIterator.java:103) ~[?:?]

	at java.util.Iterator.forEachRemaining(Iterator.java:132) ~[?:?]

	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845) ~[?:?]

	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]

	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]

	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]

	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]

	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]

	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]

	at org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl.<init>(YamlModelRepositoryImpl.java:102) ~[?:?]

	... 43 more

Caused by: java.nio.file.AccessDeniedException: /etc/openhab/_infdb/20240630

	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]

	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) ~[?:?]

	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]

	at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:440) ~[?:?]

	at java.nio.file.Files.newDirectoryStream(Files.java:482) ~[?:?]

	at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:301) ~[?:?]

	at java.nio.file.FileTreeWalker.next(FileTreeWalker.java:374) ~[?:?]

	at java.nio.file.FileTreeIterator.fetchNextIfNeeded(FileTreeIterator.java:83) ~[?:?]

	at java.nio.file.FileTreeIterator.hasNext(FileTreeIterator.java:103) ~[?:?]

	at java.util.Iterator.forEachRemaining(Iterator.java:132) ~[?:?]

	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845) ~[?:?]

	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]

	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]

	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]

	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]

	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]

	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]

	at org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl.<init>(YamlModelRepositoryImpl.java:102) ~[?:?]

	... 43 more

@@ -99,7 +99,8 @@ public YamlModelRepositoryImpl(@Reference(target = WatchService.CONFIG_WATCHER_F

// read initial contents
try (Stream<Path> files = Files.walk(watchPath)) {
files.filter(Files::isRegularFile).map(watchPath::relativize).forEach(f -> processWatchEvent(CREATE, f));
files.filter(f -> Files.isReadable(f) && Files.isRegularFile(f)).map(watchPath::relativize)
Copy link
Member

Choose a reason for hiding this comment

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

Is it really necessary to check .isReadable here? The check is done again when processWatchEvent is called.

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 was not sure what call triggered the AccessDeniedException. Not really clear when looking at the stack trace.

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@kaikreuzer kaikreuzer merged commit b932a4d into openhab:main Jul 4, 2024
5 checks passed
@kaikreuzer kaikreuzer added the bug An unexpected problem or unintended behavior of the Core label Jul 4, 2024
@kaikreuzer kaikreuzer added this to the 4.2 milestone Jul 4, 2024
@lolodomo lolodomo deleted the yaml_folder branch July 4, 2024 16:38
@@ -116,7 +117,8 @@ public void deactivate() {
public synchronized void processWatchEvent(Kind kind, Path path) {
Path fullPath = watchPath.resolve(path);
String pathString = path.toString();
if (Files.isDirectory(fullPath) || fullPath.toFile().isHidden() || !pathString.endsWith(".yaml")) {
if (!Files.isReadable(fullPath) || Files.isDirectory(fullPath) || path.startsWith("automation")
Copy link
Contributor

Choose a reason for hiding this comment

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

@lolodomo, @J-N-K - even though it's not a root cause, do you think it would make sense for performance reasons to explicitly ignore ".git" directories as well? See https://community.openhab.org/t/openhab-4-2-milestone-discussion/154316/185

I realize this could quickly turn into a rather large blacklist, though.

Copy link
Member

Choose a reason for hiding this comment

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

No. That doesn't make sense. Another guy in thread thread had a directory _infdb, why should we add .git but not _infdb? automation is different because it is readable, but may contain incompatible .yaml files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants