From 121c2987e30e11513a6005edcce665a39ff2b3db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 23 Sep 2021 15:28:46 +0200 Subject: [PATCH] ceph: stop using tini MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need to use tini. We don't have anything in the rook operator that would either create zombie processes (no threads) or use exec (to fork). The Go binary has a really good signal handling mechanism. Closes: https://github.com/rook/rook/issues/8794 Signed-off-by: Sébastien Han --- PendingReleaseNotes.md | 3 ++ .../templates/deployment.yaml | 5 +- cluster/examples/kubernetes/ceph/toolbox.yaml | 5 +- cmd/rook/util/cmdreporter.go | 10 +++- cmd/rook/util/copybins.go | 16 +++--- images/ceph/Dockerfile | 8 +-- pkg/daemon/util/cmdreporter.go | 11 ++-- pkg/daemon/util/cmdreporter_test.go | 10 ++-- pkg/daemon/util/copybins.go | 8 +-- pkg/daemon/util/copybins_test.go | 54 ++----------------- pkg/operator/ceph/cluster/mon/mon.go | 4 +- .../ceph/cluster/osd/integration_test.go | 4 +- .../ceph/cluster/osd/provision_spec.go | 4 +- pkg/operator/ceph/cluster/osd/spec.go | 16 +++--- pkg/operator/ceph/cluster/osd/spec_test.go | 10 ++-- pkg/operator/ceph/operator.go | 6 +-- .../k8sutil/cmdreporter/cmdreporter.go | 12 ++--- pkg/operator/k8sutil/volume.go | 2 +- 18 files changed, 70 insertions(+), 118 deletions(-) diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index 5f2f97cc2..d8c7ea965 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -14,3 +14,6 @@ v1.8... to update to a newer version before updating to Rook v1.8. ## Features + +- The Rook Operator does not use "tini" as an init process. Instead, it uses the "rook" and handles + signals on its own. diff --git a/cluster/charts/rook-ceph-cluster/templates/deployment.yaml b/cluster/charts/rook-ceph-cluster/templates/deployment.yaml index 7e99948b2..6336b1e38 100644 --- a/cluster/charts/rook-ceph-cluster/templates/deployment.yaml +++ b/cluster/charts/rook-ceph-cluster/templates/deployment.yaml @@ -24,9 +24,10 @@ spec: containers: - name: rook-ceph-tools image: {{ .Values.toolbox.image }} - command: ["/tini"] - args: ["-g", "--", "/usr/local/bin/toolbox.sh"] + command: ["/bin/bash"] + args: ["-m", "-c", "/usr/local/bin/toolbox.sh"] imagePullPolicy: IfNotPresent + tty: true env: - name: ROOK_CEPH_USERNAME valueFrom: diff --git a/cluster/examples/kubernetes/ceph/toolbox.yaml b/cluster/examples/kubernetes/ceph/toolbox.yaml index 28edc958b..eef078310 100644 --- a/cluster/examples/kubernetes/ceph/toolbox.yaml +++ b/cluster/examples/kubernetes/ceph/toolbox.yaml @@ -19,9 +19,10 @@ spec: containers: - name: rook-ceph-tools image: rook/ceph:master - command: ["/tini"] - args: ["-g", "--", "/usr/local/bin/toolbox.sh"] + command: ["/bin/bash"] + args: ["-m", "-c", "/usr/local/bin/toolbox.sh"] imagePullPolicy: IfNotPresent + tty: true env: - name: ROOK_CEPH_USERNAME valueFrom: diff --git a/cmd/rook/util/cmdreporter.go b/cmd/rook/util/cmdreporter.go index 9137b9f56..1ae7af3fd 100644 --- a/cmd/rook/util/cmdreporter.go +++ b/cmd/rook/util/cmdreporter.go @@ -17,8 +17,12 @@ limitations under the License. package util import ( + "context" "fmt" + "os/signal" + "github.com/rook/rook/pkg/daemon/util" + operator "github.com/rook/rook/pkg/operator/ceph" "github.com/rook/rook/cmd/rook/rook" "github.com/spf13/cobra" @@ -77,13 +81,17 @@ func init() { } func runCmdReporter(cCmd *cobra.Command, cArgs []string) { + // Initialize the context + ctx, cancel := signal.NotifyContext(context.Background(), operator.ShutdownSignals...) + defer cancel() + cmd, args, err := util.CmdReporterFlagArgumentToCommand(commandString) if err != nil { rook.TerminateFatal(fmt.Errorf("failed to parse '--command' argument [%s]. %+v", commandString, err)) } context := rook.NewContext() - reporter, err := util.NewCmdReporter(context.Clientset, cmd, args, configMapName, namespace) + reporter, err := util.NewCmdReporter(ctx, context.Clientset, cmd, args, configMapName, namespace) if err != nil { rook.TerminateFatal(fmt.Errorf("cannot start command-reporter. %+v", err)) } diff --git a/cmd/rook/util/copybins.go b/cmd/rook/util/copybins.go index 187b33c92..19707bf52 100644 --- a/cmd/rook/util/copybins.go +++ b/cmd/rook/util/copybins.go @@ -24,19 +24,19 @@ import ( "github.com/spf13/cobra" ) -// CopyBinsCmd defines a top-level utility command which copies rook and tini binaries from the Rook +// CopyBinsCmd defines a top-level utility command which copies rook binary from the Rook // container image to a directory. var CopyBinsCmd = &cobra.Command{ Use: "copy-binaries", - Short: "Copy 'rook' and 'tini' binaries from a container to a given directory.", - Long: `Copy 'rook' and 'tini' binaries from a container to a given directory. + Short: "Copy 'rook' binary from a container to a given directory.", + Long: `Copy 'rook' binary from a container to a given directory. As an example, 'cmd-reporter run' may often need to be run from a container other than the container containing the 'rook' binary. Use this command to copy -the 'rook' and required 'tini' binaries from the container containing the 'rook' +the 'rook' binary from the container containing the 'rook' binary to a Kubernetes EmptyDir volume mounted at the given directory in a pod's init container. From the pod's main container, mount the volume which now -contains the 'rook' and 'tini' binaries, and call 'rook cmd-reporter run' from -'tini' in order to run the desired command from a non-Rook container.`, +contains the 'rook' binary, and call 'rook cmd-reporter run' from +'rook' in order to run the desired command from a non-Rook container.`, Args: cobra.NoArgs, RunE: runCopyBins, } @@ -44,7 +44,7 @@ contains the 'rook' and 'tini' binaries, and call 'rook cmd-reporter run' from func init() { // copy-binaries CopyBinsCmd.Flags().StringVar(©ToDir, "copy-to-dir", "", - "The directory into which 'tini' and 'rook' binaries will be copied.") + "The directory into which 'rook' binary will be copied.") if err := CopyBinsCmd.MarkFlagRequired("copy-to-dir"); err != nil { panic(err) } @@ -52,7 +52,7 @@ func init() { func runCopyBins(cCmd *cobra.Command, cArgs []string) error { if err := util.CopyBinaries(copyToDir); err != nil { - rook.TerminateFatal(fmt.Errorf("could not copy binaries to %s. %+v", copyToDir, err)) + rook.TerminateFatal(fmt.Errorf("could not copy binary to %s. %+v", copyToDir, err)) } return nil } diff --git a/images/ceph/Dockerfile b/images/ceph/Dockerfile index 56b1e731c..f0bcec38a 100644 --- a/images/ceph/Dockerfile +++ b/images/ceph/Dockerfile @@ -16,15 +16,9 @@ FROM BASEIMAGE ARG ARCH -ARG TINI_VERSION - -# Run tini as PID 1 and avoid signal handling issues -RUN curl --fail -sSL -o /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${ARCH} && \ - chmod +x /tini - COPY rook toolbox.sh set-ceph-debug-level /usr/local/bin/ COPY ceph-monitoring /etc/ceph-monitoring COPY rook-external /etc/rook-external/ COPY ceph-csv-templates /etc/ceph-csv-templates -ENTRYPOINT ["/tini", "--", "/usr/local/bin/rook"] +ENTRYPOINT ["/usr/local/bin/rook"] CMD [""] diff --git a/pkg/daemon/util/cmdreporter.go b/pkg/daemon/util/cmdreporter.go index 0ce0d50c7..f1cc77624 100644 --- a/pkg/daemon/util/cmdreporter.go +++ b/pkg/daemon/util/cmdreporter.go @@ -61,10 +61,11 @@ type CmdReporter struct { args []string configMapName string namespace string + context context.Context } // NewCmdReporter creates a new CmdReporter and returns an error if cmd, configMapName, or Namespace aren't specified. -func NewCmdReporter(clientset kubernetes.Interface, cmd, args []string, configMapName, namespace string) (*CmdReporter, error) { +func NewCmdReporter(context context.Context, clientset kubernetes.Interface, cmd, args []string, configMapName, namespace string) (*CmdReporter, error) { if clientset == nil { return nil, fmt.Errorf("Kubernetes client interface was not specified") } @@ -83,6 +84,7 @@ func NewCmdReporter(clientset kubernetes.Interface, cmd, args []string, configMa args: args, configMapName: configMapName, namespace: namespace, + context: context, }, nil } @@ -189,10 +191,9 @@ func (r *CmdReporter) runCommand() (stdout, stderr string, retcode int, err erro func (r *CmdReporter) saveToConfigMap(stdout, stderr string, retcode int) error { retcodeStr := fmt.Sprintf("%d", retcode) - ctx := context.TODO() k8s := r.clientset - cm, err := k8s.CoreV1().ConfigMaps(r.namespace).Get(ctx, r.configMapName, metav1.GetOptions{}) + cm, err := k8s.CoreV1().ConfigMaps(r.namespace).Get(r.context, r.configMapName, metav1.GetOptions{}) if err != nil { if !errors.IsNotFound(err) { return fmt.Errorf("failed to determine if ConfigMap %s is preexisting. %+v", r.configMapName, err) @@ -214,7 +215,7 @@ func (r *CmdReporter) saveToConfigMap(stdout, stderr string, retcode int) error }, } - if _, err := k8s.CoreV1().ConfigMaps(r.namespace).Create(ctx, cm, metav1.CreateOptions{}); err != nil { + if _, err := k8s.CoreV1().ConfigMaps(r.namespace).Create(r.context, cm, metav1.CreateOptions{}); err != nil { return fmt.Errorf("failed to create ConfigMap %s. %+v", r.configMapName, err) } return nil @@ -243,7 +244,7 @@ func (r *CmdReporter) saveToConfigMap(stdout, stderr string, retcode int) error cm.Data[CmdReporterConfigMapStderrKey] = stderr cm.Data[CmdReporterConfigMapRetcodeKey] = retcodeStr - if _, err := k8s.CoreV1().ConfigMaps(r.namespace).Update(ctx, cm, metav1.UpdateOptions{}); err != nil { + if _, err := k8s.CoreV1().ConfigMaps(r.namespace).Update(r.context, cm, metav1.UpdateOptions{}); err != nil { return fmt.Errorf("failed to update ConfigMap %s. %+v", r.configMapName, err) } diff --git a/pkg/daemon/util/cmdreporter_test.go b/pkg/daemon/util/cmdreporter_test.go index da1980364..9e1557ba1 100644 --- a/pkg/daemon/util/cmdreporter_test.go +++ b/pkg/daemon/util/cmdreporter_test.go @@ -74,6 +74,7 @@ func TestCommandMarshallingUnmarshalling(t *testing.T) { } func TestNew(t *testing.T) { + ctx := context.TODO() client := fake.NewSimpleClientset type fields struct { clientset kubernetes.Interface @@ -101,6 +102,7 @@ func TestNew(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { r, err := NewCmdReporter( + ctx, tt.fields.clientset, tt.fields.cmd, tt.fields.args, @@ -145,7 +147,7 @@ func TestRunner_Run(t *testing.T) { defer func() { os.Unsetenv("GO_HELPER_PROCESS_PRINT_COMMAND") }() k8s := newClient() - r, err := NewCmdReporter(k8s, cmd, args, "command-configmap", "command-namespace") + r, err := NewCmdReporter(ctx, k8s, cmd, args, "command-configmap", "command-namespace") assert.NoError(t, err) assert.NoError(t, r.Run()) @@ -168,7 +170,7 @@ func TestRunner_Run(t *testing.T) { defer func() { os.Unsetenv("GO_HELPER_PROCESS_RETCODE") }() k8s := newClient() - r, err := NewCmdReporter(k8s, []string{"standin-cmd"}, []string{"--some", "arg"}, "outputs-configmap", "outputs-namespace") + r, err := NewCmdReporter(ctx, k8s, []string{"standin-cmd"}, []string{"--some", "arg"}, "outputs-configmap", "outputs-namespace") assert.NoError(t, err) assert.NoError(t, r.Run()) @@ -195,7 +197,7 @@ func TestRunner_Run(t *testing.T) { } _, err := k8s.CoreV1().ConfigMaps("preexisting-namespace").Create(ctx, cm, metav1.CreateOptions{}) assert.NoError(t, err) - r, err := NewCmdReporter(k8s, []string{"some-command"}, []string{"some", "args"}, "preexisting-configmap", "preexisting-namespace") + r, err := NewCmdReporter(ctx, k8s, []string{"some-command"}, []string{"some", "args"}, "preexisting-configmap", "preexisting-namespace") assert.NoError(t, err) assert.Error(t, r.Run()) cm, err = k8s.CoreV1().ConfigMaps("preexisting-namespace").Get(ctx, "preexisting-configmap", metav1.GetOptions{}) @@ -218,7 +220,7 @@ func TestRunner_Run(t *testing.T) { } _, err = k8s.CoreV1().ConfigMaps("preexisting-namespace").Create(ctx, cm, metav1.CreateOptions{}) assert.NoError(t, err) - r, err = NewCmdReporter(k8s, []string{"some-command"}, []string{"some", "args"}, "preexisting-configmap", "preexisting-namespace") + r, err = NewCmdReporter(ctx, k8s, []string{"some-command"}, []string{"some", "args"}, "preexisting-configmap", "preexisting-namespace") assert.NoError(t, err) assert.NoError(t, r.Run()) verifyConfigMap(k8s, "", "", "0", "preexisting-configmap", "preexisting-namespace") diff --git a/pkg/daemon/util/copybins.go b/pkg/daemon/util/copybins.go index a4d15f70b..ed5faf05c 100644 --- a/pkg/daemon/util/copybins.go +++ b/pkg/daemon/util/copybins.go @@ -26,14 +26,10 @@ import ( // override these for unit testing var defaultRookDir = "/usr/local/bin" -var defaultTiniDir = "/" -// CopyBinaries copies the "tini" and "rook" binaries to a shared volume at the target path. +// CopyBinaries copies the "rook" binary to a shared volume at the target path. func CopyBinaries(target string) error { - if err := copyBinary(defaultRookDir, target, "rook"); err != nil { - return err - } - return copyBinary(defaultTiniDir, target, "tini") + return copyBinary(defaultRookDir, target, "rook") } // #nosec G307 Calling defer to close the file without checking the error return is not a risk for a simple file open and close diff --git a/pkg/daemon/util/copybins_test.go b/pkg/daemon/util/copybins_test.go index d7b2e83ad..ca85855ee 100644 --- a/pkg/daemon/util/copybins_test.go +++ b/pkg/daemon/util/copybins_test.go @@ -25,8 +25,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestCopyBinaries(t *testing.T) { - +func TestCopyBinary(t *testing.T) { createTestBinary := func(binPath string) { f, err := os.Create(binPath) assert.NoError(t, err) @@ -76,79 +75,34 @@ func TestCopyBinaries(t *testing.T) { oDefaultRookDir := defaultRookDir defaultRookDir = path.Join(testRootDir, "/usr/local/bin") defer func() { defaultRookDir = oDefaultRookDir }() - // set default tini dir for unit tests - oDefaultTiniDir := defaultTiniDir - defaultTiniDir = path.Join(testRootDir, "/") - defer func() { defaultTiniDir = oDefaultTiniDir }() - // expect failure if rook binary is available in path but not tini + // expect success if binary is available in path // testRootDir/ // bin/ // rook // copy-to-dir/ createTestBinary(path.Join(envPath, "rook")) - - err = CopyBinaries(copyToDir) - assert.Error(t, err) - if err == nil { - panic(err) - } - - err = os.Remove(path.Join(envPath, "rook")) - assert.NoError(t, err) - - // expect failure if tini binary is available in path but not rook - // testRootDir/ - // bin/ - // tini - // copy-to-dir/ - createTestBinary(path.Join(envPath, "tini")) - - err = CopyBinaries(copyToDir) - assert.Error(t, err) - if err == nil { - panic(err) - } - - err = os.Remove(path.Join(envPath, "tini")) - assert.NoError(t, err) - - // expect success if both binaries are available in path - // testRootDir/ - // bin/ - // rook - // tini - // copy-to-dir/ - createTestBinary(path.Join(envPath, "rook")) - createTestBinary(path.Join(envPath, "tini")) cleanDir(copyToDir) err = CopyBinaries(copyToDir) assert.NoError(t, err) r := fileText(path.Join(copyToDir, "rook")) assert.Contains(t, r, path.Join(testRootDir, "bin/rook")) - r = fileText(path.Join(copyToDir, "tini")) - assert.Contains(t, r, path.Join(testRootDir, "bin/tini")) - // expect success if both binaries are available in default locations AND in path - // additionally expect that the binaries will be taken from the default location in this case + // expect success if the binary is available in default locations AND in path + // additionally expect that the binary will be taken from the default location in this case // testRootDir/ - // tini // usr/local/bin/ // rook // bin/ // rook - // tini // copy-to-dir/ mkdir(defaultRookDir) createTestBinary(path.Join(defaultRookDir, "rook")) - createTestBinary(path.Join(defaultTiniDir, "tini")) cleanDir(copyToDir) err = CopyBinaries(copyToDir) assert.NoError(t, err) r = fileText(path.Join(copyToDir, "rook")) assert.Contains(t, r, path.Join(testRootDir, "usr/local/bin/rook")) - r = fileText(path.Join(copyToDir, "tini")) - assert.Contains(t, r, path.Join(testRootDir, "tini")) } diff --git a/pkg/operator/ceph/cluster/mon/mon.go b/pkg/operator/ceph/cluster/mon/mon.go index 52ff53ae9..77ed2d510 100644 --- a/pkg/operator/ceph/cluster/mon/mon.go +++ b/pkg/operator/ceph/cluster/mon/mon.go @@ -608,8 +608,8 @@ func scheduleMonitor(c *Cluster, mon *monConfig) (*apps.Deployment, error) { // to modify the storage by instead running an innocuous command. d.Spec.Template.Spec.InitContainers = []v1.Container{} d.Spec.Template.Spec.Containers[0].Image = c.rookVersion - d.Spec.Template.Spec.Containers[0].Command = []string{"/tini"} - d.Spec.Template.Spec.Containers[0].Args = []string{"--", "sleep", "3600"} + d.Spec.Template.Spec.Containers[0].Command = []string{"sleep"} // sleep responds to signals so we don't need to wrap it + d.Spec.Template.Spec.Containers[0].Args = []string{"3600"} // remove the liveness probe on the canary pod d.Spec.Template.Spec.Containers[0].LivenessProbe = nil diff --git a/pkg/operator/ceph/cluster/osd/integration_test.go b/pkg/operator/ceph/cluster/osd/integration_test.go index 345522366..0b0d2491c 100644 --- a/pkg/operator/ceph/cluster/osd/integration_test.go +++ b/pkg/operator/ceph/cluster/osd/integration_test.go @@ -552,7 +552,7 @@ func osdIntegrationTestExecutor(t *testing.T, clientset *fake.Clientset, namespa // ceph osd ls returns an array of osd IDs like [0,1,2] // build this based on the number of deployments since they should be equal // for this test - l, err := clientset.AppsV1().Deployments(namespace).List(context.TODO(), metav1.ListOptions{}) + l, err := clientset.AppsV1().Deployments(namespace).List(contextStandard.TODO(), metav1.ListOptions{}) if err != nil { panic(fmt.Sprintf("failed to build 'ceph osd ls' output. %v", err)) } @@ -620,7 +620,7 @@ func newDummyStorageClassDeviceSet( func waitForNumConfigMaps(clientset kubernetes.Interface, namespace string, count int) []corev1.ConfigMap { for { - cms, err := clientset.CoreV1().ConfigMaps(namespace).List(context.TODO(), metav1.ListOptions{}) + cms, err := clientset.CoreV1().ConfigMaps(namespace).List(contextStandard.TODO(), metav1.ListOptions{}) if err != nil { panic(err) } diff --git a/pkg/operator/ceph/cluster/osd/provision_spec.go b/pkg/operator/ceph/cluster/osd/provision_spec.go index 396c1adfb..51434d9f7 100644 --- a/pkg/operator/ceph/cluster/osd/provision_spec.go +++ b/pkg/operator/ceph/cluster/osd/provision_spec.go @@ -299,8 +299,8 @@ func (c *Cluster) provisionOSDContainer(osdProps osdProperties, copyBinariesMoun readOnlyRootFilesystem := false osdProvisionContainer := v1.Container{ - Command: []string{path.Join(rookBinariesMountPath, "tini")}, - Args: []string{"--", path.Join(rookBinariesMountPath, "rook"), "ceph", "osd", "provision"}, + Command: []string{path.Join(rookBinariesMountPath, "rook")}, + Args: []string{"ceph", "osd", "provision"}, Name: "provision", Image: c.spec.CephVersion.Image, VolumeMounts: volumeMounts, diff --git a/pkg/operator/ceph/cluster/osd/spec.go b/pkg/operator/ceph/cluster/osd/spec.go index 161f6729f..604d1f765 100644 --- a/pkg/operator/ceph/cluster/osd/spec.go +++ b/pkg/operator/ceph/cluster/osd/spec.go @@ -347,7 +347,7 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC volumes := controller.PodVolumes(provisionConfig.DataPathMap, dataDirHostPath, false) failureDomainValue := osdProps.crushHostname doConfigInit := true // initialize ceph.conf in init container? - doBinaryCopyInit := true // copy tini and rook binaries in an init container? + doBinaryCopyInit := true // copy rook binary in an init container? // This property is used for both PVC and non-PVC use case if osd.CVMode == "" { @@ -387,10 +387,7 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC } osdID := strconv.Itoa(osd.ID) - tiniEnvVar := v1.EnvVar{Name: "TINI_SUBREAPER", Value: ""} - envVars := append(c.getConfigEnvVars(osdProps, dataDir), []v1.EnvVar{ - tiniEnvVar, - }...) + envVars := c.getConfigEnvVars(osdProps, dataDir) envVars = append(envVars, k8sutil.ClusterDaemonEnvVars(c.spec.CephVersion.Image)...) envVars = append(envVars, []v1.EnvVar{ {Name: "ROOK_OSD_UUID", Value: osd.UUID}, @@ -406,7 +403,6 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC dataDeviceClassEnvVar(osd.DeviceClass), }...) configEnvVars := append(c.getConfigEnvVars(osdProps, dataDir), []v1.EnvVar{ - tiniEnvVar, {Name: "ROOK_OSD_ID", Value: osdID}, {Name: "ROOK_CEPH_VERSION", Value: c.clusterInfo.CephVersion.CephVersionFormatted()}, {Name: "ROOK_IS_DEVICE", Value: "true"}, @@ -418,9 +414,9 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC // If the OSD was prepared with ceph-volume and running on PVC and using the LVM mode if osdProps.onPVC() && osd.CVMode == "lvm" { // if the osd was provisioned by ceph-volume, we need to launch it with rook as the parent process - command = []string{path.Join(rookBinariesMountPath, "tini")} + command = []string{path.Join(rookBinariesMountPath, "rook")} args = []string{ - "--", path.Join(rookBinariesMountPath, "rook"), + path.Join(rookBinariesMountPath, "rook"), "ceph", "osd", "start", "--", "--foreground", @@ -774,8 +770,8 @@ func applyTopologyAffinity(spec *v1.PodSpec, osd OSDInfo) error { return nil } -// To get rook inside the container, the config init container needs to copy "tini" and "rook" binaries into a volume. -// Get the config flag so rook will copy the binaries and create the volume and mount that will be shared between +// To get rook inside the container, the config init container needs to copy "rook" binary into a volume. +// Get the config flag so rook will copy the binary and create the volume and mount that will be shared between // the init container and the daemon container func (c *Cluster) getCopyBinariesContainer() (v1.Volume, *v1.Container) { volume := v1.Volume{Name: rookBinariesVolumeName, VolumeSource: v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}} diff --git a/pkg/operator/ceph/cluster/osd/spec_test.go b/pkg/operator/ceph/cluster/osd/spec_test.go index 34f585a41..e19cd63ea 100644 --- a/pkg/operator/ceph/cluster/osd/spec_test.go +++ b/pkg/operator/ceph/cluster/osd/spec_test.go @@ -60,12 +60,10 @@ func TestPodContainer(t *testing.T) { logger.Infof("container: %+v", container) assert.Equal(t, "copy-binaries", container.Args[0]) container = c.Spec.Containers[0] - assert.Equal(t, "/rook/tini", container.Command[0]) - assert.Equal(t, "--", container.Args[0]) - assert.Equal(t, "/rook/rook", container.Args[1]) - assert.Equal(t, "ceph", container.Args[2]) - assert.Equal(t, "osd", container.Args[3]) - assert.Equal(t, "provision", container.Args[4]) + assert.Equal(t, "/rook/rook", container.Command[0]) + assert.Equal(t, "ceph", container.Args[0]) + assert.Equal(t, "osd", container.Args[1]) + assert.Equal(t, "provision", container.Args[2]) for _, c := range c.Spec.Containers { vars := operatortest.FindDuplicateEnvVars(c) diff --git a/pkg/operator/ceph/operator.go b/pkg/operator/ceph/operator.go index 61cf4b736..410cdc526 100644 --- a/pkg/operator/ceph/operator.go +++ b/pkg/operator/ceph/operator.go @@ -41,9 +41,9 @@ var ( // ImmediateRetryResult Return this for a immediate retry of the reconciliation loop with the same request object. ImmediateRetryResult = reconcile.Result{Requeue: true} - // Signals to watch for to terminate the operator gracefully + // ShutdownSignals signals to watch for to terminate the operator gracefully // Using os.Interrupt is more portable across platforms instead of os.SIGINT - shutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM} + ShutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM} // Placeholder for the CRD manager life cycle, first we have the context to manage cancellation // of the manager. @@ -85,7 +85,7 @@ func New(context *clusterd.Context, rookImage, serviceAccount string) *Operator func (o *Operator) Run() error { // Initialize signal handler and context for the operator process life cycle // This context is used to handle the graceful termination of the operator - operatorContext, operatorStop := signal.NotifyContext(context.Background(), shutdownSignals...) + operatorContext, operatorStop := signal.NotifyContext(context.Background(), ShutdownSignals...) defer operatorStop() // Start the CRD manager diff --git a/pkg/operator/k8sutil/cmdreporter/cmdreporter.go b/pkg/operator/k8sutil/cmdreporter/cmdreporter.go index 45f213982..113151a79 100644 --- a/pkg/operator/k8sutil/cmdreporter/cmdreporter.go +++ b/pkg/operator/k8sutil/cmdreporter/cmdreporter.go @@ -42,10 +42,10 @@ const ( CmdReporterContainerName = "cmd-reporter" // CopyBinariesInitContainerName defines the name of the CmdReporter init container which copies - // the 'rook' and 'tini' binaries. + // the 'rook' binary. CopyBinariesInitContainerName = "init-copy-binaries" - // CopyBinariesMountDir defines the dir into which the 'rook' and 'tini' binaries will be copied + // CopyBinariesMountDir defines the dir into which the 'rook' binary will be copied // in the CmdReporter job pod's containers. CopyBinariesMountDir = "/rook/copied-binaries" ) @@ -85,7 +85,7 @@ type cmdReporterCfg struct { // job will be identified with the job name specified. Everything will be created in the job // namespace and will be owned by the owner reference given. // -// The Rook image defines the Rook image from which the 'rook' and 'tini' binaries will be taken in +// The Rook image defines the Rook image from which the 'rook' binary will be taken in // order to run the cmd and args in the run image. If the run image is the same as the Rook image, // then the command will run without the binaries being copied from the same Rook image. func New( @@ -351,11 +351,9 @@ func (cr *cmdReporterCfg) container() (*v1.Container, error) { return nil, fmt.Errorf("failed to convert user cmd %+v and args %+v into an argument for '--command'. %+v", cr.cmd, cr.args, err) } - cmd := []string{ - path.Join(CopyBinariesMountDir, "tini"), "--", path.Join(CopyBinariesMountDir, "rook"), - } + cmd := []string{path.Join(CopyBinariesMountDir, "rook")} if !cr.needToCopyBinaries() { - // tini -- rook is already the cmd entrypoint if we don't need to copy binaries + // rook is already the cmd entrypoint if we don't need to copy binaries cmd = nil } diff --git a/pkg/operator/k8sutil/volume.go b/pkg/operator/k8sutil/volume.go index 8ebda3f08..22f67be44 100644 --- a/pkg/operator/k8sutil/volume.go +++ b/pkg/operator/k8sutil/volume.go @@ -81,7 +81,7 @@ func NodeConfigURI() (string, error) { } func BinariesMountInfo() (v1.EnvVar, v1.Volume, v1.VolumeMount) { - // To get rook inside the container, the config init container needs to copy "tini" and "rook" binaries into a volume. + // To get rook inside the container, the config init container needs to copy "rook" binary into a volume. // Set the config flag so rook will copy the binaries. // Create the volume and mount that will be shared between the init container and the daemon container volumeName := "rookbinaries"