Skip to content

added in a "monitor" subcommand to monitor jobs to completion #141

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dansteen
Copy link
Contributor

@dansteen dansteen commented Apr 19, 2018

Hi @jrasell,

I've finally managed to circle back around and get this sorted out. I've refactored the monitor function to be its own subcommand as we had discussed. I named it "monitor" (instead of "batch-monitor" or similar) because it can technically be used to monitor services or system jobs as well as batch jobs. I've also updating things to match how you are doing the CLI components.

I opened a new pull request for this since its so radically different from what I had before.

Meant to resolve #77

Thanks!

)

// MonitorCommand is the command implementation that allows users to monitor
// a deploy until it completes
Copy link
Member

Choose a reason for hiding this comment

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

is it not monitoring the job until it completes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct. will fix.

time.Sleep(time.Second * 5)
continue
}
//logging.Info("lastIndex: %v", meta.LastIndex)
Copy link
Member

Choose a reason for hiding this comment

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

can we remove this commented out line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep.


Arguments:

EVAL_ID nomad job evaluation
Copy link
Member

Choose a reason for hiding this comment

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

More of a design question and I am happy to be wrong, but would it not be better if this was the JobID and then Levant would discover the allocs from this, rather than the eval ID?

Copy link
Contributor Author

@dansteen dansteen Apr 27, 2018

Choose a reason for hiding this comment

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

I completely agree - that would be both better and more user friendly. The trouble is that if you are just monitoring the job via the job id, you aren't really guaranteed to be monitoring a particular invocation of levant deploy ....

As an example, if you run levant deploy job_1, and then a different user runs levant deploy job_1 after you do and before you run the monitor command, then, if you run levant monitor job_1 and we use the job_id to pull the most recent evaluation, you will wind up monitoring the other users invocation of the job rather than your own. I agree this is somewhat unlikely, however I can certainly see automation tools running into this. It seemed like the need to guarantee that the command monitors what you think it is monitoring was more important.

Having said that, I do think that you are right and many people will not care. We can put a ticket in for that, and I can add that in as an additional feature if that works for you.

Number of seconds to allow until we exit with an error.

-log-level=<level>
Specify the verbosity level of Levant's logs. Valid values include DEBUG,
Copy link
Member

Choose a reason for hiding this comment

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

formatting

General Options:

-timeout=<int>
Number of seconds to allow until we exit with an error.
Copy link
Member

Choose a reason for hiding this comment

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

please use four spaces for this indent

@dansteen
Copy link
Contributor Author

@jrasell I fixed the formatting and comment issues.

@dansteen
Copy link
Contributor Author

I think the check failures are an error in the checks. It seems to say that the MonitorCommand struct is not being used, but it is used in the commands.go file. Am I understanding that incorrectly?

@jrasell
Copy link
Member

jrasell commented Apr 30, 2018

@dansteen the check is pointing the the args field not being used within the MonitorCommand struct.

@dansteen
Copy link
Contributor Author

dansteen commented May 3, 2018

@jrasell ok. fixed up the args issue, and also fixed up things to use new logging stuff.

@jrasell
Copy link
Member

jrasell commented May 10, 2018

thanks @dansteen; I am going to push out a release and then get this in to 0.2.0 if that is OK for you?

@dansteen
Copy link
Contributor Author

sure!

@dansteen
Copy link
Contributor Author

@jrasell any chance of getting this in for the 0.2.0 that is being worked on now?

@jrasell
Copy link
Member

jrasell commented Jun 20, 2018

yes sorry my bad; I have been a bit slack the past few weeks. are you able to resolve the conflict and I will get it in today

@dansteen
Copy link
Contributor Author

pretty sure it's just our conversation above from the 26th. I don't think there are any actual conflicts.

@jrasell
Copy link
Member

jrasell commented Jun 20, 2018

the conflict as in the merge conflict; if not I will fix it up when I have a moment later/tomorrow morning

@austinworks
Copy link

This seems pretty great and our team could definitely use this -- we're shipping database migrations prior to deploying new code and would love levant to verify that the tasks completed correctly or exit non-zero

@josegonzalez
Copy link

If given commit bit, I'd be happy to fix the merge conflicts (and merge once @jrasell gives second approval) :)

@hashicorp-cla
Copy link

hashicorp-cla commented Jul 26, 2020

CLA assistant check
All committers have signed the CLA.

@eugengarkusha
Copy link

This is very useful feature, @jrasell is there a way to move it forward?
Thanks

@dansteen
Copy link
Contributor Author

dansteen commented Sep 29, 2020

@eugengarkusha and @jrasell I signed the CLA just in case that was the only thing holding it back.

Base automatically changed from master to main March 3, 2021 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to wait until batch jobs *complete* prior to returning
6 participants