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

[BUG] The program crashes if the image name does not contain colon #918

Open
hoyhbx opened this issue Jun 16, 2022 · 0 comments · May be fixed by #922
Open

[BUG] The program crashes if the image name does not contain colon #918

hoyhbx opened this issue Jun 16, 2022 · 0 comments · May be fixed by #922

Comments

@hoyhbx
Copy link

hoyhbx commented Jun 16, 2022

What version of operator are you using?
commit 561cf47 (HEAD -> master)

What operating system and processor architecture are you using (kubectl version)?
Ubuntu. 20.04

kubectl version Output
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.0", GitCommit:"4ce5a8954017644c5420bae81d72b09b735c21f0", GitTreeState:"clean", BuildDate:"2022-05-03T13:46:05Z", GoVersion:"go1.18.1", Compiler:"gc", Platform:"darwin/amd64"}
Kustomize Version: v4.5.4
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.9", GitCommit:"6df4433e288edc9c40c2e344eb336f63fad45cd2", GitTreeState:"clean", BuildDate:"2022-05-19T19:53:08Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.24) and server (1.22) exceeds the supported minor version skew of +/-1

What did you do?

We found that crdb-operator will crash if we do not supply version for cockroachdb image. We supplied cockroachdb/cockroach for the spec.image field, and the operator crashes at this line

Reproduce

We first applied the operator yaml file and crd yaml file to deploy the operator.
Then we applied the following cr.yaml file to deploy the cockroachdb cluster:
by using kubectl apply -f cr.yaml -n cockroach-operator-system

cr.yaml:

apiVersion: crdb.cockroachlabs.com/v1alpha1
kind: CrdbCluster
metadata:
  name: test-cluster
spec:
  additionalLabels:
    crdb: is-cool
  dataStore:
    pvc:
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi
        volumeMode: Filesystem
  image:
    name: cockroachdb/cockroach
  nodes: 3
  resources:
    limits:
      cpu: 2
      memory: 2Gi
    requests:
      cpu: 100m
      memory: 1Gi
  tlsEnabled: true

What did you see?

The operator crashes.

Possible root cause
It seems that the cockroach operator has assumed that there will always be a colon in the image name, as this line suggests. There is no code preventing the program from crashing if an image name without a colon is provided. And if the image name does not have a colon, there will be an "index going out of range" error.

This is a bug, since crashing behavior is considered as bad behavior. There should be a sanity check to examine the validation of the image name, at least not let the program crash.

@hoyhbx hoyhbx changed the title The program crashes if the image name does not contain colon [BUG] The program crashes if the image name does not contain colon Jun 19, 2022
@hoyhbx hoyhbx linked a pull request Jun 22, 2022 that will close this issue
1 task
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 a pull request may close this issue.

1 participant