{"record":{"id":"62fc4ec954f2d059","repo":"kubernetes/kops","slug":"reading-expected-user-data-w","errorCode":null,"errorMessage":"reading expected user-data: %w","messagePattern":"reading expected user-data: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/scalewaytasks/instance.go","lineNumber":429,"sourceCode":"}\n\nfunc checkUserDataDifferences(c *fi.CloudupContext, cloud scaleway.ScwCloud, actualServer *instance.Server, expectedUserData *fi.Resource) (bool, error) {\n\tactualUserData, err := cloud.InstanceService().GetServerUserData(&instance.GetServerUserDataRequest{\n\t\tZone:     actualServer.Zone,\n\t\tServerID: actualServer.ID,\n\t\tKey:      \"cloud-init\",\n\t}, scw.WithContext(c.Context()))\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"getting actual user-data: %w\", err)\n\t}\n\n\tactualUserDataBytes, err := io.ReadAll(actualUserData)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"reading actual user-data: %w\", err)\n\t}\n\texpectedUserDataBytes, err := fi.ResourceAsBytes(*expectedUserData)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"reading expected user-data: %w\", err)\n\t}\n\n\tif sha256.Sum256(actualUserDataBytes) != sha256.Sum256(expectedUserDataBytes) {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}\n\nfunc imageLabelFromID(c *fi.CloudupContext, cloud scaleway.ScwCloud, id string) (string, error) {\n\tlocalImage, err := cloud.MarketplaceService().GetLocalImage(&marketplace.GetLocalImageRequest{\n\t\tLocalImageID: id,\n\t}, scw.WithContext(c.Context()))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"getting image from the marketplace: %w\", err)\n\t}\n\treturn localImage.Label, nil\n}\n","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/scalewaytasks/instance.go#L411-L447","documentation":"In checkUserDataDifferences, the expected user-data (a fi.Resource held by the Instance task) is materialized with fi.ResourceAsBytes before SHA-256 comparison against the live server user-data. This error wraps a failure of that materialization: the resource could not be opened or read (e.g. an unreadable local file or failing resource provider). It indicates the desired user-data on the kOps side is unreadable, not a problem with the cloud.","triggerScenarios":"fi.ResourceAsBytes(*expectedUserData) errors because the backing resource — typically a file:// resource or a bytes resource from the instance template — cannot be opened/read; file deleted or permissions changed between task construction and rendering.","commonSituations":"Cluster manifest references user-data generated on the fly (e.g. nodeup bootstrap script) whose underlying file handle or path is unavailable; running kOps in a container without the referenced file mounted; permission-restricted secrets dir.","solutions":["Check that the source of the user-data resource (bootstrap script path) exists and is readable by the kOps process.","Re-run `kops update cluster`; if a temp file was deleted, it will be regenerated.","Verify file permissions on ~/.cache/kops or the assets directory kOps reads bootstrap scripts from.","If it persists, file an issue — this usually indicates an internal kOps resource construction bug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate the expected user-data resource is readable before the reconcile\nif expectedUserData != nil {\n    if _, err := fi.ResourceAsBytes(*expectedUserData); err != nil {\n        return fmt.Errorf(\"expected user-data unreadable: %w\", err)\n    }\n}","typeGuard":"func userDataReadable(r fi.Resource) bool {\n    if r == nil { return false }\n    _, err := fi.ResourceAsBytes(r)\n    return err == nil\n}","tryCatchPattern":"expectedBytes, err := fi.ResourceAsBytes(*expectedUserData)\nif err != nil {\n    return false, fmt.Errorf(\"reading expected user-data: %w\", err) // surfaces as invalid cluster spec, not a cloud issue\n}","preventionTips":["Keep the machine/container running kops able to read all bootstrap asset paths","Don't mutate or delete ~/.cache/kops files while an apply is in flight","Run `kops update cluster --dry-run` first to surface unreadable resources early"],"tags":["scaleway","user-data","io","kops"],"backgroundTag":"resource-read-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}