-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Describe the bug
Jikkou incorrectly assumes that all schemas listed after the first missing schema in the configuration file need to be recreated, regardless of their actual existence in the registry.
To Reproduce
We define a schema configuration file like:
$ cat schemas.yaml
---
apiVersion: "schemaregistry.jikkou.io/v1beta2"
kind: "SchemaRegistrySubject"
metadata:
name: "schema1"
labels: {}
spec:
schemaType: "JSON"
schema: "{\"properties\":{\"b\":{\"type\":\"integer\"\
},\"a\":{\"type\":\"integer\"}},\"description\":\"test schema\",\"title\":\"schema1\",\"type\":\"object\"}"
---
apiVersion: "schemaregistry.jikkou.io/v1beta2"
kind: "SchemaRegistrySubject"
metadata:
name: "schema2"
labels: {}
spec:
schemaType: "JSON"
schema: "{\"properties\":{\"a\":{\"type\":\"integer\"\
},\"b\":{\"type\":\"integer\"}},\"description\":\"test schema 2\",\"title\":\"schema2\",\"type\":\"object\"}"
We apply it in order to create the schemas:
$ jikkou apply -f schemas.yaml
TASK [CREATE] Create subject 'schema1' (type=CREATE, compatibilityLevel=<global>) - CHANGED *************
{
"end" : "2025-07-09T14:27:22.057092Z",
"status" : "CHANGED",
"description" : "Create subject 'schema1' (type=CREATE, compatibilityLevel=<global>)",
"change" : {
"apiVersion" : "schemaregistry.jikkou.io/v1beta2",
"kind" : "SchemaRegistrySubjectChange",
"metadata" : {
"name" : "schema1",
"labels" : { },
"annotations" : {
"jikkou.io/managed-by-location" : "schemas.yaml"
}
},
"spec" : {
"changes" : [ {
"name" : "schema",
"op" : "CREATE",
"after" : { }
}, {
"name" : "schemaType",
"op" : "CREATE",
"after" : "JSON"
}, {
"name" : "references",
"op" : "CREATE",
"after" : [ ]
} ],
"op" : "CREATE",
"data" : {
"normalizeSchema" : false,
"permanentDelete" : false
}
}
},
"failed" : false,
"changed" : true
}
TASK [CREATE] Create subject 'schema2' (type=CREATE, compatibilityLevel=<global>) - CHANGED *************
{
"end" : "2025-07-09T14:27:22.057096Z",
"status" : "CHANGED",
"description" : "Create subject 'schema2' (type=CREATE, compatibilityLevel=<global>)",
"change" : {
"apiVersion" : "schemaregistry.jikkou.io/v1beta2",
"kind" : "SchemaRegistrySubjectChange",
"metadata" : {
"name" : "schema2",
"labels" : { },
"annotations" : {
"jikkou.io/managed-by-location" : "schemas.yaml"
}
},
"spec" : {
"changes" : [ {
"name" : "schema",
"op" : "CREATE",
"after" : { }
}, {
"name" : "schemaType",
"op" : "CREATE",
"after" : "JSON"
}, {
"name" : "references",
"op" : "CREATE",
"after" : [ ]
} ],
"op" : "CREATE",
"data" : {
"normalizeSchema" : false,
"permanentDelete" : false
}
}
},
"failed" : false,
"changed" : true
}
EXECUTION in 84ms
ok : 0, created : 2, altered : 0, deleted : 0 failed : 0
Now we delete schema1 from the schema registry, so here is the new status (only schema2 is present):
$ jikkou get sr
---
apiVersion: "schemaregistry.jikkou.io/v1beta2"
kind: "SchemaRegistrySubject"
metadata:
name: "schema2"
labels: {}
annotations:
schemaregistry.jikkou.io/schema-version: 2
schemaregistry.jikkou.io/url: "http://localhost:5005"
schemaregistry.jikkou.io/schema-id: 19
jikkou.io/generated: "2025-07-09T14:27:43.783493Z"
spec:
compatibilityLevel: "NONE"
schemaRegistry:
vendor: "generic"
schemaType: "JSON"
schema: |-
{
"description" : "test schema 2",
"properties" : {
"a" : {
"type" : "integer"
},
"b" : {
"type" : "integer"
}
},
"title" : "schema2",
"type" : "object"
}
references: []
Then we launch a dry-run apply:
$ jikkou apply --dry-run -f schemas.yaml
TASK [CREATE] Create subject 'schema1' (type=CREATE, compatibilityLevel=<global>) - CHANGED *************
{
"end" : "2025-07-09T14:30:02.535723Z",
"status" : "CHANGED",
"description" : "Create subject 'schema1' (type=CREATE, compatibilityLevel=<global>)",
"change" : {
"apiVersion" : "schemaregistry.jikkou.io/v1beta2",
"kind" : "SchemaRegistrySubjectChange",
"metadata" : {
"name" : "schema1",
"labels" : { },
"annotations" : {
"jikkou.io/managed-by-location" : "schemas.yaml"
}
},
"spec" : {
"changes" : [ {
"name" : "schema",
"op" : "CREATE",
"after" : { }
}, {
"name" : "schemaType",
"op" : "CREATE",
"after" : "JSON"
}, {
"name" : "references",
"op" : "CREATE",
"after" : [ ]
} ],
"op" : "CREATE",
"data" : {
"normalizeSchema" : false,
"permanentDelete" : false
}
}
},
"failed" : false,
"changed" : true
}
TASK [CREATE] Create subject 'schema2' (type=CREATE, compatibilityLevel=<global>) - CHANGED *************
{
"end" : "2025-07-09T14:30:02.535724Z",
"status" : "CHANGED",
"description" : "Create subject 'schema2' (type=CREATE, compatibilityLevel=<global>)",
"change" : {
"apiVersion" : "schemaregistry.jikkou.io/v1beta2",
"kind" : "SchemaRegistrySubjectChange",
"metadata" : {
"name" : "schema2",
"labels" : { },
"annotations" : {
"jikkou.io/managed-by-location" : "schemas.yaml"
}
},
"spec" : {
"changes" : [ {
"name" : "schema",
"op" : "CREATE",
"after" : { }
}, {
"name" : "schemaType",
"op" : "CREATE",
"after" : "JSON"
}, {
"name" : "references",
"op" : "CREATE",
"after" : [ ]
} ],
"op" : "CREATE",
"data" : {
"normalizeSchema" : false,
"permanentDelete" : false
}
}
},
"failed" : false,
"changed" : true
}
EXECUTION in 69ms (DRY_RUN)
ok : 0, created : 2, altered : 0, deleted : 0 failed : 0
Jikkou attempts to recreate both schemas despite schema2 already existing in the registry.
If we change the order in the config file (put schema2 definition in first then schema1) then here it detect that schema2 exists and only want to recreate schema1:
$ jikkou apply --dry-run -f schemas.yaml
TASK [NONE] Unchanged subject 'schema2' (type=NONE, compatibilityLevel=<global>) - OK ************
{
"end" : "2025-07-09T14:30:39.920225Z",
"status" : "OK",
"description" : "Unchanged subject 'schema2' (type=NONE, compatibilityLevel=<global>)",
"change" : {
"apiVersion" : "schemaregistry.jikkou.io/v1beta2",
"kind" : "SchemaRegistrySubjectChange",
"metadata" : {
"name" : "schema2",
"labels" : { },
"annotations" : {
"jikkou.io/managed-by-location" : "schemas.yaml"
}
},
"spec" : {
"changes" : [ {
"name" : "compatibilityLevel",
"op" : "NONE"
}, {
"name" : "schema",
"op" : "NONE",
"before" : { },
"after" : { }
}, {
"name" : "schemaType",
"op" : "NONE",
"before" : "JSON",
"after" : "JSON"
}, {
"name" : "references",
"op" : "NONE",
"before" : [ ],
"after" : [ ]
} ],
"op" : "NONE",
"data" : {
"normalizeSchema" : false,
"permanentDelete" : false
}
}
},
"failed" : false,
"changed" : false
}
TASK [CREATE] Create subject 'schema1' (type=CREATE, compatibilityLevel=<global>) - CHANGED *************
{
"end" : "2025-07-09T14:30:39.920226Z",
"status" : "CHANGED",
"description" : "Create subject 'schema1' (type=CREATE, compatibilityLevel=<global>)",
"change" : {
"apiVersion" : "schemaregistry.jikkou.io/v1beta2",
"kind" : "SchemaRegistrySubjectChange",
"metadata" : {
"name" : "schema1",
"labels" : { },
"annotations" : {
"jikkou.io/managed-by-location" : "schemas.yaml"
}
},
"spec" : {
"changes" : [ {
"name" : "schema",
"op" : "CREATE",
"after" : { }
}, {
"name" : "schemaType",
"op" : "CREATE",
"after" : "JSON"
}, {
"name" : "references",
"op" : "CREATE",
"after" : [ ]
} ],
"op" : "CREATE",
"data" : {
"normalizeSchema" : false,
"permanentDelete" : false
}
}
},
"failed" : false,
"changed" : true
}
EXECUTION in 72ms (DRY_RUN)
ok : 1, created : 1, altered : 0, deleted : 0 failed : 0
When working with three schemas (schema1, schema2, and schema3) and removing only schema2 from the schema registry, Jikkou incorrectly tries to recreate both schema2 and schema3, even though schema3 still exists in the registry.
If your remove schema1 from the registry (leaving schema2 and schema3) then it will tries to recreate the 3 schemas, and so on.
Expected behavior
Jikkou should only recreate the missing schemas.
Runtime environment
- Jikkou: 0.35.7
- Confluent schema registry 7.9.2