Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround to hide output-only spec field but support it in observed state #2075

Merged

Conversation

maqiuyujoyce
Copy link
Collaborator

@maqiuyujoyce maqiuyujoyce commented Jun 20, 2024

Change description

This is a workaround for #2051 so that the output-only field spec.softDeletePolicy.EffectiveTime won't be added to CRD.

Tests you have done

  • Run make ready-pr to ensure this PR is ready for review.
  • Perform necessary E2E testing for changed resources.
go test -v -tags=integration ./pkg/controller/dynamic/ -test.run TestCreateNoChangeUpdateDelete -run-tests storagebucket -timeout 900s

Verified that the created resource doesn't have spec.softDeletePolicy.EffectiveTime field even if state-into-spec: merge is configured by default:

dynamic_controller_integration_test.go:248: created resource is &{map[apiVersion:storage.cnrm.cloud.google.com/v1beta1 kind:StorageBucket metadata:map[annotations:map[cnrm.cloud.google.com/management-conflict-prevention-policy:none cnrm.cloud.google.com/project-id:[PROJECT_ID] cnrm.cloud.google.com/state-into-spec:merge] creationTimestamp:2024-06-21T23:51:21Z finalizers:[cnrm.cloud.google.com/finalizer cnrm.cloud.google.com/deletion-defender] generation:4 labels:map[cnrm-test:true label-one:value-one managed-by-cnrm:true newkey:newval] managedFields:[map[apiVersion:storage.cnrm.cloud.google.com/v1beta1 fieldsType:FieldsV1 fieldsV1:map[f:metadata:map[f:labels:map[.:map[] f:cnrm-test:map[] f:label-one:map[] f:newkey:map[]]] f:spec:map[.:map[] f:location:map[] f:softDeletePolicy:map[.:map[] f:retentionDurationSeconds:map[]] f:versioning:map[.:map[] f:enabled:map[]]]] manager:___198TestCreateNoChangeUpdateDelete_in_github_com_GoogleCloudPlatform_k8s_config_connector_pkg_controller_dynamic.test operation:Update time:2024-06-21T23:58:13Z] map[apiVersion:storage.cnrm.cloud.google.com/v1beta1 fieldsType:FieldsV1 fieldsV1:map[f:metadata:map[f:annotations:map[f:cnrm.cloud.google.com/state-into-spec:map[]] f:finalizers:map[.:map[] v:"cnrm.cloud.google.com/deletion-defender":map[] v:"cnrm.cloud.google.com/finalizer":map[]]] f:spec:map[f:publicAccessPrevention:map[] f:resourceID:map[] f:storageClass:map[]] f:status:map[.:map[] f:conditions:map[] f:observedGeneration:map[] f:observedState:map[.:map[] f:softDeletePolicy:map[.:map[] f:effectiveTime:map[] f:retentionDurationSeconds:map[]]] f:selfLink:map[] f:url:map[]]] manager:cnrm-controller-manager operation:Update time:2024-06-22T00:16:40Z]] name:storagebucket-sample-7lyh7jdpfbs5usazbgdq namespace:7lyh7jdpfbs5usazbgdq resourceVersion:1555 uid:dd773a67-40f3-45c7-85f0-79ebf814ac14] spec:map[location:US publicAccessPrevention:inherited resourceID:storagebucket-sample-7lyh7jdpfbs5usazbgdq softDeletePolicy:map[retentionDurationSeconds:6000000] storageClass:STANDARD versioning:map[enabled:true]] status:map[conditions:[map[lastTransitionTime:2024-06-22T00:16:40Z message:The resource is up to date reason:UpToDate status:True type:Ready]] observedGeneration:4 observedState:map[softDeletePolicy:map[effectiveTime:2024-06-22T00:16:10.816Z retentionDurationSeconds:6000000]] selfLink:https://www.googleapis.com/storage/v1/b/storagebucket-sample-7lyh7jdpfbs5usazbgdq url:gs://storagebucket-sample-7lyh7jdpfbs5usazbgdq]]}

@maqiuyujoyce
Copy link
Collaborator Author

@yuwenma just a heads up that #2051 should not be released unless this PR is merged.

@yuwenma
Copy link
Collaborator

yuwenma commented Jun 26, 2024

The API, CRD and golden log looks good to me. @gemmahou Could you take another eye on the krm2tf code part?

@gemmahou
Copy link
Collaborator

Looks good to me!
/lgtm
/approve

@google-oss-prow google-oss-prow bot added the lgtm label Jun 26, 2024
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gemmahou

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 86ab5a7 into GoogleCloudPlatform:master Jun 26, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants