acorn-io / runtime

A simple application deployment framework built on Kubernetes
https://docs.acorn.io/
Apache License 2.0
1.14k stars 101 forks source link

When user creates a new credentials as part of deploying app/ picks an existing one , he is prompted again to pick a credential. #2410

Closed sangee2004 closed 6 months ago

sangee2004 commented 6 months ago

acorn version - v0.10.0-rc2-9-g43dbcbf4+43dbcbf4

Steps to reproduce the problem:

Scenario 1:

  1. Deploy app with credentials
    secrets: config: {
    type: "credential.acorn.io/mytestcred"
    params: {
        promptOrder: ["username", "password"]
    }
    data: {
        username:      "abc"
        password:      "ppp"
    }
    }
    containers: {
    mytest: {
        image: "nginx"
    }
    }
  2. When prompted for credentials , enter new credentials.
  3. After this , user is presented withe list of existing credentials (which also includes the one that was just created) and asked to choose from the list.
mytestnew
STATUS: ENDPOINTS[] HEALTHY[] UPTODATE[] 
STATUS: ENDPOINTS[] HEALTHY[0] UPTODATE[0] waiting for quota allocation; (container: mytest): pending; (secret: config): pending
? password **
? username **
STATUS: ENDPOINTS[] HEALTHY[0] UPTODATE[0] "acorn login mytestnew" required
STATUS: ENDPOINTS[] HEALTHY[0/1] UPTODATE[0] "acorn login mytestnew" required
STATUS: ENDPOINTS[] HEALTHY[0/1] UPTODATE[1] "acorn login mytestnew" required
? Choose an existing credential or enter a new one Existing: config-n778n (Keys: [password, username], Created: [2024-01-12 10:55:50 -0800 PST])
STATUS: ENDPOINTS[] HEALTHY[1] UPTODATE[1] "acorn login mytestnew" required

┌───────────────────────────────────────────────┐
| STATUS: ENDPOINTS[] HEALTHY[1] UPTODATE[1] OK |
└───────────────────────────────────────────────┘

Expected Behavior: If user is creating a new cred , we should be able to use the created one for the app instead of having to letting him select again.

Scenario 2:

  1. Deploy app with creds and create new cred.
  2. Deploy another app with same credential type as step1.
  3. When prompted for credentials , pick the existing one that gets listed.
  4. Notice that user will be prompted again to pick a cred.
mytestnew5
STATUS: ENDPOINTS[] HEALTHY[] UPTODATE[] 
STATUS: ENDPOINTS[] HEALTHY[0] UPTODATE[0] waiting for quota allocation; (container: mytest): pending; (secret: config): pending
? Choose an existing credential or enter a new one Existing: config-2kl5g (Keys: [password, username], Created: [2024-01-12 11:09:45 -0800 PST])
STATUS: ENDPOINTS[] HEALTHY[0] UPTODATE[0] "acorn login mytestnew5" required
STATUS: ENDPOINTS[] HEALTHY[0/1] UPTODATE[0] "acorn login mytestnew5" required
STATUS: ENDPOINTS[] HEALTHY[0/1] UPTODATE[1] "acorn login mytestnew5" required
? Choose an existing credential or enter a new one Existing: config-2kl5g (Keys: [password, username], Created: [2024-01-12 11:09:45 -0800 PST])
STATUS: ENDPOINTS[] HEALTHY[1] UPTODATE[1] "acorn login mytestnew5" required

Expected Behavior: User should not be prompted multiple times.

g-linville commented 6 months ago

Not sure what changed, but I am no longer seeing this behavior on the main branch of runtime, installed in my local k8s. (Haven't tried it against the SaaS.) Both scenarios produce the expected behavior as described in this issue. Moving this into QA. Let me know if something still seems broken.

sangee2004 commented 6 months ago

@g-linville This issue reproduced inconsistently for me earlier. Also i saw this happen when testing in main .

g-linville commented 6 months ago

I'll bring it back to In Progress for now and play around some more and see if I can cause this bug to appear.

g-linville commented 6 months ago

Merged the fix. The user should now be prompted only one time to provide credentials (or select existing ones).

sangee2004 commented 6 months ago

@g-linville With latest build - acorn version - v0.10.0-rc2-35-g3cf6c107+3cf6c107 , I am not prompted to enter credentials when deploying apps with credentials.

App deployment just stays at acorn login mytestapp" required state without prompting the user:

mytestapp
STATUS: ENDPOINTS[] HEALTHY[] UPTODATE[] 
STATUS: ENDPOINTS[] HEALTHY[0] UPTODATE[0] "acorn login mytestapp" required
^C%  
sangee2004 commented 6 months ago

@g-linville The Acornfile I used for deploying apps when I am not prompted to enter the creds (has secrets being used as env variable in container):

secrets: config: {
    type: "credential.acorn.io/mytestcred"
    params: {
        promptOrder: ["username", "password","testnodef"]
    }
    data: {
        username:      "abcd"
        password:      "ppp"
        testnodef:      "yy"
    }
}
containers: {
    mytest: {
        image: "nginx"
        env:{
           username: "secret://config/username"
           password: "secret://config/password"
    }
}
}

I am prompted as expected when using the Acornfile mentioned in the issue.

g-linville commented 6 months ago

Should be good now.

sangee2004 commented 6 months ago

Tested with - acorn version - v0.10.0-rc2-36-g994b4680+994b4680

User is prompted to enter/pick existing credentials as expected when deploying apps with creds and containers having secrets consumed as env variables.

Also i am not able to reproduce the initial issue reported in this issue with user being prompted twice when entering a new cred/ choosing an existing cred. User is prompted only once to enter a new credential/pick existing one.