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

namespaced package causes deploy failure #211

Closed
evanshortiss opened this issue Apr 6, 2018 · 0 comments
Closed

namespaced package causes deploy failure #211

evanshortiss opened this issue Apr 6, 2018 · 0 comments

Comments

@evanshortiss
Copy link
Contributor

Interesting issue I just ran into. I created a new project by running npm init. Since I'm logged into npm the resulting package.json looks like so (note the name field):

{
  "name": "@evanshortiss/node-app",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "nodeshift": "nodeshift",
    "start": "node index.js"
  },
  "author": "Evan Shortiss <evanshortiss@gmail.com>",
  "license": "MIT",
  "dependencies": {
    "env-var": "~3.2.0",
    "fastify": "~1.2.1"
  },
  "devDependencies": {
    "nodeshift": "~1.6.0"
  }
}

Attempting a deployment with this results in a failure like so:

2018-04-06T18:17:00.497Z INFO loading configuration
2018-04-06T18:17:00.523Z INFO using namespace myproject at https://127.0.0.1:8443
2018-04-06T18:17:00.530Z WARNING a file property was not found in your package.json, archiving the current directory.
2018-04-06T18:17:00.531Z INFO creating archive of .editorconfig, index.js, package-lock.json, package.json
2018-04-06T18:17:00.666Z ERROR User "developer" cannot get buildconfigs/node-app-s2i in the namespace "myproject": User "developer" cannot get buildconfigs/node-app-s2i in project "myproject"
2018-04-06T18:17:00.666Z ERROR Status code 403

Removing the @evanshortiss/ from package.name resolves the issue.

Interestingly, when I was first investigating the issue I thought it was related to permissions so I ran oc adm policy add-cluster-role-to-user cluster-admin developer and then retried, which resulted in a different error that gave me my clue to fix the issue:

2018-04-06T18:21:52.686Z INFO loading configuration
2018-04-06T18:21:52.713Z INFO using namespace myproject at https://127.0.0.1:8443
2018-04-06T18:21:52.720Z WARNING a file property was not found in your package.json, archiving the current directory.
2018-04-06T18:21:52.720Z INFO creating archive of .editorconfig, index.js, package-lock.json, package.json
2018-04-06T18:21:52.832Z INFO creating build configuration @evanshortiss/node-app-s2i
2018-04-06T18:21:52.832Z INFO Using s2i image bucharestgold/centos7-s2i-nodejs with tag latest
2018-04-06T18:21:52.916Z ERROR {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"BuildConfig \"@evanshortiss/node-app-s2i\" is invalid: [metadata.name: Invalid value: \"@evanshortiss/node-app-s2i\": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'), metadata.labels: Invalid value: \"@evanshortiss/node-app\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?'), spec.output.to.name: Invalid value: \"@evanshortiss/node-app\": ImageStreamTag name contains invalid syntax]","reason":"Invalid","details":{"name":"@evanshortiss/node-app-s2i","kind":"BuildConfig","causes":[{"reason":"FieldValueInvalid","message":"Invalid value: \"@evanshortiss/node-app-s2i\": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')","field":"metadata.name"},{"reason":"FieldValueInvalid","message":"Invalid value: \"@evanshortiss/node-app\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')","field":"metadata.labels"},{"reason":"FieldValueInvalid","message":"Invalid value: \"@evanshortiss/node-app\": ImageStreamTag name contains invalid syntax","field":"spec.output.to.name"}]},"code":422}
2018-04-06T18:21:52.916Z ERROR Status code 422

Sounds like nodeshift should add a check for package.name for alphanumeric only, and also hyphens?

Here's some version info that might be helpful too. I'd be happy to look into a PR since I found this while experimenting for a hackathon 😄

➜ node-app node:(v8.9.3) node -v
v8.9.3

➜ node-app node:(v8.9.3) npm -v
5.5.1

➜ node-app node:(v8.9.3) oc version
oc v3.7.1+ab0f056
kubernetes v1.7.6+a08f5eeb62
features: Basic-Auth

Server https://127.0.0.1:8443
openshift v3.7.1+ab0f056
kubernetes v1.7.6+a08f5eeb62
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

No branches or pull requests

1 participant