langflow icon indicating copy to clipboard operation
langflow copied to clipboard

Cannot disable autologin or create unique creds for superuser

Open syoung-gaia opened this issue 1 year ago • 4 comments

Bug Description

Looking at the code, I should only need to uncomment and add values to these few lines within my own values.yaml file:

    # autoLogin: true|false
    # superuser: <superuser login>
    # superuserPassword: <superuser password>
    # secretKey: <encryption key, optional>
    # newUserIsActive: true|false
    autoLogin: false
    superuser: "admin"
    superuserPassword: "Testing123"
    secretKey: "tEsTMysEcrETkEy"
    newUserIsActive: true

However, this block never gets inserted into the rendered manifest. There must either be a bug with Helm, or this if-statement within the backend-statefulset.yaml file isn't correct:

{{- if and (hasKey .Values.langflow.backend "autoLogin") (eq .Values.langflow.backend.autoLogin false) }}

Certainly looks right. But it also never works. I've checked everything imaginable, like running yamllint against my values.yaml file, and running helm template to see if any errors are received. Sure would be nice if Helm's --debug flag actually printed the logic steps & results. Why does something so seemingly innocuous always turns out to be rather deadly?

Reproduction

  1. Configure build scripts for your K8s/OpenShift environment accordingly using default values where possible.
  2. Build a working instance of Langflow
  3. Uncomment & configure AutoLogin/Superuser values appropriately
  4. Build modified instance of Langflow
  5. Test for AutoLogin disabled

Expected behavior

I expect AutoLogin o be disabled. The superuser & superuserPassword should be required to login to Langflow The Admin panel within the UI should be enabled. New users can be added and granted access to Langflow.

Who can help?

No response

Operating System

OpenShift 4.16

Langflow Version

1.1.1

Python Version

3.12

Screenshot

No response

Flow File

No response

syoung-gaia avatar Dec 17 '24 22:12 syoung-gaia

Hey @syoung-gaia! I'm here to help you with any bugs, questions, or contributions you have in mind. Let's work together to solve this issue!

The issue you're experiencing with the autoLogin setting not being applied in the rendered manifest could be due to how the Helm chart processes the values.yaml file. Here are a few things to check:

  1. Path in values.yaml: Ensure that the path in your values.yaml file matches the expected structure in the Helm chart. The autoLogin and related parameters should be nested under the correct hierarchy, such as langflow.backend. For example:

    langflow:
      backend:
        autoLogin: false
        superuser: "admin"
        superuserPassword: "Testing123"
        secretKey: "tEsTMysEcrETkEy"
        newUserIsActive: true
    
  2. Helm Template Logic: The conditional logic in backend-statefulset.yaml seems correct, but ensure that the values.yaml file is correctly formatted and that there are no indentation issues. YAML is sensitive to spaces and indentation, which can affect how values are parsed.

  3. Helm Debugging: While Helm's --debug flag might not show logic steps, you can use helm template to render the templates locally and inspect the output. This can help identify if the values are being correctly substituted.

  4. Helm Version: Ensure you are using a compatible version of Helm that supports the features used in the chart. Sometimes, discrepancies in Helm versions can lead to unexpected behavior.

  5. Check for Overrides: Verify that there are no other Helm value files or command-line overrides that might be affecting the values you set in values.yaml.

If these steps don't resolve the issue, it might be helpful to review the Helm chart's documentation or source code to ensure there are no additional conditions or settings affecting the autoLogin parameter.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

dosubot[bot] avatar Dec 17 '24 22:12 dosubot[bot]

@dosu I have previously done all those things you suggest. Otherwise, I would have solved the problem and not needed to submit this issue to GitHub. But thank you for trying anyway...

syoung-gaia avatar Dec 17 '24 23:12 syoung-gaia

This is a tough nut to crack, could really use your help on this, @ogabrielluiz.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

dosubot[bot] avatar Dec 17 '24 23:12 dosubot[bot]

Hi @syoung-gaia, I've created a working deployment of Langflow on Kubernetes that fixes the autoLogin and superuser configuration. Here's the complete solution:

First, create this folder structure:

helm/ ├── Chart.yaml ├── templates/ │ ├── deployment.yaml │ └── service.yaml └── values.yaml

Create Chart.yaml:

apiVersion: v2
name: langflow
description: A Helm chart for Langflow
version: 0.1.0
appVersion: "1.1.1"

Create values.yaml:

langflow:
  backend:
    autoLogin: false
    superuser: "admin"
    superuserPassword: "Testing123"
    secretKey: "tEsTMysEcrETkEy"
    newUserIsActive: true

Create templates/deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: langflow
spec:
  replicas: 1
  selector:
    matchLabels:
      app: langflow
  template:
    metadata:
      labels:
        app: langflow
    spec:
      containers:
      - name: langflow
        image: langflowai/langflow:v1.1.1
        env:
        - name: CONFIG_DIR
          value: "/tmp"
        - name: LANGFLOW_PORT
          value: "7860"
        - name: LANGFLOW_HOST
          value: "0.0.0.0"
        - name: LANGFLOW_AUTO_LOGIN
          value: "false"
        - name: LANGFLOW_SUPERUSER
          value: "{{ .Values.langflow.backend.superuser }}"
        - name: LANGFLOW_SUPERUSER_PASSWORD
          value: "{{ .Values.langflow.backend.superuserPassword }}"
        - name: LANGFLOW_SECRET_KEY
          value: "{{ .Values.langflow.backend.secretKey }}"
        - name: LANGFLOW_NEW_USER_IS_ACTIVE
          value: "{{ .Values.langflow.backend.newUserIsActive }}"
        ports:
        - containerPort: 7860
          name: http
        livenessProbe:
          httpGet:
            path: /health
            port: 7860
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /health
            port: 7860
          initialDelaySeconds: 30
          periodSeconds: 10

Create templates/service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: langflow
spec:
  selector:
    app: langflow
  ports:
  - name: http
    port: 7860
    targetPort: 7860
  type: ClusterIP

To deploy: Install the chart helm install langflow . -f values.yaml -n langflow

Watch the pod status

kubectl get pods -n langflow -w

Key points addressed:

Fixed the port validation error by using proper environment variables Configured autoLogin and superuser credentials correctly Added health checks with appropriate timing Set up proper service networking

The pod should now start successfully and you should be able to:

Access Langflow through the service Login with the configured superuser credentials Add new users as needed

You can download the full code here: helm.zip

Let me know if you need any clarification or run into other issues!

Cristhianzl avatar Dec 23 '24 14:12 Cristhianzl

Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to help you.

carlosrcoelho avatar Jan 03 '25 19:01 carlosrcoelho