Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Add fs_type field to targets table #2343

Merged
merged 6 commits into from
Nov 18, 2020
Merged

Add fs_type field to targets table #2343

merged 6 commits into from
Nov 18, 2020

Conversation

johnsonw
Copy link
Contributor

@johnsonw johnsonw commented Oct 21, 2020

The fs_type data should be included in the targets table. This will be
used when creating the ldev conf and likely other things as well.

Signed-off-by: johnsonw wjohnson@whamcloud.com


This change is Reviewable

@johnsonw johnsonw requested a review from a team October 21, 2020 20:13
@johnsonw johnsonw self-assigned this Oct 21, 2020
@johnsonw johnsonw force-pushed the add-fs-type branch 3 times, most recently from 40d2591 to 2c1e5f4 Compare October 22, 2020 16:05
iml-api/src/graphql/mod.rs Outdated Show resolved Hide resolved
iml-wire-types/src/lib.rs Outdated Show resolved Hide resolved
iml-wire-types/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@mkpankov mkpankov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 11 of 11 files at r1, 4 of 4 files at r2.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @johnsonw)


iml-api/src/graphql/mod.rs, line 1211 at r2 (raw file):

        false => true,
    })
    .collect();

Collecting in between iterator calls is an antipattern. Directly append further iterator calls instead (xs below should go here, with one collect in the end).


iml-services/iml-device/src/lib.rs, line 66 at r2 (raw file):

pub async fn create_target_cache(pool: &PgPool) -> Result<Vec<Target>, ImlDeviceError> {
    let xs: Vec<Target> = sqlx::query!("select state, name, active_host_id, host_ids, filesystems, uuid, mount_path, dev_path, fs_type::text from target")

SELECT state, name, active_host_id, host_ids, filesystems, uuid, mount_path, dev_path, fs_type::text FROM target


iml-services/iml-device/src/lib.rs, line 79 at r2 (raw file):

                dev_path: x.dev_path,
                fs_type: x.fs_type.unwrap_or_else(|| "ldiskfs".to_string()).into(),
            }

Maybe implement impl From<TargetRecord> for TargetBuilder and do it like this: TargetBuilder::from(x).with_fs_type(x.fs_type.unwrap_or_else(|| "ldiskfs".to_string()).into()).build()?


iml-wire-types/src/lib.rs, line 1917 at r2 (raw file):

}

impl From<String> for FsType {

I think caller should just do &s instead of providing an impl for all types that can coerce to string slice.

iml-api/src/graphql/mod.rs Outdated Show resolved Hide resolved
@johnsonw johnsonw force-pushed the add-fs-type branch 6 times, most recently from 8ddd171 to 23c7a2a Compare October 26, 2020 18:16
@johnsonw
Copy link
Contributor Author

Just wanted to share my testing results. I setup a clean cluster with an ldiskfs monitored filesystem. The table was populated as expected with ldiskfs as the fs_type. I then removed the servers, undid the yum history for the ldiskfs installation, wiped the device labels, provisioned with zfs and re-added the servers to the existing IML installation. The zfs devices were immediately picked up and the fs_type was appropriately set zfs. After having two filesystems, this is the final output from the database:

chroma=> select name, state, fs_type from target ORDER BY state;
     name      |   state   | fs_type
---------------+-----------+---------
 zfsmo-OST000e | mounted   | zfs
 zfsmo-OST000f | mounted   | zfs
 zfsmo-MDT0000 | mounted   | zfs
 MGS           | mounted   | zfs
 zfsmo-MDT0001 | mounted   | zfs
 zfsmo-OST0000 | mounted   | zfs
 zfsmo-OST0001 | mounted   | zfs
 zfsmo-OST0002 | mounted   | zfs
 zfsmo-OST0003 | mounted   | zfs
 zfsmo-OST0004 | mounted   | zfs
 zfsmo-OST0005 | mounted   | zfs
 zfsmo-OST0006 | mounted   | zfs
 zfsmo-OST0007 | mounted   | zfs
 zfsmo-OST0008 | mounted   | zfs
 zfsmo-OST0009 | mounted   | zfs
 zfsmo-OST000a | mounted   | zfs
 zfsmo-OST000b | mounted   | zfs
 zfsmo-OST000c | mounted   | zfs
 zfsmo-OST000d | mounted   | zfs
 zfsmo-OST0010 | mounted   | zfs
 zfsmo-OST0011 | mounted   | zfs
 zfsmo-OST0012 | mounted   | zfs
 zfsmo-OST0013 | mounted   | zfs
 fs2-OST0009   | unmounted | ldiskfs
 fs2-OST0008   | unmounted | ldiskfs
 fs-MDT0000    | unmounted | ldiskfs
 fs-MDT0001    | unmounted | ldiskfs
 fs-OST0000    | unmounted | ldiskfs
 fs-OST0001    | unmounted | ldiskfs
 fs-OST0002    | unmounted | ldiskfs
 fs2-OST0004   | unmounted | ldiskfs
 fs-OST0003    | unmounted | ldiskfs
 fs-OST0004    | unmounted | ldiskfs
 fs-OST0005    | unmounted | ldiskfs
 fs-OST0006    | unmounted | ldiskfs
 fs-OST0007    | unmounted | ldiskfs
 fs-OST0008    | unmounted | ldiskfs
 fs-OST0009    | unmounted | ldiskfs
 fs2-MDT0000   | unmounted | ldiskfs
 fs2-OST0000   | unmounted | ldiskfs
 fs2-OST0001   | unmounted | ldiskfs
 fs2-OST0002   | unmounted | ldiskfs
 fs2-OST0003   | unmounted | ldiskfs
 fs2-OST0005   | unmounted | ldiskfs
 fs2-OST0006   | unmounted | ldiskfs
 fs2-OST0007   | unmounted | ldiskfs
 MGS           | unmounted | ldiskfs

iml-wire-types/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor Author

@johnsonw johnsonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above is being used when parsing a line from the ldev conf. A line could represent a zfs target, such as:

zeno1 zeno5 zeno-OST0000 zfs:lustre-zeno1/ost1

or an ldiskfs target:

oss1.local oss2.local fs2-OST0000 ldiskfs:/mnt/ost2-0

Unless there is another valid format that I'm not aware of, it should always have either ldiskfs or zfs. But since I'm converting from an &str to an FsType, I need to account for all other strings. If it isn't either ldiskfs or zfs, how should we handle it? Should I create a third variant, Unknown?

@jgrund
Copy link
Member

jgrund commented Oct 27, 2020

The above is being used when parsing a line from the ldev conf. A line could represent a zfs target, such as:

zeno1 zeno5 zeno-OST0000 zfs:lustre-zeno1/ost1

or an ldiskfs target:

oss1.local oss2.local fs2-OST0000 ldiskfs:/mnt/ost2-0

Unless there is another valid format that I'm not aware of, it should always have either ldiskfs or zfs. But since I'm converting from an &str to an FsType, I need to account for all other strings. If it isn't either ldiskfs or zfs, how should we handle it? Should I create a third variant, Unknown?

I think returning an Option<FsType> is the best approach then. We shouldn't assume one thing is another thing or it can lead to issues later on.

mkpankov
mkpankov previously approved these changes Oct 27, 2020
Copy link
Contributor

@mkpankov mkpankov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 9 files at r3, 1 of 1 files at r4.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ip1981, @jgrund, and @johnsonw)

