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

Side deck for plugins #30

Open
wants to merge 6 commits into
base: v1.x/staging
Choose a base branch
from

Conversation

fkovinAtRocket
Copy link
Contributor

  • side deck that a plugin can use to link with the functions in the server
  • script that I used to generate it
  • header file that has all the functions that are in the side deck

- side deck that a plugin can use to link with the functions in the server
- script that I used to generate it
- header file that has all the functions that are in the side deck

Signed-off-by: Fyodor Kovin <[email protected]>
@ghost ghost assigned fkovinAtRocket May 2, 2019
@jordanfilteau1995 jordanfilteau1995 self-requested a review May 2, 2019 17:24
Copy link
Contributor

@jordanfilteau1995 jordanfilteau1995 left a comment

Choose a reason for hiding this comment

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

The line endings in this file look strange. I know that the side file must have 80 character across. Is this going to cause an issue when it's checked out?

@fkovinAtRocket
Copy link
Contributor Author

fkovinAtRocket commented May 3, 2019

Jordan, the file is supposed to be 80 char fixed block, so it doesn't have line endings. Every line is exactly 80 characters, padded with spaces if needed.

The only problem would be if it's stored internally represented in ISO8859-1: it's unlikely that the compiler supports file tags and auto conversion. It looks like git check out stuff in 1047 by default though, so that should be alright.

@fkovinAtRocket
Copy link
Contributor Author

fkovinAtRocket commented May 3, 2019

What really concerns me though is that we're adding many functions whose name don't have prefixes, like: writeString(), writeHeader(), readByte(), indexOf(), etc. They might clash with other functions in the plugin code.

Some of them might be non-essential, but the functions in httpserver.c definitely must go there, and they all are unprefixed, with names like finishResponse(), writeBytes() writeRequest() etc. Note that it's absolutely required for a plugin to be able to read HTTP requests and send responses.

So I'm wondering if we should take the time and rename them to e.g. httpServerFinishResponse(), etc

@ifakhrutdinov ifakhrutdinov self-requested a review May 3, 2019 14:12
@ifakhrutdinov
Copy link
Contributor

ifakhrutdinov commented May 3, 2019

Would we want to include the recovery.c functions (recoveryPush, recoveryPop, etc)? The recovery context is created by ZSS, so it's better if we provide those functions as they may be incompatible with the context if linked statically.

@1000TurquoisePogs
Copy link
Member

How far do we go here? charsets.c and xml.c also look like someone may want to use them.

@fkovinAtRocket
Copy link
Contributor Author

fkovinAtRocket commented May 3, 2019

As I though of this, the criteria is not so much whether someone wants to use it or not. The code is always there and they can link statically. Each new file added to this side deck is a potential pain for us, since everything that has once been added there becomes an API and thus a maintenance burden for us. Since this PR is approved, we won't be able to easily rename a function from http.c, for example, because someone's plugin will break and fail to load because a symbol will not be found.

Rather, the criteria was: include everything that's required for communication between ZSS and the plugin. Nothing good will happen if ZSS passes a plugin a HTTPRequest that was made by an incompatibly changed constructor function, and the plugin has statically linked an older version. HTTP, dataserivce, json, logging, recovery, even utils because of StringList are all shared between ZSS and plugins.

Copy link
Member

@1000TurquoisePogs 1000TurquoisePogs left a comment

Choose a reason for hiding this comment

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

This approach to side file generation should not be done for two reasons

  1. It includes several internal functions that shouldn't be called at least due to them having no good meaning or purpose to plugins
  2. It generates a nearly unreadable file that breaks our rule for 120 character line length limit. side file specification does not say that you cannot have a newline on the last byte of the 80 column line.

A good start would be a hand-crafted file including only useful functions, or, having a file generated by including only functions that are marked by some means as being valid for inclusion. It is easier to add on request as needed than to remove when people wrongly depended on what should have been an internal function that we didn't sufficiently protect in the first place.

Now is also not the right time to be attempting to rename internal functions to work-around the automated pitfalls. That could be significant effort and could cause significant problems for direct extenders of zowe-common-c.

@fkovinAtRocket
Copy link
Contributor Author

fkovinAtRocket commented May 3, 2019

  1. Please define "useful function". This was my first question and it turned out that nobody knew what exactly it was. It looks like alloc.c might be safely removed, and we don't need all of the stuff in utils.c, but I would argue that logging, recovery and http/dataservice stuff need to be included in full, since they are functions that work with data/state shared by ZSS and plugins.
  2. I'm not sure how collision-prone names are "automated pitfalls". They're pretty manual pitfalls instead: C doesn't have any namespaces, and any global function/variable name should be reasonably unique. If we're forcing every plugin to link with a symbol called "finishResponse" then chances are moderately high that they might also have a function with that name but a different meaning/arguments/return value: it's just a pretty common name for a function. If it were called "httpServerFinishResponse()" or "zoweHttpFinishResponse()", then, OTOH, chances would be much lower.
    And this particular function finishResponse meets the definition of a "useful function" at least empirically: it can be observed that most plugins, and, generally HTTP endpoints, use it, to, well, finish an HTTP response. And it's also a function that works with data shared by ZSS and plugins, so it has to be part of the side file.
  3. A side file is not a human readable file anyway, so I thought line breaks shouldn't matter. It's a coincidence, I think, that it's not binary in XL C, but it easily could've been. It looks like they followed the path of least resistance and made it a piece of binder control statements. Now, if we need line breaks in a non-human readable file for some reason, that's doable, of course.

@1000TurquoisePogs
Copy link
Member

Side files are human-readable files when written to only include functions that plugins should be able to use, and exclude those they shouldn't rely on. They then serve as a form of documentation. What's a "useful" function will change over time, so we should start with a short list and only extend it when requested and the request has merit.

@1000TurquoisePogs
Copy link
Member

Example of something that shouldn't be in the side file but is in this PR: dequeueHttpRequest

Signed-off-by: Fyodor Kovin <[email protected]>
@fkovinAtRocket fkovinAtRocket force-pushed the feature/zss-side-deck branch 2 times, most recently from 686c21f to d90953b Compare May 6, 2019 17:05
Signed-off-by: Fyodor Kovin <[email protected]>
@fkovinAtRocket fkovinAtRocket force-pushed the feature/zss-side-deck branch from 6316f0c to 4f5cd0e Compare May 6, 2019 17:17
@fkovinAtRocket
Copy link
Contributor Author

It turns out that we actually need xml.c because there's a global function in httpserver that creates an XML object.

Copy link
Member

@1000TurquoisePogs 1000TurquoisePogs left a comment

Choose a reason for hiding this comment

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

I think this approach can work, but there's more to blacklist.

lib/zss.x Outdated
IMPORT CODE,'zssServer','setConfiguredProperty'
IMPORT CODE,'zssServer','setContentType'
IMPORT CODE,'zssServer','setDefaultJSONRESTHeaders'
IMPORT CODE,'zssServer','setHttpAuthTrace'
Copy link
Member

Choose a reason for hiding this comment

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

I'd blacklist all the tracers... doesn't seem like something that plugins should be touching.

lib/zss.x Outdated
IMPORT CODE,'zssServer','printStderr'
IMPORT CODE,'zssServer','printStdout'
IMPORT CODE,'zssServer','printXMLToken'
IMPORT CODE,'zssServer','processHttpFragment'
Copy link
Member

Choose a reason for hiding this comment

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

This seems too internal

lib/zss.x Outdated
IMPORT CODE,'zssServer','logGetLevel'
IMPORT CODE,'zssServer','logSetLevel'
IMPORT CODE,'zssServer','logShouldTraceInternal'
IMPORT CODE,'zssServer','mainHttpLoop'
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't be used by a plugin.

sakeerthy pushed a commit to sakeerthy/zss that referenced this pull request May 11, 2020
…fication-of-addresses

Adding ipAddresses field for zlux and agent(zss) for specifying binding to specific IPs
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