kubernetes/kops · error

Error applying endpoint: %v

Error message

Error applying endpoint: %v

What it means

All client-side validation passed but Store.UpsertDiscoveryEndpoint returned an error while persisting the DiscoveryEndpoint. The server wraps the store error and returns HTTP 500 with 'Error applying endpoint: %v'; the underlying cause is whatever the store implementation reported (network, serialization, storage failure).

Source

Thrown at discovery/pkg/discovery/server.go:219

	}

	// Validation: ensure the name in body matches the URL
	if input.ObjectMeta.Name != name {
		log.Info("Forbidden: name does not match", "name", input.ObjectMeta.Name, "expected", name)
		http.Error(w, "Forbidden: name does not match", http.StatusForbidden)
		return
	}

	// Validation: ensure the namespace in body matches the URL
	if input.ObjectMeta.Namespace != ns {
		log.Info("Forbidden: namespace does not match", "namespace", input.ObjectMeta.Namespace, "expected", ns)
		http.Error(w, "Forbidden: namespace does not match", http.StatusForbidden)
		return
	}

	if err := s.Store.UpsertDiscoveryEndpoint(r.Context(), universeID, &input); err != nil {
		log.Error(err, "error applying endpoint")
		http.Error(w, fmt.Sprintf("Error applying endpoint: %v", err), http.StatusInternalServerError)
		return
	}

	// Return the created object
	s.writeJSON(w, http.StatusCreated, input)

	log.Info("Applied endpoint", "namespace", input.ObjectMeta.Namespace, "name", input.ObjectMeta.Name, "universe", universeID)
}

func (s *Server) handleGetDiscoveryEndpoint(w http.ResponseWriter, r *http.Request, _ *UserInfo) {
	universeID := r.PathValue("universe")
	ns := r.PathValue("namespace")
	name := r.PathValue("name")

	found, err := s.Store.GetDiscoveryEndpoint(r.Context(), universeID, ns, name)
	if err != nil {
		http.Error(w, fmt.Sprintf("Error getting endpoint: %v", err), http.StatusInternalServerError)
		return

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the %v detail in the response body and the server log line 'error applying endpoint' to identify the underlying store error
  2. Check connectivity and credentials between the discovery server and its store backend; repair/restart the store if down
  3. Retry the apply with backoff if the cause was transient (timeout, network blip)
  4. Verify store configuration (endpoint, schema/migrations, permissions) before restarting the server
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check: ensure the endpoint serializes before sending
func precheck(ep *DiscoveryEndpoint) error {
    if _, err := json.Marshal(ep); err != nil {
        return fmt.Errorf("endpoint not serializable: %w", err)
    }
    return nil
}

Try / catch

var lastErr error
for attempt := 0; attempt < 3; attempt++ {
    err := client.ApplyDiscoveryEndpoint(ctx, universe, ns, name, ep)
    if err == nil {
        return nil
    }
    lastErr = err
    var httpErr *HTTPError
    if errors.As(err, &httpErr) && httpErr.StatusCode == http.StatusInternalServerError && strings.Contains(httpErr.Body, "Error applying endpoint") {
        time.Sleep(backoff(attempt)) // transient store failure: retry with backoff
        continue
    }
    return err // non-500 (e.g. 403): do not retry
}
return fmt.Errorf("apply failed after retries: %w", lastErr)

Prevention

When it happens

Trigger: Any apply request whose store write fails: store's backing database/etcd unreachable, request context cancelled mid-write, object fails backend validation/serialization, or a storage-layer conflict occurs.

Common situations: Store backend down or misconfigured connection string; store credentials lack write permission; transient network partition between discovery server and storage; quota/resource limits exceeded in the backing store.

Related errors


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