@johnsonw
Copy link
Contributor Author

I just tried rebuilding and it passed this time. Should be ready.

mkpankov
mkpankov previously approved these changes Oct 30, 2020
Copy link
Contributor

@mkpankov mkpankov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ip1981, @jgrund, and @johnsonw)

Copy link
Contributor

@nlinker nlinker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 11 files at r1, 2 of 4 files at r2, 4 of 9 files at r3, 1 of 1 files at r4, 5 of 5 files at r5.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ip1981, @jgrund, and @johnsonw)

Copy link
Contributor

@nlinker nlinker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 4 files at r2.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ip1981, @jgrund, and @johnsonw)

mkpankov
mkpankov previously approved these changes Nov 3, 2020
Copy link
Contributor

@mkpankov mkpankov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r7.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @ip1981, @jgrund, and @johnsonw)

utopiabound
utopiabound previously approved these changes Nov 3, 2020
The fs_type data should be included in the targets table. This will be
used when creating the ldev conf and likely other things as well.

Signed-off-by: johnsonw <wjohnson@whamcloud.com>
Signed-off-by: johnsonw <wjohnson@whamcloud.com>
Signed-off-by: johnsonw <wjohnson@whamcloud.com>
… lower case.

Signed-off-by: johnsonw <wjohnson@whamcloud.com>
@johnsonw
Copy link
Contributor Author

More updates:

image

+------------+---------+-------------+-------------+--------------------------------------+---------+
| Name       | State   | Active Host | Filesystems | UUID                                 | fs_type |
+============+=========+=============+=============+======================================+=========+
| fs-MDT0000 | mounted | mds1.local  | fs          | 7a120ae2-edc2-4497-984a-501b30bedb6c | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-MDT0001 | mounted | mds2.local  | fs          | be86ec9c-6b10-471c-97c1-43e34e9a081c | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0000 | mounted | oss1.local  | fs          | 8ad89c2e-2098-43da-b60f-90d6d7be79a2 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0001 | mounted | oss1.local  | fs          | 07458651-e63d-47b1-b11b-d79f3b4cb1e5 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0002 | mounted | oss1.local  | fs          | d7561861-c714-47ac-9c50-e2224a2e7cb9 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0003 | mounted | oss1.local  | fs          | 63f6ac71-f62b-4ddc-84c4-e80bf000ebd8 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0004 | mounted | oss1.local  | fs          | 2b537a24-9546-4507-b736-9efef6077077 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0005 | mounted | oss2.local  | fs          | 8d23218c-ded4-4398-a2b3-11d6702f8845 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0006 | mounted | oss2.local  | fs          | 09dd4a49-0c15-41ba-891e-4efb6e559144 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0007 | mounted | oss2.local  | fs          | 6d674ff4-de5e-4615-a19a-820749598cb6 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0008 | mounted | oss2.local  | fs          | 0ca7a05f-74d6-4d98-881f-3ce2788475b3 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| fs-OST0009 | mounted | oss2.local  | fs          | bbafb127-2a67-439d-a8fb-44008e668f43 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+
| MGS        | mounted | mds1.local  | fs fs2      | 8447553c-c729-46ff-8277-21139448a2c7 | ldiskfs |
+------------+---------+-------------+-------------+--------------------------------------+---------+

Signed-off-by: johnsonw <wjohnson@whamcloud.com>
Signed-off-by: johnsonw <wjohnson@whamcloud.com>
@johnsonw johnsonw requested a review from a team November 17, 2020 14:33
Copy link
Contributor

@mkpankov mkpankov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 5 of 9 files at r8, 4 of 4 files at r9.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @ip1981, @jgrund, @johnsonw, and @utopiabound)

@jgrund jgrund merged commit 67f7828 into master Nov 18, 2020
@jgrund jgrund deleted the add-fs-type branch November 18, 2020 16:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants