1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

k8sのcronjobなどのyamlでexpected alphabetic or numeric character, but found ' 'が発生する時

Posted at

結論から言うと、cronの指定はダブルクォートで囲んで、文字列だと明記しましょう。

NG

spec:
  schedule: */5 * * * *

OK

spec:
  schedule: "*/5 * * * *"

ただ、これはOKなので紛らわしい

spec:
  schedule: 0 * * * *

何が起きているか

*から始まる値はエイリアスとみなされるので、

* * * * *

" * * * *"

という名前のエイリアスだとみなされます。しかしエイリアスは空白文字を許さないので、表題の"expected alphabetic or numeric character, but found ' '"となってしまいます。

どうして気づかなかったか

yamlを直接書いてればIDEがエラー吐いてくれるので気づくんですが、

spec:
  schedule: ${SCHEDULE}

という感じでこのcron行は外部から注入できるようにしてデプロイしてたので気づきませんでした。

gitlabでも同様なバグが有ったらしい https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/2284

エイリアスに使えない文字について

実は実装依存のよう。libyamlでは.や/も使えるようだけど(https://github.com/yaml/libyaml/pull/170/files) pyyamlでは使えない。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?