Commit Graph
399 Commits
Author SHA1 Message Date
Chen, Tingjie 0e87348093 ceph: add support for wal device for OSD on PVC
Based on the feature of metadata PVC for OSD: #4818, add the wal device.

For this, you need to create a new volumeClaimTemplates, its name must be "wal", if "wal" is
set, "metadata" device will refers specially for block.db device, and "wal" refers for block.wal
device in BlueStore.

A template will look like this:

```
volumeClaimTemplates:
- metadata:
    name: data
  spec:
    resources:
      requests:
        storage: 10Gi
    # IMPORTANT: Change the storage class depending on your environment (e.g. local-storage, gp2)
    storageClassName: gp2
    volumeMode: Block
    accessModes:
      - ReadWriteOnce
- metadata:
    name: metadata
  spec:
    resources:
      requests:
        storage: 6Gi
    # IMPORTANT: Change the storage class depending on your environment (e.g. local-storage, io1)
    storageClassName: io1
    volumeMode: Block
    accessModes:
      - ReadWriteOnce
- metadata:
    name: wal
  spec:
    resources:
      requests:
        storage: 6Gi
    # IMPORTANT: Change the storage class depending on your environment (e.g. local-storage, io1)
    storageClassName: io1
    volumeMode: Block
    accessModes:
      - ReadWriteOnce
```

We now map block, block.db and block.wal directly inside the container instead of
running ceph-volume activate.

Signed-off-by: Chen, Tingjie <tingjie.chen@intel.com>
2020-08-10 08:48:20 +08:00
Sébastien Han 89b3225441 ceph: add encryption support for osd pvc
We can now encrypted OSD device that were provisioned via a storage
class using the PV interface.
The encryption works at the storageClassDeviceSets level, which means we
can have encrypted and non-encrypted sets.
Using the new key `encrypted` we can turn it on.

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-08-05 10:06:11 +02:00
Satoru Takeuchi 88f4b9c148 ceph: support crypt type device in OSD on PVC
Ceph supported encrypted OSD in the following two ways.

- Encrypt OSD by Ceph itself
- Encrypt OSD by user

However, Rook supports only the first way. Let's support this way too.

With supporting this way, Rook can use variety of encryption methods.
For example, TPM can be used to manage encrypt key. In fact, I use TPM
as follows.

https://github.com/cybozu-go/sabakan/blob/57ff3ab560acb99d23aa8901c1018bf865f9ff4d/docs/disk_encryption.md#disk-encryption

Signed-off-by: UMEZAWA Takeshi <takeshi-umezawa@cybozu.co.jp>
Signed-off-by: morimoto-cybozu <kenji_morimoto@cybozu.co.jp>
Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
2020-08-03 21:17:06 +00:00
subhamkrai c938849cf8 ceph: closing file which are open for writing
using defer for closing file which are open
for writing is not safe. so closing file again
following  below steps:
1. open files
2. defer file.close()
3. write
4.file.close()

these will make sure files are closed.

Signed-off-by: subhamkrai <subhamkumarrai03@gmail.com>
2020-07-30 22:37:56 +05:30
subhamkrai 0279025e9e ceph: handling all the gosec errors
a few of the gosec errors were left. so
this commit will resolve all the errors.

Signed-off-by: subhamkrai <subhamkumarrai03@gmail.com>
2020-07-30 08:19:55 +05:30
Travis Nielsen 998b3f29ea ceph: reduce the file permissions to fix gosec errors
File permissions need to be reduced to the minimum to avoid config
files from being accessed. While a connection to the pod would be
required to access the files, min privileges are set just as
another layer of security. This fixes gosec error G306.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-28 15:46:24 -06:00
Nizamudeen 041618dacb ceph: change the file and directory permissions to most narrow possible
This commit fixes where there are areas in which files and directories are
written and created with statically defined permissions. Many of these
permissions are rather open, potentially allowing other system tenants to
view and interact with their contents, which may be sensitive.

