-
Task
-
Resolution: Won't Do
-
Undefined
-
None
-
None
-
None
-
False
-
-
False
-
-
-
Very Likely
-
0
dbapi.ConnectorDeployment.Annotations is not needed.
The annotations are stored on the dbapi.Connector structure and setting them on the private.ConnectorDeployment in connector_deployment.go by Annotations: PresentConnectorAnnotations(from.Annotations) can be simplified to Annotations: presentedConnector.Annotations.
I checked the FleetManager and FleetShard and both expect private.ConnectorDeployment.Annotations to be what is stored as dbapi.Connector.Annotations.
The Foreign Key gorm tries to establish between dbapi.ConnectorDeployment.Annotations to dbapi.ConnectorAnnotations causes problems when a Connector with Annotations is saved without a ConnectorDeployment record (FK violation).
This also highlights an issue with gorm that Foreign Key constraints are NOT added by AutoMigrator on the first execution. This means the Foreign Key issue above is not actually evident until the second time gorm AutoMigration is ran. This can be observed by running migration once and checking the definition of the processor_annotations[1] table. The FK will be missing. Run the migration again and the FK appears. The same FK (between connectors_deployments and connector_annotations) exists on dbapi.ConnectorDeployments but not in the various migration files and hence the issue is less visible for connector_deployments.
[1] You'll need to use PR https://github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/pull/1548 to have processor support.