mykso/myks

Incorrect application name is silently ignored

Closed this issue · 6 comments

Incorrect application name is silently ignored
kbudde commented

@Zebradil what is this issue about?

@kbudde It'a minor problem:

myks all MY_ENV MY_APP,NOT_EXISTS

doesn't complain about asking it to process a non-existing application. It is bad when you have a typo in the name, it is okay when you want to process an application, which doesn't exist in all target environments. So I thought to add a warning message at least.

kbudde commented

Did some tests

1. providing subset of configured and existing apps (good)

=> works as expected

$ myks all envs/mykso/dev argocd,httpbingo
7:16AM INF [mykso-dev > httpbingo > sync] Synced
7:16AM INF [mykso-dev > httpbingo > helm] Helm chart rendered
7:16AM INF [mykso-dev > httpbingo > ytt] Local YTT rendered
7:16AM INF [mykso-dev > httpbingo > render] Completed
7:17AM INF [mykso-dev > argocd > sync] Synced
7:17AM INF [mykso-dev > argocd > ytt] Local YTT rendered
7:17AM INF [mykso-dev > argocd > render] Completed

2. providing a non configured, non existing app, e.g. a typo

=> exits with application not found

$ myks all envs/mykso/dev argocd,httpbingo,foo
7:17AM INF Setting log level to: info
7:17AM ERR [mykso-dev > init] Unable to initialize applications error="Application not found: foo"
7:17AM FTL Unable to initialize myks's globe error="failed to process item: Application not found: foo"

3. configure an app which does not exist -> configuration error (env-data.ytt.yaml)

=> Warning but no exit. I would propose to exit here as well. It's not just a typo it's a configuration error.

$ myks all envs/mykso/dev # or
$ myks all envs/mykso/dev foobar,argocd
7:23AM WRN [mykso-dev > init] Unable to initialize application error="application prototype does not exist" app=foobar dir=envs/mykso/dev
7:23AM INF [mykso-dev > argocd > sync] Synced
7:23AM INF [mykso-dev > argocd > ytt] Local YTT rendered
7:23AM INF [mykso-dev > argocd > render] Completed

4. configure an app only for one env and try to render multiple envs

=> exits with application not found. This is sad as this limits ondemand rendering of multiple envs a lot.

$ myks all envs/mykso argocd,onlyprod
7:29AM ERR [mykso-dev > init] Unable to initialize applications error="Application not found: onlyprod"
7:29AM FTL Unable to initialize myks's globe error="failed to process item: Application not found: onlyprod"

my conclusion:

  • changing 3. to exit is required
  • Improving 4. would be nice to have.
kbudde commented

New behaviour with #52

# 1. providing subset of configured and existing apps (good)
$ myks all envs/mykso/dev argocd,httpbingo
9:32AM INF Setting log level to: info
9:32AM INF [mykso-dev > httpbingo > sync] Synced
9:32AM INF [mykso-dev > httpbingo > helm] Helm chart rendered
9:32AM INF [mykso-dev > httpbingo > ytt] Local ytt rendered
9:32AM INF [mykso-dev > httpbingo > render] Completed
9:32AM INF [mykso-dev > argocd > sync] Synced
9:32AM INF [mykso-dev > argocd > ytt] Local ytt rendered
9:32AM INF [mykso-dev > argocd > render] Completed

# 2. foo is provided via commandline but not configured for the env -> Warn and go on
$ myks all envs/mykso/dev argocd,httpbingo,foo
9:32AM INF Setting log level to: info
9:32AM WRN [mykso-dev > init] Application not found app=foo dir=envs/mykso/dev
9:32AM INF [mykso-dev > httpbingo > sync] Synced
9:32AM INF [mykso-dev > httpbingo > helm] Helm chart rendered
9:32AM INF [mykso-dev > httpbingo > ytt] Local ytt rendered
9:32AM INF [mykso-dev > httpbingo > render] Completed
9:32AM INF [mykso-dev > argocd > sync] Synced
9:32AM INF [mykso-dev > argocd > ytt] Local ytt rendered
9:32AM INF [mykso-dev > argocd > render] Completed

# 3. application foobar is configured in env-data but does not exist -> FTL
$ myks all envs/mykso/dev
9:33AM INF Setting log level to: info
9:33AM ERR [mykso-dev > init] Unable to initialize applications error="unable to initialize application foobar for env envs/mykso/dev. Err application prototype does not exist"
9:33AM FTL Unable to initialize myks\'s globe error="unable to initialize application foobar for env envs/mykso/dev. Err application prototype does not exist"

# 3b.  application foobar is configured in env-data but does not exist and it is provided via commandline -> It justs warns.
# issue: at the time of evaluation it's not clear if the app exists for another environmen. See #4
$ myks all envs/mykso/dev foobar,argocd
9:34AM INF Setting log level to: info
9:34AM WRN [mykso-dev > init] Unable to initialize application error="application prototype does not exist" app=foobar dir=envs/mykso/dev
9:34AM INF [mykso-dev > argocd > sync] Synced
9:34AM INF [mykso-dev > argocd > ytt] Local ytt rendered
9:34AM INF [mykso-dev > argocd > render] Completed

#4 render two envs. Provide an application which only exists for one. missing app is ignored.
# actually at this stage it cannot be checked easily if the application exists for another env
$ myks all envs/mykso argocd,only-prod
9:35AM INF Setting log level to: info
9:35AM WRN [mykso-dev > init] Application not found app=only-prod dir=envs/mykso/dev
9:35AM INF [mykso-prod > only-prod > sync] Synced
9:35AM INF [mykso-prod > only-prod > helm] Helm chart rendered
9:35AM INF [mykso-prod > only-prod > ytt] Local ytt rendered
9:35AM INF [mykso-prod > only-prod > render] Completed
9:35AM INF [mykso-dev > argocd > sync] Synced
9:35AM INF [mykso-dev > argocd > ytt] Local ytt rendered
9:35AM INF [mykso-dev > argocd > render] Completed
9:35AM INF [mykso-prod > argocd > sync] Synced
9:35AM INF [mykso-prod > argocd > ytt] Local ytt rendered
9:35AM INF [mykso-prod > argocd > render] Completed

Awesome, thanks a lot!

The logic does make sense to me. To improve it further, we would need either to restructure the internal logic to be able to perform the validation step after the init process but before the rendering process or to make logging less noisy (it'd be cool to have it done in a similar way to how it does docker-compose — with multiple parallel progress bars). But for now, I think it's already good enough.

Solved with #52