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

translate: support deprecated create filesystem object #28

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tormath1
Copy link

Hi,

In this PR, we add support for create object in the filesystem configuration:

  "storage": {
    "filesystems": [
      {
        "mount": {
          "device": "/dev/disk/by-label/ROOT",
          "format": "btrfs",
          "create": {
            "force": true,
            "options": [
              "--label=ROOT",
              "--uuid=9aa5237a-ab6b-458b-a7e8-f25e2baef1a3"
            ]
          }
        }
      }
    ]

ign-converter will try to use value from f.Mount.WipeFilesystem if this one is nil and we have a f.Mount.Create struct, we try to parse the options (label and uuid) and wipeFilesystem is conditionally bound to f.Mount.Create.Force.

Even if create object is deprecated, I feel that supporting into the ign-converter will help users to migrate to newer versions of ignition.

Copy link
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

translate/v23tov30/v23tov30.go Outdated Show resolved Hide resolved
translate/v23tov30/v23tov30.go Outdated Show resolved Hide resolved
// If `wipe` is set to `false` but we have a `"create": {...}` section, we try
// to convert it.
if wipe == nil && f.Mount.Create != nil {
wipe = util.BoolP(f.Mount.Create.Force)
Copy link
Contributor

Choose a reason for hiding this comment

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

If Force is true, it's safe to set WipeFilesystem true. But if Mount.Create is non-nil and Force is false, I think we should fail the translation. In that situation, the config is asking for the FS to be created if it doesn't exist, and for Ignition to fail otherwise. For the case where the filesystem exists and matches the specified parameters (format etc.), Ignition 2.x can't deliver those semantics: provisioning would succeed instead.

Copy link
Author

Choose a reason for hiding this comment

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

I get your point - and this is something I'd like to talk with you; maybe in a dedicated issue. Currently ign-converter expects a fsMap to map file systems with path, what if we could generate this value on the fly, with something like:

 @@ -49,7 +50,13 @@ func Check2_4(cfg old.Config, fsMap map[string]string) error {
        fsMap["root"] = "/"
        for _, fs := range cfg.Storage.Filesystems {
                if _, ok := fsMap[fs.Name]; !ok {
-                       return util.NoFilesystemError(fs.Name)
+                       // generate a random path
+                       p, err := ioutil.TempDir("", fs.Name)
+                       if err != nil {
+                               return fmt.Errorf("creating tmp fs directory: %w", err)
+                       }
+
+                       fsMap[fs.Name] = p
                }

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's discuss that change in a separate issue. I don't think it's relevant here, though? The problem here isn't the mountpoint, but what to do if the specified Device already has a filesystem superblock on it.

Copy link
Author

@tormath1 tormath1 Nov 16, 2021

Choose a reason for hiding this comment

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

Ok, the issue is created in here: #30

The problem here isn't the mountpoint, but what to do if the specified Device already has a filesystem superblock on it.

Got it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, cool. So let's add an error return in Check2_* if f.Mount.Create != nil && !f.Mount.Create.Force, and a comment here referring to that.

since we support `mount.create` object, we need to check that the
filesystem will be actually forced in its creation.

Otherwise it will conflict with an eventual existing fs on a device.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
It can be useful for users interested to translate their ignition config
with deprecated fields like the `create` one.

We extract the options (`label` and `uuid`) from the `options` array in
the `create` object.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
we assert that filesystem `create` object is correctly translated to
filesystems options.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
in this case the check must fail because it does not fulfill the
requirements.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
@tormath1 tormath1 force-pushed the tormath1/support-create branch from c6b931e to 058ae48 Compare November 17, 2021 09:58
@tormath1
Copy link
Author

@bgilbert fixup! commits have been squased since you resolved the conversations and two new commits have been pushed to add the check config and its associated test dicussed in here: #28 (comment).

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 this pull request may close these issues.

2 participants