kubernetes/kops · error

error extracting server groups from pages: %v

Error message

error extracting server groups from pages: %v

What it means

After the pages are fetched, servergroups.ExtractServerGroups(allPages) decodes the JSON body into []servergroups.ServerGroup. If the page body cannot be parsed or does not match the expected server-groups schema, kOps wraps the error as "error extracting server groups from pages: %v". This is a response-decoding failure, not a transport failure.

Source

Thrown at upup/pkg/fi/cloudup/openstack/server_group.go:74

	}
}

func (c *openstackCloud) ListServerGroups(opts servergroups.ListOptsBuilder) ([]servergroups.ServerGroup, error) {
	return listServerGroups(c, opts)
}

func listServerGroups(c OpenstackCloud, opts servergroups.ListOptsBuilder) ([]servergroups.ServerGroup, error) {
	var sgs []servergroups.ServerGroup

	done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) {
		allPages, err := servergroups.List(c.ComputeClient(), opts).AllPages(context.TODO())
		if err != nil {
			return false, fmt.Errorf("error listing server groups: %v", err)
		}

		r, err := servergroups.ExtractServerGroups(allPages)
		if err != nil {
			return false, fmt.Errorf("error extracting server groups from pages: %v", err)
		}
		sgs = r
		return true, nil
	})
	if err != nil {
		return sgs, err
	} else if done {
		return sgs, nil
	} else {
		return sgs, wait.ErrWaitTimeout
	}
}

func osBuildCloudInstanceGroup(c OpenstackCloud, cluster *kops.Cluster, ig *kops.InstanceGroup, nodeMap map[string]*v1.Node) (*cloudinstances.CloudInstanceGroup, error) {
	cg := &cloudinstances.CloudInstanceGroup{
		HumanName:     ig.Name,
		InstanceGroup: ig,
		MinSize:       int(fi.ValueOf(ig.Spec.MinSize)),

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Capture the raw response (e.g. 'openstack server group list --debug') and check whether a proxy/LB is returning an error page instead of JSON.
  2. Upgrade or align the Gophercloud SDK version with the cloud's Nova API release so the schema matches.
  3. Remove/fix any proxy intercepting compute API traffic, or point the client directly at the nova-api endpoint.
  4. Retry if the page was truncated by a transient network error; if consistent, the response schema itself is the problem.

Example fix

// before: incompatible SDK decode of newer API body
// go.mod: github.com/gophercloud/gophercloud/v2 v2.0.0
// after: bump SDK to match cloud API
// go.mod: github.com/gophercloud/gophercloud/v2 v2.x.y (with servergroups schema fix)
require github.com/gophercloud/gophercloud/v2 v2.7.0
Defensive patterns

Strategy: fallback

Validate before calling

// Probe that the API returns parseable JSON before relying on extraction
var probe map[string]json.RawMessage
resp, err := servergroups.List(computeClient, nil).AllPages(ctx)
if err == nil {
	if err := json.Unmarshal(servergroups.ExtractPagesInto(resp), &probe); err != nil {
		return fmt.Errorf("compute API returned non-JSON body (proxy misconfiguration?): %w", err)
	}
}

Try / catch

sgs, err := cloud.ListServerGroups(opts)
if err != nil {
	if strings.Contains(err.Error(), "error extracting server groups from pages") {
		// decode failure: log raw body via debug mode and degrade gracefully
		klog.Warningf("server group response undecodable; proceeding without server group discovery: %v", err)
		sgs = nil // or fall back to an alternate discovery path
		return sgs, nil
	}
	return err
}

Prevention

When it happens

Trigger: servergroups.ExtractServerGroups(allPages) returns an error because the response body is not valid JSON (truncated page, HTML error page from a proxy), or the JSON lacks the expected "server_groups" array / has unexpected field types (e.g. an API microversion or proxy mangling the body).

Common situations: An API gateway/LB in front of nova-api returns an HTML 502 page that the SDK tries to unmarshal; a non-standard OpenStack distribution (or older release) returns a different server-groups schema; TLS-terminating proxy truncating large paginated responses; SDK version mismatch with the deployed Nova API.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/5ea21607bf4f4621. Report an issue: GitHub.