eclipse / hawkbit

Eclipse hawkBit™
https://projects.eclipse.org/projects/iot.hawkbit
Eclipse Public License 2.0
453 stars 187 forks source link

EntityAlreadyExistsException AssignDs to target #1660

Open meladon1337 opened 6 months ago

meladon1337 commented 6 months ago

I have Hawkbit running with a Azure SQL Database connected. When i call the Target API with:

curl --location 'https://URL/rest/v1/targets/TARGET_ID/assignedDS' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic TOKEN' \ --data '[ { "id": ID } ]'

I get the following error. I dont see any problems in the Database and the error does not help. { "exceptionClass": "org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException", "errorCode": "hawkbit.server.error.repo.entitiyAlreayExists", "message": "The given entity already exists in database" }

I also set the log to Trace, so i can see more output, but still not more detail: Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.473 TRACE 1661112 --- [nio-8443-exec-3] o.s.t.i.TransactionInterceptor : Completing transaction for [org.eclipse.hawkbit.repository.jpa.management.JpaDeploymentManagement.assignDistributionSets] Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.484 DEBUG 1661112 --- [nio-8443-exec-3] o.s.j.s.SQLStateSQLExceptionTranslator : Extracted SQL state class '23' from value '23000' Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.485 DEBUG 1661112 --- [nio-8443-exec-3] .m.m.a.ExceptionHandlerExceptionResolver : Using @ExceptionHandler org.eclipse.hawkbit.rest.exception.ResponseExceptionHandler#handleSpServerRtExceptions(HttpServletRequest, Exception) Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.485 TRACE 1661112 --- [nio-8443-exec-3] o.s.web.method.HandlerMethod : Arguments: [SecurityContextHolderAwareRequestWrapper[ org.springframework.security.web.header.HeaderWriterFilter$HeaderWriterRequest@268c859d], org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException: The given entity already exists in database] Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.485 DEBUG 1661112 --- [nio-8443-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [/] and supported [application/json, application/+json, application/json, application/+json, application/cbor] Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.486 TRACE 1661112 --- [nio-8443-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [org.eclipse.hawkbit.rest.json.model.ExceptionInfo@3bb3da5a] Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.486 DEBUG 1661112 --- [nio-8443-exec-3] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException: The given entity already exists in database] Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.486 TRACE 1661112 --- [nio-8443-exec-3] o.s.web.servlet.DispatcherServlet : No view rendering, null ModelAndView returned. Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.487 DEBUG 1661112 --- [nio-8443-exec-3] o.j.s.OpenEntityManagerInViewInterceptor : Closing JPA EntityManager in OpenEntityManagerInViewInterceptor Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.487 DEBUG 1661112 --- [nio-8443-exec-3] o.s.web.servlet.DispatcherServlet : Completed 409 CONFLICT, headers={} Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.487 DEBUG 1661112 --- [nio-8443-exec-3] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.488 TRACE 1661112 --- [nio-8443-exec-3] o.s.b.w.s.f.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@28daa682 Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.488 DEBUG 1661112 --- [nio-8443-exec-3] o.a.tomcat.util.net.SocketWrapperBase : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@98b6818:org.apache.tomcat.util.net.SecureNioChannel@4b23caf2:java.nio.channels.SocketChannel[connected local=/10.0.0.4:8443 remote=/87.153.114.212:53188]], Read from buffer: [0] Feb 15 14:55:09 java[1661112]: 2024-02-15 14:55:09.488 DEBUG 1661112 --- [nio-8443-exec-3] org.apache.tomcat.util.net.NioEndpoint : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@98b6818:org.apache.tomcat.util.net.SecureNioChannel@4b23caf2:java.nio.channels.SocketChannel[connected local=/10.0.0.4:8443 remote=/87.153.114.212:53188]], Read direct from socket: [0]

Any ideas?

matkomilovich commented 1 month ago

hi @meladon1337, were you able to solve it? I'm having the same issue and I'm not sure what it could be due to. I don't have any distribution set or rollout associated with the target (I created both with the Management API), but I still get the 409 error.