aws-controllers-k8s / community

AWS Controllers for Kubernetes (ACK) is a project enabling you to manage AWS services from Kubernetes
https://aws-controllers-k8s.github.io/community/
Apache License 2.0
2.43k stars 256 forks source link

[S3] The status field of the lifecycle rules is required #1523

Open aljoshare opened 2 years ago

aljoshare commented 2 years ago

Describe the bug The documentation says that the status field of the lifecycle rules is optional but in fact it is required. It needs to be set to Enabled or Disabled.

Documentation: https://aws-controllers-k8s.github.io/community/reference/s3/v1alpha1/bucket/ image

Error message:

- message: |
      Error syncing property 'Lifecycle': InvalidParameter: 1 validation error(s) found.
      - missing required field, PutBucketLifecycleConfigurationInput.LifecycleConfiguration.Rules[2].Status.
    status: "True"
    type: ACK.Recoverable

Steps to reproduce

Deploy an S3 with a lifecycle configuration and omit the status field, e.g.:

apiVersion: s3.services.k8s.aws/v1alpha1
kind: Bucket
metadata:
  name: test
spec:
  name: test
  publicAccessBlock:
    blockPublicACLs: true
    blockPublicPolicy: true
    ignorePublicACLs: true
    restrictPublicBuckets: true
  versioning:
    status: Enabled
  encryption:
    rules:
      - bucketKeyEnabled: false
        applyServerSideEncryptionByDefault:
          sseAlgorithm: AES256
  lifecycle:
    rules:
      - id: "Non-Current Version Transition to STANDARD_IA"
        status: "Enabled"
        filter:
          prefix: "/topics"
        noncurrentVersionTransitions:
          - noncurrentDays: 30
            storageClass: "STANDARD_IA"
      - id: "Current Version Transition to STANDARD_IA"
        filter:
          prefix: "/topics"
        status: "Enabled"
        transitions:
          - days: 30
            storageClass: "STANDARD_IA"
      - id: "This one is broken"
        filter:
          prefix: "/topics"
        transitions:
          - days: 30
            storageClass: "STANDARD_IA"

Expected outcome Either the documentation should say that its required or the operator should fill the field with a default value so that truly optional.

Environment

ack-bot commented 1 year ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

jaypipes commented 1 year ago

@RedbackThomson feel like taking a stab at this? I think now that codegen supports nested field configuration options, I think this should be fixable by adding an is_required to the FieldConfig of Lifecycle.Rules.Status?

RedbackThomson commented 1 year ago

@jaypipes I see that Enabled is already a required field within LifecycleRule. I wonder why it's not marked as required by default within the type. If I manually mark this field as required, I would have to mark every other field within all of these other custom configuration fields as well?

jaypipes commented 1 year ago

@jaypipes I see that Enabled is already a required field within LifecycleRule. I wonder why it's not marked as required by default within the type. If I manually mark this field as required, I would have to mark every other field within all of these other custom configuration fields as well?

It is indeed.

This must be a bug in the API inference part of the code-generator. I can take a look into it tomorrow.

a-hilaly commented 1 year ago

I think this is very similar to what @embano1 is experiencing in https://github.com/aws-controllers-k8s/community/issues/1645

jljaco commented 1 year ago

/remove-lifecycle stale

jaypipes commented 1 year ago

Potential fix for this: https://github.com/aws-controllers-k8s/code-generator/pull/393

ack-bot commented 1 year ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

ack-bot commented 1 year ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle rotten

jljaco commented 1 year ago

/remove-lifecycle rotten

ack-bot commented 11 months ago

Issues go stale after 180d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 60d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

ack-bot commented 5 months ago

Issues go stale after 180d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 60d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale