kubernetes/kops · error
unable to parse instance url %q
Error message
unable to parse instance url %q
What it means
DumpManagedInstance casts the resource object to a GCE ManagedInstance and parses its Instance self-link URL with gce.ParseGoogleCloudURL; if the URL doesn't match the expected projects/zones/instances format, it returns 'unable to parse instance url %q' without wrapping the parse error. This means the instance self-link stored on the resource is malformed or empty.
Source
Thrown at pkg/resources/gce/dump.go:52
cloud gce.GCECloud
// mutex protects the follow resources
mutex sync.Mutex
// instances is a cache of instances by zone
instances map[string]map[string]*compute.Instance
// disks is a cache of disks by zone
disks map[string]map[string]*compute.Disk
}
// DumpManagedInstance is responsible for dumping a resource for a ManagedInstance
func DumpManagedInstance(op *resources.DumpOperation, r *resources.Resource) error {
instance := r.Obj.(*compute.ManagedInstance)
u, err := gce.ParseGoogleCloudURL(instance.Instance)
if err != nil {
return fmt.Errorf("unable to parse instance url %q", instance.Instance)
}
// Fetch instance details
instanceMap, err := getDumpState(op).getInstances(op.Context, u.Zone)
if err != nil {
return err
}
i := &resources.Instance{
Name: u.Name,
}
instanceDetails := instanceMap[u.Name]
if instanceDetails == nil {
var sb strings.Builder
fmt.Fprintf(&sb, "instance %q not found (currentAction=%q instanceStatus=%q)", instance.Instance, instance.CurrentAction, instance.InstanceStatus)
if instance.LastAttempt != nil && instance.LastAttempt.Errors != nil {
for _, e := range instance.LastAttempt.Errors.Errors {View on GitHub (pinned to 4c8573c808)
Solutions
- Log/inspect the failing instance.Instance value printed in the error and compare against the expected Google self-link format.
- Refresh cluster state (kops update cluster / re-export) so instance resources carry current, full self-links.
- Delete the orphaned ManagedInstance resource from the instance group state if the underlying VM no longer exists, then re-run the dump.
- If the URL is valid but still rejected, check the gce.ParseGoogleCloudURL regex against your URL form (regional vs global paths) and update kops.
Example fix
// before
u, err := gce.ParseGoogleCloudURL(instance.Instance)
if err != nil {
return fmt.Errorf("unable to parse instance url %q", instance.Instance)
}
// after
u, err := gce.ParseGoogleCloudURL(instance.Instance)
if err != nil {
return fmt.Errorf("unable to parse instance url %q: %w", instance.Instance, err)
} Defensive patterns
Strategy: validation
Validate before calling
var gceSelfLinkRe = regexp.MustCompile(`^https://www\.googleapis\.com/compute/[^/]+/projects/[^/]+/zones/[^/]+/instances/[^/]+$`)
func instanceURLValid(selfLink string) bool { return gceSelfLinkRe.MatchString(selfLink) }
// call before DumpManagedInstance: if !instanceURLValid(instance.Instance) { skip/log } Type guard
func isFullGCEInstanceURL(u string) bool {
_, err := gce.ParseGoogleCloudURL(u)
return err == nil && strings.HasPrefix(u, "https://www.googleapis.com/compute/")
} Try / catch
if err := resources.DumpManagedInstance(op, r); err != nil {
if strings.HasPrefix(err.Error(), "unable to parse instance url") {
klog.Warningf("skipping resource with malformed instance URL: %v", err)
return nil // continue dump instead of failing whole run
}
return err
} Prevention
- Keep kops state in sync so ManagedInstance objects carry full Google self-links
- Purge orphaned resources after partial deletions before running toolbox dump
- Validate self-link format when constructing resource objects
- Watch for version changes in Google compute API URL schemes
When it happens
Trigger: instance.Instance is empty, truncated, or not a full Google Cloud self-link (e.g. 'https://www.googleapis.com/compute/v1/projects/<proj>/zones/<zone>/instances/<name>') during 'kops toolbox dump' on a GCE cluster.
Common situations: Dangling/stale ManagedInstance resources from a partially deleted instance group, resources built from an older kops version that stored relative URLs, or manual edits to the cluster state.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- invalid google cloud URL (content after name): %q
- error parsing subnet url %q: %w
- error parsing operation URL %q: %v
- error parsing source image URL: %v
- unable to parse disk source URL: %q
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/15e3dc601d1cb557.
Report an issue: GitHub.