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

Don't raise dependency errors for dynamic credential fields #4798

Closed
wants to merge 1 commit into from
Closed

Don't raise dependency errors for dynamic credential fields #4798

wants to merge 1 commit into from

Conversation

wenottingham
Copy link
Contributor

Example: setting ssh_key_unlock by hand when the key comes from a vault.

Example: setting ssh_key_unlock by hand when the key comes from a vault.
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@wenottingham
Copy link
Contributor Author

For #4791

@omgjlk
Copy link
Contributor

omgjlk commented Sep 20, 2019

Well this lets me save the dialog, AND execute a command on a host using that credential prompts for the passphrase. However when trying to use it now the job fails immediately, the same way as if it didn't get prompted for the passphrase.

image

@omgjlk
Copy link
Contributor

omgjlk commented Sep 20, 2019

So I guess technically this pull request DOES solve a bug, and should be merged. But it uncovers a deeper underlying bug too.

@wenottingham
Copy link
Contributor Author

Anything in the logs that looks like a traceback or gives more info as to how it failed?

@omgjlk
Copy link
Contributor

omgjlk commented Sep 20, 2019

Actually you know what, I forgot to make this code change on the task container. I'll work that out and get back to you with any additional logging.

@@ -652,6 +652,9 @@ def validate(self, value, model_instance):
)
if match:
label, extraneous = match.groups()
# bail if the dependency is for a dynamic source
Copy link
Contributor

@jakemcdermott jakemcdermott Sep 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For new credentials, these dynamic input relationships don't exist yet, and the dependency validation error will still occur:

Screenshot from 2019-09-21 09-59-20

To get the expected validation behavior, we'll need to come up with a way of knowing the intended dynamic inputs before they've been created.

For regular / static fields that are encrypted, we've dealt with similar issues in the past by (ab)using the special $encrypted value as a placeholder. We may need to do something similar here.

I'd need to take a deeper look at this before proposing anything specific.

@jakemcdermott
Copy link
Contributor

@omgjlk Once the prompted fields are saved, I suspect that an updated task container might be all that's needed to resolve #4798 (comment) but it would be good to confirm - thanks for taking a look.

@omgjlk
Copy link
Contributor

omgjlk commented Sep 23, 2019

@omgjlk Once the prompted fields are saved, I suspect that an updated task container might be all that's needed to resolve #4798 (comment) but it would be good to confirm - thanks for taking a look.

I restarted the task container, which seems to have already had the edited code in it (I'm guessing with the docker-compose style of deployment there is a shared venv).

Unfortunately the task still fails, and there aren't really any good logs to show WHY it failed.

	awx_task     | 2019-09-23 13:08:06,773 DEBUG    awx.main.dispatch delivered 640de1d5-99ce-425b-8bd9-1eb04e3a7639 to worker[196] qsize 0
awx_task     | 2019-09-23 13:08:06,777 DEBUG    awx.main.dispatch task 640de1d5-99ce-425b-8bd9-1eb04e3a7639 starting awx.main.scheduler.tasks.run_task_manager(*[])
awx_task     | 2019-09-23 13:08:06,781 DEBUG    awx.main.scheduler Running Tower task manager.
awx_task     | 2019-09-23 13:08:06,792 DEBUG    awx.main.scheduler Starting Scheduler
awx_task     | 2019-09-23 13:08:06,849 DEBUG    awx.main.scheduler Starting ad_hoc_command 11794 (pending) in group tower instance awx (remaining_capacity=76)
awx_task     | 2019-09-23 13:08:06,857 DEBUG    awx.main.scheduler Submitting ad_hoc_command 11794 (waiting) to <instance group, instance> <1,awx>.
awx_task     | 2019-09-23 13:08:06,882 DEBUG    awx.main.scheduler ad_hoc_command 11794 (waiting) consumed 6 capacity units from tower with prior total of 0
awx_task     | 2019-09-23 13:08:06,938 DEBUG    awx.main.dispatch publish awx.main.tasks.RunAdHocCommand(3c1d9572-1486-45b4-95e9-2012c5076d86, queue=awx)
awx_task     | 2019-09-23 13:08:06,953 DEBUG    awx.main.dispatch delivered 3c1d9572-1486-45b4-95e9-2012c5076d86 to worker[198] qsize 0
awx_task     | 2019-09-23 13:08:06,956 DEBUG    awx.main.dispatch task 3c1d9572-1486-45b4-95e9-2012c5076d86 starting awx.main.tasks.RunAdHocCommand(*[11794])
awx_task     | 2019-09-23 13:08:06,954 DEBUG    awx.main.dispatch task 640de1d5-99ce-425b-8bd9-1eb04e3a7639 is finished
awx_task     | 2019-09-23 13:08:09,421 INFO     awx.main.commands.run_callback_receiver Event processing is finished for Job 11794, sending notifications
awx_task     | 2019-09-23 13:08:09,421 INFO     awx.main.commands.run_callback_receiver Event processing is finished for Job 11794, sending notifications
awx_task     | 2019-09-23 13:08:09,514 DEBUG    awx.main.tasks ad_hoc_command 11794 (running) finished running, producing 1 events.
awx_task     | 2019-09-23 13:08:09,577 WARNING  awx.main.dispatch ad_hoc_command 11794 (failed) encountered an error (rc=1), please see task stdout for details.
awx_task     | 2019-09-23 13:08:09,579 DEBUG    awx.main.dispatch task 3c1d9572-1486-45b4-95e9-2012c5076d86 starting awx.main.tasks.handle_work_error(*['3c1d9572-1486-45b4-95e9-2012c5076d86'])
awx_task     | 2019-09-23 13:08:09,580 DEBUG    awx.main.tasks Executing error task id 3c1d9572-1486-45b4-95e9-2012c5076d86, subtasks: [{'type': 'ad_hoc_command', 'id': 11794}]
awx_task     | 2019-09-23 13:08:09,584 DEBUG    awx.main.dispatch publish awx.main.scheduler.tasks.run_task_manager(3ef1968c-b49e-456c-a681-14ccadf061c9, queue=awx_private_queue)

The web UI shows this for output

Enter passphrase for /tmp/awx_11794_yh899vb9/artifacts/11794/ssh_key_data

I'm totally wiling to drop a rpdb.set_trace() somewhere in here to catch this interaction in a debugging session, if there are values and such you'd like me to dump at some points in this.

@ryanpetrello
Copy link
Contributor

ryanpetrello commented Sep 23, 2019

@wenottingham @jakemcdermott @omgjlk I'm not certain this is going to work, and the more I think about it, I think supporting this new dynamic input model means we're going to have to lose this level of validation, because the order of operations just doesn't work.

@ryanpetrello
Copy link
Contributor

@wenottingham we might end up going with this instead:

#4807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants