Skip to content

incorrect input for comparing object meta #937

@surajkota

Description

@surajkota

Describe the bug
While working on #931, I noticed that kc.Patch (metadata + spec) was always getting executed during delete and found that even though we are passing resource.MetaObject() to MetaV1ObjectEqual() the whole runtime object gets passed.

Steps to reproduce
Print string(aBytes) and string(bBytes) before this line. See below the whole object including status and spec get printed.

aBytes:
{"metadata":{"name":"sdk-endpoint-zmf2ez058uziox31eo7-model","namespace":"default","selfLink":"/apis/sagemaker.services.k8s.aws/v1alpha1/namespaces/default/models/sdk-endpoint-zmf2ez058uziox31eo7-model","uid":"2c24a9ef-06be-47a5-989b-bd61a89c959d","resourceVersion":"32242499","generation":2,"creationTimestamp":"2021-09-07T21:27:55Z","deletionTimestamp":"2021-09-07T21:28:16Z","deletionGracePeriodSeconds":0,"annotations":{"services.k8s.aws/adopted":"true"},"finalizers":["finalizers.sagemaker.services.k8s.aws/Model"]},"spec":{"containers":[{"image":"246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.0-1-cpu-py3","mode":"SingleModel","modelDataURL":"s3://XXX-test-data/sagemaker/model/xgboost-mnist-model.tar.gz"}],"enableNetworkIsolation":false,"executionRoleARN":"arn:aws:iam::123456789012:role/m-sagemaker-role","modelName":"sdk-endpoint-zmf2ez058uziox31eo7-model"},"status":{"ackResourceMetadata":{"arn":"arn:aws:sagemaker:us-west-2:123456789012:model/sdk-endpoint-zmf2ez058uziox31eo7-model","ownerAccountID":"123456789012"},"conditions":[]}}

bBytes:
{"metadata":{"name":"sdk-endpoint-zmf2ez058uziox31eo7-model","namespace":"default","selfLink":"/apis/sagemaker.services.k8s.aws/v1alpha1/namespaces/default/models/sdk-endpoint-zmf2ez058uziox31eo7-model","uid":"2c24a9ef-06be-47a5-989b-bd61a89c959d","resourceVersion":"32242499","generation":2,"creationTimestamp":"2021-09-07T21:27:55Z","deletionTimestamp":"2021-09-07T21:28:16Z","deletionGracePeriodSeconds":0,"annotations":{"services.k8s.aws/adopted":"true"}},"spec":{"containers":[{"image":"246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.0-1-cpu-py3","mode":"SingleModel","modelDataURL":"s3://XXX-test-data/sagemaker/model/xgboost-mnist-model.tar.gz"}],"enableNetworkIsolation":false,"executionRoleARN":"arn:aws:iam::123456789012:role/m-sagemaker-role","modelName":"sdk-endpoint-zmf2ez058uziox31eo7-model"},"status":{"ackResourceMetadata":{"arn":"arn:aws:sagemaker:us-west-2:123456789012:model/sdk-endpoint-zmf2ez058uziox31eo7-model","ownerAccountID":"123456789012"},"conditions":[]}}

Expected outcome
The comparison should only be done on specific fields in metadata like annotations and not the whole object.

  • Reason: even in the above output, the diff is a finalizer is present in a but not in b. Not sure why that is the case but is unrelated to this issue. only saw this during delete.

We should only touch fields set/unset by the controller. Maybe we can have guidance to prefix controller related annotations with services.k8s.aws and runtime only compares these annotations instead of all metadata/all annotations

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions