Skip to content

Feature/data handling improvements#3

Open
stefbenoist wants to merge 4 commits intocea-hpc:masterfrom
stefbenoist:feature/data-handling-improvements
Open

Feature/data handling improvements#3
stefbenoist wants to merge 4 commits intocea-hpc:masterfrom
stefbenoist:feature/data-handling-improvements

Conversation

@stefbenoist
Copy link

@stefbenoist stefbenoist commented Jan 15, 2026

Hi @fihuer, this PR brings some improvements around data handling:

  • Fix SQLAlchemy 2.0 issue for strings not more accepted for attribute names

“Using strings to represent relationship names in ORM operations such as Query.join(), as well as strings for all ORM >attribute names in loader options like selectinload() is deprecated and will be removed in SQLAlchemy 2.0. The class->bound attribute should be passed instead.”
https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#orm-query-joining-loading-on-relationships-uses-attributes-not-strings

  hosts = db.session.query(Host).options(joinedload(Host.profiles))
  • Return SQLAlchemy error messages for conflicts instead of "already exists" static message

  • Allow configuring SQLAlchemy db connection pool (pool size and recycle)

# DB Pool connection config
    pool_size = get_int_param(app,'BMGR_DB_POOL_SIZE', 20)
    pool_recycle = get_int_param(app,'BMGR_DB_POOL_RECYCLE', 600)

    app.config.setdefault('SQLALCHEMY_ENGINE_OPTIONS', {'pool_size': pool_size, 'pool_recycle': pool_recycle})
  • Allow customizing data initialization in an idempotent way for alias and resources from config instead of specific code
# init data
BMGR_INIT_DATA = [
    {"type": "resource", "name": "ipxe_normal_boot", "template_uri": "file://disk_boot.ipxe.jinja"},
    {"type": "resource", "name": "ipxe_deploy_boot", "template_uri": "file://deploy_boot.ipxe.jinja"},
    {"type": "resource", "name": "kickstart", "template_uri": "file://ks_rhel7.jinja"},
    {"type": "resource", "name": "poap_config", "template_uri": "file://poap_config.jinja"},
    {"type": "alias", "name": "ipxe_boot", "target": "ipxe_normal_boot"}
]
  • Unlimit text length for profile data storage as it may contain large data such as SSH keys
  _attributes = db.Column('attributes', db.String())
  • Cleanup some code and comments

Unit Tests have been added and documentation updated for data initialization.

Thanks for your review.

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.

1 participant