derailed/k9s · error
can not rollback current replica
Error message
can not rollback current replica
What it means
getRSRevision backs the ReplicaSet rollback command (dao/rs.go:88 Rollback). Kubernetes refuses to roll a Deployment back to the revision that is currently active, so k9s checks rs.Status.Replicas: a non-zero count means this ReplicaSet is the live one and the attempt is rejected before contacting the API server. The error tells you to pick an older revision instead.
Solutions
- Select an older ReplicaSet (one with 0 replicas / not the revision annotated as current) and retry the rollback.
- Confirm with `kubectl rollout history deployment/<name>` which revision is active, and target a previous one.
- If you truly need to reapply the current revision, edit/apply the Deployment spec instead of using rollback.
Defensive patterns
Strategy: validation
Validate before calling
func isRollbackable(rs *appsv1.ReplicaSet) bool {
return rs.Status.Replicas == 0
}
rs, _ := replicaSetDAO.Load(factory, fqn)
if !isRollbackable(rs) {
// pick an older RS row; current revision cannot be a rollback target
} Try / catch
if err := rsDAO.Rollback(fqn); err != nil {
if strings.Contains(err.Error(), "can not rollback current replica") {
flash.Warnf("Select an older replicaset to roll back")
} else { /* surface err */ }
} Prevention
- In UI code, only offer :rollback on rows with 0 replicas.
- Teach users to check `kubectl rollout history` for valid targets.
- Remember rolling back TO the active revision is a no-op by design.
When it happens
Trigger: Running the rollback action (:rollback) on the newest ReplicaSet of a Deployment while it still has running replicas (Status.Replicas > 0), i.e. trying to roll back to the current revision.
Common situations: Selecting the top/active RS row in the replicasets view instead of an older one; a Deployment that just rolled out and the old RS was scaled to 0 so users assume any row is rollback-able; automated scripts invoking Rollback on an arbitrary RS FQN.
Related errors
- revision conversion failed
- expected Unstructured, but got %T
- expecting Deployment resource
- no valid selector found on deployment
- unable to find controller for replicaset
AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15).
Data as JSON: /api/errors/e43a5d27bd1da505.
Report an issue: GitHub.
Appendix: source
Thrown at internal/dao/rs.go:62
func (*ReplicaSet) Load(f Factory, path string) (*appsv1.ReplicaSet, error) {
o, err := f.Get(client.RsGVR, path, true, labels.Everything())
if err != nil {
return nil, err
}
var rs appsv1.ReplicaSet
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &rs)
if err != nil {
return nil, err
}
return &rs, nil
}
func getRSRevision(rs *appsv1.ReplicaSet) (int64, error) {
revision := rs.Annotations["deployment.kubernetes.io/revision"]
if rs.Status.Replicas != 0 {
return 0, errors.New("can not rollback current replica")
}
vers, err := strconv.Atoi(revision)
if err != nil {
return 0, errors.New("revision conversion failed")
}
return int64(vers), nil
}
func controllerInfo(rs *appsv1.ReplicaSet) (name, kind, group string, err error) {
for _, ref := range rs.OwnerReferences {
if ref.Controller == nil {
continue
}
group, tokens := ref.APIVersion, strings.Split(ref.APIVersion, "/")
if len(tokens) == 2 {
group = tokens[0]
}View on GitHub (pinned to 2d3ccc6ba2)