fix endpoints plugin CI failures

Migration tests knew no endpoints head revision, so the parametrized guards raised KeyError. Register it in EXPECTED_HEAD_REVISION.

EndpointState declared lastreportedat both index=True and an explicit db.Index over the same column, and the baseline migration named single-column indexes differently from what create_all builds. On a pre-existing table the name-keyed guard could not see the create_all index and added a duplicate, tripping the idempotency guard. Drop the redundant declaration and rename migration indexes to ix_<table>_<column> to match.

endpoints was absent from the universal site profile, so the installer would not offer it and prune-schema would drop its tables at provisioning. Add it.

The agent design record lived under docs/, which is stripped to the public wiki and normally absent from the tree; a lone file there un-skipped the wiki-publish guards. Move it into the plugin.
This commit is contained in:
benjamin.baker
2026-08-27 07:10:43 -04:00
parent 3deff4f716
commit d68c6db9ab
5 changed files with 15 additions and 12 deletions

View File

@@ -4,6 +4,7 @@
"backups",
"computers",
"employees",
"endpoints",
"geenforce",
"guides",
"knowledgebase",

View File

@@ -50,7 +50,9 @@ def upgrade():
sa.PrimaryKeyConstraint('endpointstateid'),
sa.UniqueConstraint('assetid'),
)
create_index_if_missing('idx_endpointstates_lastreportedat',
create_index_if_missing('ix_endpointstates_assetid',
'endpointstates', ['assetid'])
create_index_if_missing('ix_endpointstates_lastreportedat',
'endpointstates', ['lastreportedat'])
create_table_if_missing(
@@ -68,11 +70,11 @@ def upgrade():
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('endpointeventid'),
)
create_index_if_missing('ixendpointeventsassetid', 'endpointevents',
create_index_if_missing('ix_endpointevents_assetid', 'endpointevents',
['assetid'])
create_index_if_missing('ixendpointeventseventid', 'endpointevents',
create_index_if_missing('ix_endpointevents_eventid', 'endpointevents',
['eventid'])
create_index_if_missing('ixendpointeventseventtime', 'endpointevents',
create_index_if_missing('ix_endpointevents_eventtime', 'endpointevents',
['eventtime'])
# Alerting/history reads by "this endpoint's events over time", so the
# composite is the index that actually gets used.
@@ -83,11 +85,12 @@ def upgrade():
def downgrade():
op.drop_index('idx_endpointevents_assetevent',
table_name='endpointevents')
op.drop_index('ixendpointeventseventtime', table_name='endpointevents')
op.drop_index('ixendpointeventseventid', table_name='endpointevents')
op.drop_index('ixendpointeventsassetid', table_name='endpointevents')
op.drop_index('ix_endpointevents_eventtime', table_name='endpointevents')
op.drop_index('ix_endpointevents_eventid', table_name='endpointevents')
op.drop_index('ix_endpointevents_assetid', table_name='endpointevents')
op.drop_table('endpointevents')
op.drop_index('idx_endpointstates_lastreportedat',
op.drop_index('ix_endpointstates_lastreportedat',
table_name='endpointstates')
op.drop_index('ix_endpointstates_assetid', table_name='endpointstates')
op.drop_table('endpointstates')

View File

@@ -82,10 +82,6 @@ class EndpointState(db.Model):
createdat = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
__table_args__ = (
db.Index('idx_endpointstates_lastreportedat', 'lastreportedat'),
)
def __repr__(self):
return f"<EndpointState {self.hostname or self.assetid}>"

View File

@@ -87,6 +87,9 @@ EXPECTED_HEAD_REVISION['tools'] = 'tools0001securesend'
EXPECTED_HEAD_REVISION['notifications'] = 'notifications0005boardorder'
# warranty adds the proof-of-cover document columns on top of its anchor.
EXPECTED_HEAD_REVISION['warranty'] = 'warranty0002proof'
# endpoints is a NEW post-cutover plugin: its 0001 genuinely creates the
# endpointstates + endpointevents tables the core chain never owned.
EXPECTED_HEAD_REVISION['endpoints'] = 'endpoints0001baseline'
# Plugins built after the cutover: their 0001 baseline really creates tables the
# core chain never owned.