Fixed G303: Poor file permissions used for directory by using the most narrow permission

Resoves: https://github.com/rook/rook/issues/4580

Signed-off-by: Nizamudeen <nia@redhat.com>
2020-07-28 15:46:12 -06:00
subhamkrai bcd7faed4e ceph: suppress gosec errors for g204, g304, g101
this commit suppress the gosec errors for

g204: Audit use of command execution.
g304: File path provided as taint input.
g101: Look for hard coded credentials.

Signed-off-by: subhamkrai <subhamkumarrai03@gmail.com>
2020-07-28 11:10:48 +05:30
Travis Nielsen cf53467380 core: suppress gosec errors for closing files
To ensure a file handle is closed, we defer the close command
so it is guaranteed to run when the method returns. The closing
of the file handle is not going to fail in our usage since we aren't
using the SetDeadline on the files that would cancel a request
and return an error.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-24 12:31:13 -06:00
subhamkrai acc4ed5df9 ceph: handling gosec errors that are not checked
this commit handles all the gosec g104
i.e audit errors not checked inside pkg.

Signed-off-by: subhamkrai <subhamkumarrai03@gmail.com>
2020-07-24 20:02:06 +05:30
Travis Nielsen 77e787b00e Merge pull request #5805 from kesavanvt/add_device_class
ceph: Adding deviceClasses info to CephCluster CR
2020-07-22 16:00:18 -06:00
Sébastien Han 8f4e37b80a Merge pull request #5452 from leseb/osd-wipe
ceph: enhancement disk sanitize options
2020-07-22 16:11:35 +02:00
kesavan 453200045e ceph: adding deviceclasses info to cephcluster cr
The admin needs to start the toolbox and run a command such as ceph osd tree to see the device classes for each OSD. This PR simplifies it by storing the deviceclass info in the CephCluster CR status

closes: https://github.com/rook/rook/issues/5754
Signed-off-by: kesavan <kvellalo@redhat.com>
2020-07-22 17:46:51 +05:30
Travis Nielsen e4026560c5 Merge pull request #5860 from travisn/edgefs-security-review
Error checking for EdgeFS related to the security review
2020-07-21 20:54:57 -06:00
Sébastien Han 10ed662bdb ceph: enhancement disk sanitize options
Now, we can not only cleanup monitor data, logs and crashes but the
disks too. As part of the cleanupPolicy CR spec, we have a new setting
called sanitizeDisk which holds more details:

* method: indicates if the entire disk should be sanitized or simply ceph's metadata.
Possible choices are 'complete' or 'quick' (default)
* dataSource: indicate where to get random bytes from to write on the disk.
Possible choices are 'zero' (default) or 'random'
Using random sources will consume entropy from the system and will take much more time then the zero source
* iteration: overwrite N times instead of the default (1). Takes an integer value

See the documentation for more details.

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-07-21 14:07:11 +02:00
Sébastien Han a343c597f6 Merge pull request #5857 from travisn/more-clusterinfo
ceph: Additional clusterInfo cleanup for user creds
2020-07-21 12:16:44 +02:00
Sébastien Han 6e99c0933f Merge pull request #5796 from rajatsingh25aug/finalizer-deletion
Ceph: Delete Filesystem only when it exists
2020-07-21 12:13:41 +02:00
Travis Nielsen 710b3e8b19 ceph: remove obsolete log method
The ClusterInfo does not use the Log method to write the fields
anymore. The formatting was not necessary since the struct can
be logged if needed with the standard %v golang formatting.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-20 17:11:37 -06:00
Travis Nielsen e7998b3c00 ceph: additional clusterInfo cleanup for user creds
The user creds should not be passed to the ceph helper methods
since the clusterInfo already has the needed context. Removing
a final reference that was missed in the refactor.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-20 16:26:20 -06:00
RAJAT SINGH e3c0d2530d ceph: delete filesystem only when it exists
ceph-file-controller gets stuck in loops, this happens when it tires to delete the filesystem which doesn't exist.Filesystem should only be deleted when it exist.

