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

fix(wsl): Put back the "path" argument to wsl_path in ds-identify #5537

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

CarlosNihelton
Copy link
Contributor

Proposed Commit Message

fix(wsl): Put back the "path" argument to wsl_path in ds-identify

Got swallowed by 
https://github.com/canonical/cloud-init/pull/5116/commits/da6b5c437a799bb934c89545c1b077a84d34a51d

The way it is results in wrong invocation of wslpath binary,
thus we never find WSL specific data, disabling cloud-init.

Additional Context

Test Steps

  1. Have a WSL instance with datasources_list=[WSL, NoCloud] # could be something else,as long as there is one more real datasource meant to be not activated
  2. Run cloud-init normally.
  3. Look at /run/ds-identify.log. It should contain the message "No .cloud-init directories found".

We compute the .cloud-init directory correctly but when translating that into a Linux path using wslpath then things don't go well.

Unfortunately that's a function built to be mocked, so I don't see how to properly test this in the current repository practices.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

@CarlosNihelton code looks good and I can see the oversight in the original use of duplicated wslpath $params $1. Given the time it takes to setup and launch these instances for me on a paid account, can you attach the before/after of the /run/cloud-init/ds-identify.log here to establish both failure path and success.

@blackboxsw blackboxsw self-assigned this Jul 23, 2024
@CarlosNihelton
Copy link
Contributor Author

Before:

[up 15255.84s] ds-identify 
policy loaded: mode=search report=false found=all maybe=all notfound=disabled
/etc/cloud/cloud.cfg.d/99_wsl.cfg set datasource_list: [WSL, NoCloud]
WARN: No dmidecode program. Cannot read sys_vendor.
WARN: No dmidecode program. Cannot read board_name.
WARN: No dmidecode program. Cannot read chassis_asset_tag.
WARN: No dmidecode program. Cannot read product_name.
WARN: No dmidecode program. Cannot read product_serial.
WARN: No dmidecode program. Cannot read product_uuid.
DMI_PRODUCT_NAME=error
DMI_SYS_VENDOR=error
DMI_PRODUCT_SERIAL=error
DMI_PRODUCT_UUID=error
PID_1_PRODUCT_NAME=unavailable
DMI_CHASSIS_ASSET_TAG=error
DMI_BOARD_NAME=error
FS_LABELS=
ISO9660_DEVS=
KERNEL_CMDLINE=initrd=initrd.img WSL_ROOT_INIT=1 panic=-1 nr_cpus=4 hv_utils.timesync_implicit=1 console=hvc0 debug pty.legacy_count=0
VIRT=wsl
UNAME_KERNEL_NAME=Linux
UNAME_KERNEL_VERSION=#1 SMP Fri Mar 29 23:14:13 UTC 2024
UNAME_MACHINE=x86_64
DSNAME=
DSLIST=WSL NoCloud
MODE=search
ON_FOUND=all
ON_MAYBE=all
ON_NOTFOUND=disabled
pid=34 ppid=16
is_container=false
No .cloud-init directories found
No ds found [mode=search, notfound=disabled]. Disabled cloud-init [1]
[up 15256.12s] returning 1

After the fix:

[up 15416.65s] ds-identify 
policy loaded: mode=search report=false found=all maybe=all notfound=disabled
/etc/cloud/cloud.cfg.d/99_wsl.cfg set datasource_list: [WSL, NoCloud]
WARN: No dmidecode program. Cannot read sys_vendor.
WARN: No dmidecode program. Cannot read board_name.
WARN: No dmidecode program. Cannot read chassis_asset_tag.
WARN: No dmidecode program. Cannot read product_name.
WARN: No dmidecode program. Cannot read product_serial.
WARN: No dmidecode program. Cannot read product_uuid.
DMI_PRODUCT_NAME=error
DMI_SYS_VENDOR=error
DMI_PRODUCT_SERIAL=error
DMI_PRODUCT_UUID=error
PID_1_PRODUCT_NAME=unavailable
DMI_CHASSIS_ASSET_TAG=error
DMI_BOARD_NAME=error
FS_LABELS=
ISO9660_DEVS=
KERNEL_CMDLINE=initrd=initrd.img WSL_ROOT_INIT=1 panic=-1 nr_cpus=4 hv_utils.timesync_implicit=1 console=hvc0 debug pty.legacy_count=0
VIRT=wsl
UNAME_KERNEL_NAME=Linux
UNAME_KERNEL_VERSION=#1 SMP Fri Mar 29 23:14:13 UTC 2024
UNAME_MACHINE=x86_64
DSNAME=
DSLIST=WSL NoCloud
MODE=search
ON_FOUND=all
ON_MAYBE=all
ON_NOTFOUND=disabled
pid=31 ppid=16
is_container=false
Found applicable pro data file for this instance at: /mnt/c/Users/User/.ubuntupro/.cloud-init/agent.yaml
check for 'WSL' returned found
Found single datasource: WSL
[up 15416.94s] returning 0

