{"record":{"id":"ab6e92d8c1ff628f","repo":"kubernetes/kops","slug":"s-was-listed-but-then-not-found-q","errorCode":null,"errorMessage":"%s was listed, but then not found %q","messagePattern":"(.+?) was listed, but then not found %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/client/simple/vfsclientset/commonvfs.go","lineNumber":248,"sourceCode":"\tsliceValue := reflect.ValueOf(items)\n\tsliceType := reflect.TypeOf(items)\n\tif sliceType.Kind() != reflect.Slice {\n\t\treturn nil, fmt.Errorf(\"expected slice, got %T\", items)\n\t}\n\n\tnames, err := c.listNames(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, name := range names {\n\t\to, err := c.Find(ctx, name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif o == nil {\n\t\t\treturn nil, fmt.Errorf(\"%s was listed, but then not found %q\", c.kind, name)\n\t\t}\n\n\t\tsliceValue = reflect.Append(sliceValue, reflect.ValueOf(o).Elem())\n\t}\n\n\treturn sliceValue.Interface(), nil\n}\n","sourceCodeStart":230,"sourceCodeEnd":256,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/client/simple/vfsclientset/commonvfs.go#L230-L256","documentation":"readAll lists names in the state store then Find()s each one. If a listed name disappears between listing and read (or Find returns nil without error), the library returns this consistency error. It is a race / deletion-between-list-and-read condition.","triggerScenarios":"Concurrent deletion of an instance group or cluster object while another client runs List; partially completed delete operations leaving stale listing state.","commonSituations":"Two operators running `kops delete` and `kops get` simultaneously; automation deleting objects during reads; eventual-consistency lag on object stores making a just-deleted key still appear in listings.","solutions":["Re-run the List command once concurrent deletes finish.","Eliminate concurrent writers to the same cluster state directory.","Use object-store versioning or locking if multiple operators share a state store.","Clean up leftover/partial objects."],"exampleFix":"// before\nkops delete instancegroup foo & kops get instancegroups   # racy\n// after\nkops delete instancegroup foo\nkops get instancegroups   # sequential, no race","handlingStrategy":"retry","validationCode":"names, _ := listChildNames(ctx, basePath)\nfor _, name := range names {\n    if _, err := c.Find(ctx, name); err != nil {\n        return err\n    }\n}\n// pre-check every listed name before processing","typeGuard":null,"tryCatchPattern":"items, err := client.List(ctx, metav1.ListOptions{})\nif err != nil {\n    if strings.Contains(err.Error(), \"was listed, but then not found\") {\n        // transient: an object was deleted mid-list; retry once\n        time.Sleep(time.Second)\n        return client.List(ctx, metav1.ListOptions{})\n    }\n    return err\n}","preventionTips":["Serialize read and delete operations on the same cluster state","Avoid parallel kops commands against one state store","Use S3 versioning/locking for shared state stores"],"tags":["vfs","race-condition","consistency"],"backgroundTag":"read-during-delete-race","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"}