Signed-off-by: RAJAT SINGH <rajasing@redhat.com>
2020-07-21 01:58:11 +05:30
Sébastien Han 2c48357f8b ceph: fix error message on empty buffer
Do not print the empty buffer to get a clean error message.

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-07-20 17:41:49 +02:00
Sébastien Han 954074b707 ceph: report error on timeout
If the healthcheck goroutine cannot check for the ceph status/times out
(if the mons are not in quorum) this should still be reflected in the
CRD status field.

Example:

```
status:
  ceph:
    details:
      error:
        message: 'failed to get status. . timed out: exit status 1'
        severity: Urgent
    health: HEALTH_ERR
    lastChanged: "2020-07-20T14:11:05Z"
    lastChecked: "2020-07-20T14:11:05Z"
    previousHealth: HEALTH_WARN
```

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-07-20 16:15:08 +02:00
Sébastien Han f3c4975e35 ceph: fail prepare pod if lvm2 pkg is missing
A long-standing issue that was only solved via a documentation note. Now,
during the prepare pod instantiation, we check for the presence of the
lvm binary on the host. Success will indicate that we can bootstrap
OSDs where failure will refuse to prepare the OSD.

Closes: https://github.com/rook/rook/issues/5627
Signed-off-by: Sébastien Han <seb@redhat.com>
2020-07-20 10:05:05 +02:00
Sébastien Han 94c8546d31 ceph: fix some mgr test
Fail if the orch status never gets ready.

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-07-17 14:03:58 +02:00
Travis Nielsen e74c7eaef8 ceph: refactor context and clusterInfo passed to the ceph commands
To provide more context for executing commands in a ceph cluster,
the full clusterInfo is now passed to the ceph execution commands.
All information about the cluster will now be available throughout
all the areas of the operator. The namespace, ceph credentials,
mon endpoints, and other info is a core part of that cluster info.

Arguments passed through the controllers are also simplified for
mons, mgr, osds, and other daemons where the parameters had
become too complex.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-16 15:54:54 -06:00
Travis Nielsen 4681f9e73d ceph: consolidate ceph config and client packages
The ceph config and client packages are conceptually the same.
To avoid circular dependencies in some cases, we simplify by combining
the packages into the client package.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-16 15:54:43 -06:00
Travis Nielsen 631b13b906 ceph: refactor creds used by operator
The operator should only connect to ceph with a single set of creds.
In a converged cluster this will be the admin creds and in an external
cluster it will be lower-privileged creds. Independent clusters were
implemented with a separate set of creds. To simplify the code these
are now merged to a single set.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-16 15:54:42 -06:00
Blaine Gardner 7117fc12b7 ceph: osd: add drive groups spec to cluster CR
Add the ability to provision Ceph OSDs with Drive Groups.
This adds Drive Groups to the CephCluster CRD, and it sets code
in place for propagating this config to the OSD provisioning pod.

Signed-off-by: Blaine Gardner <blaine.gardner@suse.com>
2020-07-14 09:43:03 -06:00
Vineet Badrinath 98874ccf4d ceph: implement controller-runtime for admission controllers
moves the admission-controller server to use controller-runtime library for better support, maintainibility of code.

Signed-off-by: Vineet Badrinath <vbadrina@redhat.com>
2020-07-14 01:10:03 +05:30
Vineet Badrinath ce1003aef8 ceph: adds scripts and components to support admission controllers
adds deploy.sh script to deploy validatingwebhookconfiguration and create secrets.
adds new command ceph admission-controller to start webhook servers.
adds validation for various rook custom resources

