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

Port variable: Single point of truth #140

Open
ckunki opened this issue Jan 26, 2024 · 0 comments
Open

Port variable: Single point of truth #140

ckunki opened this issue Jan 26, 2024 · 0 comments
Labels
refactoring Code improvement without behavior change

Comments

@ckunki
Copy link
Contributor

ckunki commented Jan 26, 2024

In the initial implementation of the AI-Lab (copied from SLC Sandbox) the Jupyter port 8888 was mentioned literally and redunant in different files: Ansible, Python, Tests, CloudformationStack, Dockerfile, Documentation, ...

Ticket #75 requested to change the port of the Jupyter server to 49494.

AI-Lab Docker Edition

For AI-Lab Docker Edition this could be done the usual way by

  • Defining the final value in the Ansible scripts,
  • Forwarding it to Ansible facts, and
  • Finally using it for port forwardings, welcome message, etc.

AMI and VM Edition

AMI and VM Editions cannot use this approach:

Function run_setup_ec2_and_install_dependencies in file lib/setup_ec2/run_setup_ec2_and_install_dependencies.py

  1. Calls run_lifecycle_for_ec2()
  2. Before calling run_install_dependencies()
  3. Writes a log message about how to connect to the Jupyter server

Ansible is run in step (2) and Ansible facts are available only after step (2).

Step (1) in contrast already needs the port information to create an instance of CloudformationStack wrapped into CloudformationStackContextManager which in method enter() calls the CF stack's method upload_cloudformation_stack().

This finally loads the jinja template templates/ec2_cloudformation.jinja.yaml and could inject the value for the port to avoid redundancies.

Acceptance Criteria

The current ticket requests to

  • Define the port in python
  • In run_setup_ec2_and_install_dependencies
    • Replace the literal values by the value of the port variable in the log message
    • forward the variable to calls for rendering the template
  • For Ansible
@ckunki ckunki added the refactoring Code improvement without behavior change label Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code improvement without behavior change
Projects
None yet
Development

No branches or pull requests

1 participant