Skip to content

zk-setup init container uses "[[" which is not available in /bin/sh which is used to run the command in the init-container #798

@kunstkomputer

Description

@kunstkomputer

After Installing a Solr-Cloud using a self provided security.json and a Kubernetes Secret supplying the login information for k8s-oper and solr users for the basicAuth the zk-setup init-container completes prematurely. The logline printed before the init container exits is sh: 1: [[: not found
The zk-setup init container uses plain /bin/sh instead of /bin/bash as its container Entrypoint.

solr-operator chart version: v0.9.1
WARN  - 2025-09-11 12:10:58.779; org.apache.solr.common.cloud.SolrZkClient; Using default ZkCredentialsInjector. ZkCredentialsInjector is not secure, it creates an empty list of credentials which leads to 'OPEN_ACL_UNSAFE' ACLs to Zookeeper nodes
WARN  - 2025-09-11 12:10:58.985; org.apache.solr.common.cloud.SolrZkClient; Using default ZkACLProvider. DefaultZkACLProvider is not secure, it creates 'OPEN_ACL_UNSAFE' ACLs to Zookeeper nodes
configs
overseer
aliases.json
live_nodes
collections
overseer_elect
security.json
solr.xml
node_roles
sh: 1: [[: not found
stream closed EOF for sophora-stable/solr-solrcloud-0 (setup-zk)
  setup-zk:
    Container ID:  containerd://d3b47a032cdeb9e76833ce1bfaa1cfecdab60cd1c2998d32318640227f574aa1
    Image:         solr:9.2.1
    Image ID:      docker.io/library/solr@sha256:c7d2485fb31e5acdda15c4b22fb9765d233875afd1bca51422dfc6ab7049748d
    Port:          <none>
    Host Port:     <none>
    Command:
      sh
      -c
      solr zk ls ${ZK_CHROOT} -z ${ZK_SERVER} || solr zk mkroot ${ZK_CHROOT} -z ${ZK_SERVER};  solr zk cp zk:/security.json /tmp/current_security.json -z $ZK_HOST >/dev/null 2>&1;  GET_CURRENT_SECURITY_JSON_EXIT_CODE=$?; if [ ${GET_CURRENT_SECURITY_JSON_EXIT_CODE} -eq 0 ]; then if [[ ! -s /tmp/current_security.json ]] || grep -q '^{}$' /tmp/current_security.json ; then  echo $SECURITY_JSON > /tmp/security.json; solr zk cp /tmp/security.json zk:/security.json -z $ZK_HOST >/dev/null 2>&1;  echo 'Blank security.json found. Put new security.json in ZK'; fi; elif [ ${GET_CURRENT_SECURITY_JSON_EXIT_CODE} -eq 1 ]; then  echo $SECURITY_JSON > /tmp/security.json; solr zk cp /tmp/security.json zk:/security.json -z $ZK_HOST >/dev/null 2>&1;  echo 'No security.json found. Put new security.json in ZK'; fi
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Thu, 11 Sep 2025 14:10:55 +0200
      Finished:     Thu, 11 Sep 2025 14:11:02 +0200

I think the fix is trivial as while constructing the shell command simply another /bin/sh compatible shell command, like test or [ ] can be used instead of the /bin/bash `[[' version. I am happy to provide a PR if the bug itself is acknowledged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions