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

Fix manager() adding extra quotes #1122

Merged
merged 1 commit into from May 17, 2019
Merged

Conversation

vstumpf
Copy link
Contributor

@vstumpf vstumpf commented May 9, 2019

Describe Bug or Feature

A previous check-in #1089 introduced a bug where PTL would quote string values if it contained certain characters. This would fail with string arrays. It would also fail with tests that added quotes to the strings so qmgr could import it; it would double-quote some strings. This will cause tests that set Fairshare order to fail.

Describe Your Change

manager() will now also take lists of strings.
Design: https://pbspro.atlassian.net/wiki/spaces/PD/pages/1281458177/manager+should+use+python+lists+for+string+arrays

String Arrays
If any of the strings in the list have quotes or special characters, it will separately set each one, so qmgr does not get confused as to what is a string boundary and what is actually in the string.
Otherwise, it will join the string with commas and fall through to the strings case.

Strings
If the first and last character are both single or double quotes, don't add quotes.

Attach Test Logs or Output

after-fix-self.txt
after-fix8.txt
after-fix9.txt
after-fix10.txt

bhroam
bhroam previously approved these changes May 10, 2019
Copy link
Contributor

@bhroam bhroam left a comment

Choose a reason for hiding this comment

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

Looks good. I sign off.

@vstumpf vstumpf changed the title Fix manager() adding extra quotes [WIP] Fix manager() adding extra quotes May 10, 2019
@vstumpf
Copy link
Contributor Author

vstumpf commented May 10, 2019

I've made this WIP due to some tests failing. I think the best way to continue this fix is to change how string arrays are handled with PTL.

Expect a design doc soon.

@vstumpf vstumpf changed the title [WIP] Fix manager() adding extra quotes Fix manager() adding extra quotes May 14, 2019
@vstumpf
Copy link
Contributor Author

vstumpf commented May 14, 2019

I've opened this up for review again.
Please re-review. I've dismissed the previous reviews, as I've added new changes.
I also fixed a test (TestQmgr) that was added in the previous PR.

Copy link
Contributor

@nishiya nishiya left a comment

Choose a reason for hiding this comment

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

I like the idea. I think a few minor changes are needed.

self.server.create_import_hook("test", a, hook_body, overwrite=True)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you add this return? I don't think it should be here.

(' -c "p n %s comment"' % self.mom.hostname)
ret = self.du.run_cmd(self.server.hostname,
(' -c "p n %s comment"' % self.mom.shortname)
ret = self.du.run_cmd(self.server.shortname,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you changing this to self.server.shortname?

MGR_CMD_CREATE, RSC, attr, id=r, runas=ROOT_USER, logerr=False)
self.assertEqual(rc, 0)
self.server.manager(MGR_CMD_SET, SERVER,
{"resources_available.foo2": ["A'A", 'B"B', 'C C']}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a test for commas and newlines too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's weird, even though the code is there in pbs, it doesn't support new lines or commas in string array values.

attr['flag'] = 'h'
r = 'foo2'
rc = self.server.manager(
MGR_CMD_CREATE, RSC, attr, id=r, runas=ROOT_USER, logerr=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to run this as ROOT_USER. PTL makes the user who runs pbs_benchpress a manager. That is sufficient.

"""
attr = {}
attr['type'] = 'string_array'
attr['flag'] = 'h'
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why use 3 lines when this should all fit on one?

nodes = self.server.filter(SERVER,
{'resources_available.foo2':
"""A'A,B"B,C C"""})
self.logger.info(nodes)
Copy link
Contributor

Choose a reason for hiding this comment

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

You're querying the server, nodes is a poor variable name. Also, don't log a blanket variable. Either turn it into a full log message, or maybe assert instead.

Copy link
Contributor

@bhroam bhroam left a comment

Choose a reason for hiding this comment

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

Looks good. I sign off.

Copy link
Contributor

@nishiya nishiya left a comment

Choose a reason for hiding this comment

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

Look good

@latha-subramanian
Copy link
Contributor

latha-subramanian commented May 16, 2019

@vstumpf, Are the attached test results the latest ? Logs show failures(TestManager suite). Please attach the latest logs.

@vstumpf
Copy link
Contributor Author

vstumpf commented May 16, 2019

Sorry, that was an old version of the test. I ran the new test without resaving the output.
I've attached the new output.

@latha-subramanian
Copy link
Contributor

Sorry, that was an old version of the test. I ran the new test without resaving the output.
I've attached the new output.

Sorry, that was an old version of the test. I ran the new test without resaving the output.
I've attached the new output.

Thanks @vstumpf

@vstumpf
Copy link
Contributor Author

vstumpf commented May 17, 2019

I've rebased, please take this forward @bhroam

@bhroam bhroam merged commit bf67c62 into openpbs:master May 17, 2019
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.

None yet

4 participants