Support enroll-init retry

In the event of an enroll-init failure (e.g., standalone node reconfig
failure), a retry without reinstallation must be supported to allow
users to simply try again with updated config values.
Hence, it is necessary to ensure the seed ISO is regenerated,
inserted, and cloud-init re-runs/applies the corrected
config. Overall, this requires the cloud-init module frequency
to be set to 'always' (from the default 'per instance') to ensure cloud
config is applied on enroll-init retries.

Story: 2011100
Task: 50663

Test Plan:
1. PASS: Validate generated Seed ISO
   - Mount generated seed ISO and ensure user-data includes
     expected module frequency updates

2. PASS: Verify that enroll-init can be redone after successive
   enroll-init failures (standalone reconfig failure)
   - Initiate enroll-init with bad payload such that the
     enroll-init-reconfig script fails on the subcloud
   - Verify enroll-init success with corrected parameters

3. PASS: Verify error msgs on target subcloud for each failed
   enroll-init attempt. Ensure success log after the failed attempts.

Change-Id: I8884ed8eb91d6ce1f3513f796dd999c96ffdc594
Signed-off-by: Salman Rana <salman.rana@windriver.com>
This commit is contained in:
Salman Rana
2024-07-26 18:17:35 -04:00
parent 186307a2c9
commit 234c9bd08f

View File

@@ -180,7 +180,17 @@ class SubcloudEnrollmentInit(object):
user_data_file = os.path.join(path, "user-data")
with open(user_data_file, "w") as f_out_user_data_file:
contents = {"runcmd": runcmd}
# Cloud-init module frequency for runcmd and scripts-user
# must be set to 'always'. This ensures that the
# cloud config is applied on an enroll-init retry, since the
# default frequency for these modules is 'per-instance'.
# It's necessary to specify both modules, runcmd
# generates the script, while scripts-user executes it.
contents = {
"cloud_config_modules": [["runcmd", "always"]],
"cloud_final_modules": [["scripts-user", "always"]],
"runcmd": runcmd,
}
f_out_user_data_file.writelines("#cloud-config\n")
f_out_user_data_file.write(
yaml.dump(