Signed-off-by: Vineet Badrinath <vbadrina@redhat.com>
2020-06-24 14:59:00 +05:30
Satoru Takeuchi f65bb923ed ceph: fix ignoring device specification with non-kname
Partition's DevLinks are empty in osd-prepare-pod. So, the device
specification with non-kname, for example devicePathFilter, doesn't
work.

Closes: https://github.com/rook/rook/issues/5504

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
2020-06-22 21:37:05 +09:00
Satoru Takeuchi e2df534abe ceph: fix the test of OSD
Fix the following bugs.

- CephVersion is not back to Octopus
- `cephadm' here is called with three arguments,
  "info --query=property <devname>". We should use 'args[2]' instead.

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
2020-06-22 05:32:58 +09:00
Sébastien Han c7f255a0e8 ceph: add the ability to set any pool property
We can now explicitly set any property on a given pool by using the new
Property field in the CephBlockPool Spec.

Also, this fixes the case where both `CephBlockPool` and `CephCluster`
are created at the same time. When Rook creates the pool, the cluster is
still being bootstrapped and the global option
`osd_pool_default_pg_autoscale_mode` has not bee set yet. So the pool
gets created but its `pg_autoscale_mode` property is set to `warn`
instead of `on`.

Closes: https://github.com/rook/rook/issues/5608V
Signed-off-by: Sébastien Han <seb@redhat.com>
2020-06-17 10:08:00 +02:00
Alexander Trost 1a072be677 core: fix info log for discovered devices
Fix the info log statement to log the discovered devices as their string
representation instead of pointers.
This changes the info log to only be the device names and the debug log
to be the whole disk struct as well.

Resolves #5625

Signed-off-by: Alexander Trost <galexrt@googlemail.com>
2020-06-16 09:37:33 +02:00
Sébastien Han 993af443a4 ceph: always turn on balancer on octopus
When running Octopus, we still need to turn on the balancer module. The
distinction is tricky, the module is "enabled" but it has to be "turned
on" and configured.

This was only working when the `pg_autoscaler` module was explicitly
listed in the CephCluster spec mgr section module section but not
automatically configured when running Octopus (the `pg_autoscaler`
module is already enabled).

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-06-09 15:42:15 +02:00
Sébastien Han 3c7a252862 ceph: fix osd number detection on upgrade
If the cluster has 3 OSDs, during the upgrade when the OSD restarts it
will temporarily disappear from the "ceph versions" list so we need a
more robust way to list the number of OSDs and always returns the total
number of OSDs.

Closes: https://github.com/rook/rook/issues/5521
Signed-off-by: Sébastien Han <seb@redhat.com>
2020-06-05 15:20:46 +02:00
Sébastien Han 5520ee35bb ceph: check if ok-to-stop even on failure
Even if we cannot determine wheter all the OSDs are running on the host,
we still need to perform the ok-to-stop check. It is far more common to
have more than 3 OSDs anyways.

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-06-05 15:06:35 +02:00
subhamkrai 4378a30c64 ceph: updated initializeBlockPVC method and added unit tests
Updated initializeBlockPVC method to add
crushDeviceClass along with
immediateExecuteArgs instead of
metadataArg. Also added unit tests for this method.

Signed-off-by: subhamkrai <subhamkumarrai03@gmail.com>
2020-05-29 12:30:19 +05:30
Sébastien Han c799e11032 ceph: enhancement cleanup with disks
Now, we can not only cleanup monitor data, logs and crashes but the
disks too. As part of the cleanupPolicy CR spec, we have a new setting
called sanitizeDisks which holds more details:

* confirmation: the confirmation message to sanitize disks,
use "yes-really-sanitize-disks" to confirm

This will **only** wipe the metadata, so it's a fast cleanup allowing
you to re-install later but won't remove all the data from the drive.

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-05-27 18:14:02 +02:00
Sébastien Han 2576674648 Merge pull request #5515 from leseb/lvm-verbose
ceph: fix lvm arg
2020-05-20 17:13:47 +02:00
Sébastien Han 712c958202 ceph: fix lvm arg
Add the valid verbose flags back.

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-05-20 13:03:51 +02:00
Travis Nielsen 5ac7b528c3 Merge pull request #5342 from rajatsingh25aug/ceph-mds-deactivate
Ceph: Newer mechanism to scale MDS for Nautilus+
2020-05-19 10:50:00 -06:00
Travis Nielsen 81dae96929 ceph: remove obsolete version from osd health check
The Ceph version information is not needed to be passed
to the osd health checker since mimic support was dropped.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-05-18 12:56:28 -06:00
Travis Nielsen af54349a5e ceph: remove invalid verbose params from lv activate
The activation of the lvs for OSDs had an invalid
argument to vgchange. The invalid argument is now reverted
to enable the OSDs in this scenario again.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-05-08 11:19:42 -06:00
Travis Nielsen 5f57b6fd3a ceph: skip ceph-volume inventory for PVs
For multipath devices, ceph-volume inventory is failing
to detect that the device is available, complaining about
insufficient space. Instead of relying on c-v inventory
to determine if the device is available, just call
c-v raw list to determine if there is already an osd
configured on the pv. Otherwise, just attempt to configure
the OSD.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-05-06 17:12:25 -06:00
RAJAT SINGH 9feb0287c5 Ceph: Newer mechanism to scale MDS for Nautilus+
ceph mds deactivate is not valid command for Nautilus, changing the mechnaism of upgrading so that it can be done in the way Nautilus does it.

Closes: https://github.com/rook/rook/issues/5278
Signed-off-by: RAJAT SINGH <rajasing@redhat.com>
2020-05-06 13:33:26 +05:30
Sébastien Han 65aae84bdd ceph: do not fail on deactivate
If we fail to release an LVM device, we should not fail the deployment.
We just print the error and let the backend handle the rest. Some
CSI backend will force detach the device anyway.
This prevents the deployment to get stuck in terminating.

Signed-off-by: Sébastien Han <seb@redhat.com>
2020-05-05 12:03:43 +02:00
Sébastien Han c2079483a4 Merge pull request #5354 from HaichaoLii/mem
tests: Fix ProbeDevices function unit test failure
2020-05-04 15:58:56 +02:00
Madhu Rajanna 81688398f2 cleanup: use err.Wrap when the formatting is not required
Replaced err.Wrapf with err.Wrap when the formatting
is not required.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-04-29 17:42:59 +05:30
Haichao Li c0a7297931 tests: Fix ProbeDevices function unit test failure
During the sgdisk command test, there was no output assignment,
causing uuid not found for device /dev/testa. Follow the log.

2020-04-27 18:24:21.921337 I | rook-discover: RUN Command lsblk
  [--all --noheadings --list --output KNAME]
2020-04-27 18:24:21.921491 I | rook-discover: RUN Command lsblk
[/dev/testa --bytes --nodeps --pairs --paths --output SIZE,ROTA,
RO,TYPE,PKNAME,NAME]
2020-04-27 18:24:21.921549 I | rook-discover: RUN Command sgdisk
[--print /dev/testa]
2020-04-27 18:24:21.921576 W | inventory: skipping device "testa"
because 'lsblk' failed. uuid not found for device /dev/testa. output=
2020-04-27 18:24:21.921592 I | rook-discover: localdevices: []
2020-04-27 18:24:21.921598 I | rook-discover: available devices: []
--- FAIL: TestProbeDevices (0.00s)
    discover_test.go:95:
                Error Trace:    discover_test.go:95
                Error:          Not equal:
                                expected: 1
                                actual  : 0
                Test:           TestProbeDevices
panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0
FAIL    github.com/rook/rook/pkg/daemon/discover        0.050s

Signed-off-by: Haichao Li <haichao.li@arm.com>
2020-04-28 17:51:22 +08:00