@CarlosNihelton
Copy link
Contributor Author

CarlosNihelton commented Jul 23, 2024

And augmenting the information we log with:

diff --git a/tools/ds-identify b/tools/ds-identify
index f6a97461..9dd1ff3b 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -1776,7 +1776,7 @@ dscheck_WSL() {
 
     # Then we can check for any .cloud-init folders for the user
     if [ ! -d "$profile_dir/.cloud-init/" ] && [ ! -d "$profile_dir/.ubuntupro/.cloud-init/" ]; then
-        debug 1 "No .cloud-init directories found"
+        debug 1 "No .cloud-init directories found in $profile_dir"
         return "${DS_NOT_FOUND}"
     fi
 

we would see

[up 4.41s] ds-identify 
policy loaded: mode=search report=false found=all maybe=all notfound=disabled
/etc/cloud/cloud.cfg.d/99_wsl.cfg set datasource_list: [WSL, NoCloud]
WARN: No dmidecode program. Cannot read sys_vendor.
WARN: No dmidecode program. Cannot read board_name.
WARN: No dmidecode program. Cannot read chassis_asset_tag.
WARN: No dmidecode program. Cannot read product_name.
WARN: No dmidecode program. Cannot read product_serial.
WARN: No dmidecode program. Cannot read product_uuid.
DMI_PRODUCT_NAME=error
DMI_SYS_VENDOR=error
DMI_PRODUCT_SERIAL=error
DMI_PRODUCT_UUID=error
PID_1_PRODUCT_NAME=unavailable
DMI_CHASSIS_ASSET_TAG=error
DMI_BOARD_NAME=error
FS_LABELS=
ISO9660_DEVS=
KERNEL_CMDLINE=initrd=initrd.img WSL_ROOT_INIT=1 panic=-1 nr_cpus=4 hv_utils.timesync_implicit=1 console=hvc0 debug pty.legacy_count=0
VIRT=wsl
UNAME_KERNEL_NAME=Linux
UNAME_KERNEL_VERSION=#1 SMP Fri Mar 29 23:14:13 UTC 2024
UNAME_MACHINE=x86_64
DSNAME=
DSLIST=WSL NoCloud
MODE=search
ON_FOUND=all
ON_MAYBE=all
ON_NOTFOUND=disabled
pid=34 ppid=16
is_container=false
No .cloud-init directories found in Usage:
    -a    force result to absolute path format
    -u    translate from a Windows path to a WSL path (default)
    -w    translate from a WSL path to a Windows path
    -m    translate from a WSL path to a Windows path, with '/' instead of '\'

EX: wslpath 'c:\users'
No ds found [mode=search, notfound=disabled]. Disabled cloud-init [1]
[up 4.68s] returning 1

(notice the usage error message printed in place of the profile_dir variable).

@blackboxsw
Copy link
Collaborator

Excellent @CarlosNihelton LGTM. Please add the suspplemental parameterized log message anyway as that is a good breadcrumb anyway.

Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

One log parameterization is added.

Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

LGTM!

@blackboxsw blackboxsw merged commit 99ac819 into canonical:main Jul 23, 2024
23 checks passed
@CarlosNihelton CarlosNihelton deleted the fix-wsl-path branch July 23, 2024 23:08
holmanb pushed a commit to holmanb/cloud-init that referenced this pull request Aug 2, 2024
…nonical#5537)

Got swallowed by
https://github.com/canonical/cloud-init/pull/5116/commits/
da6b5c4

The former commit resulted in usage error from the wslpath
command thus we never found WSL specific data,
disabling cloud-init.
holmanb pushed a commit that referenced this pull request Aug 6, 2024
)

Got swallowed by
https://github.com/canonical/cloud-init/pull/5116/commits/
da6b5c4

The former commit resulted in usage error from the wslpath
command thus we never found WSL specific data,
disabling cloud-init.
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