Skip to content

Commit 7f7a413

Browse files
authored
Add support to set/change log retention period (#4)
Issue #, if available: Description of changes: This change adds the support to set/change the retention period for log-groups. By default, when log group is created, log retention period is set to 'never expire'. So, it is necessary to allow to change it. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 3dcc80c commit 7f7a413

34 files changed

+1174
-47
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2023-05-24T17:19:40Z"
3-
build_hash: 6542e04cc357215c91df94e747e3d412fb26df97
4-
go_version: go1.19.4
5-
version: v0.26.1-3-g6542e04
6-
api_directory_checksum: 399f9b6fb5675139a83fc87a26271448ad5d9584
2+
build_date: "2023-10-10T03:24:22Z"
3+
build_hash: 7445de38211639a12e79992d154adab6e60f01fd
4+
go_version: go1.21.1
5+
version: v0.27.1-1-g7445de3
6+
api_directory_checksum: 1c09a2cd5e3e19b4be39e68fc87d33aaf0dccd1e
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.263
99
generator_config_info:
10-
file_checksum: c92ac565fa72636728117afcc963ee28a6ebd4e4
10+
file_checksum: ad8a73bf74d9e8606bc2db81635b9d58b0a1c851
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ resources:
1212
exceptions:
1313
terminal_codes:
1414
- InvalidParameterException
15+
reconcile:
16+
requeue_on_success_seconds: 60
1517
fields:
1618
Name:
1719
type: string
@@ -21,6 +23,10 @@ resources:
2123
resource: Key
2224
service_name: kms
2325
path: Status.ACKResourceMetadata.ARN
26+
RetentionDays:
27+
from:
28+
operation: PutRetentionPolicy
29+
path: RetentionInDays
2430
CreationTime:
2531
is_read_only: true
2632
from:
@@ -50,10 +56,19 @@ resources:
5056
operations:
5157
DescribeLogGroups:
5258
input_fields:
53-
LogGroupNamePattern: Name
59+
LogGroupNamePrefix: Name
5460
CreateLogGroup:
5561
input_fields:
5662
LogGroupName: Name
5763
DeleteLogGroup:
5864
input_fields:
5965
LogGroupName: Name
66+
hooks:
67+
delta_pre_compare:
68+
code: customPreCompare(delta, a, b)
69+
sdk_create_post_set_output:
70+
template_path: hooks/log_group/sdk_create_post_set_output.go.tpl
71+
sdk_read_many_post_set_output:
72+
template_path: hooks/log_group/sdk_read_many_post_set_output.go.tpl
73+
update_operation:
74+
custom_method_name: customUpdateLogGroup

apis/v1alpha1/log_group.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/controller/main.go

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/controller/deployment.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ spec:
2929
- "$(AWS_REGION)"
3030
- --aws-endpoint-url
3131
- "$(AWS_ENDPOINT_URL)"
32-
- --enable-development-logging
33-
- "$(ACK_ENABLE_DEVELOPMENT_LOGGING)"
32+
- --enable-development-logging=$(ACK_ENABLE_DEVELOPMENT_LOGGING)
3433
- --log-level
3534
- "$(ACK_LOG_LEVEL)"
3635
- --resource-tags
3736
- "$(ACK_RESOURCE_TAGS)"
3837
- --watch-namespace
3938
- "$(ACK_WATCH_NAMESPACE)"
39+
- --enable-leader-election=$(ENABLE_LEADER_ELECTION)
40+
- --leader-election-namespace
41+
- "$(LEADER_ELECTION_NAMESPACE)"
4042
image: controller:latest
4143
name: controller
4244
ports:
@@ -66,6 +68,10 @@ spec:
6668
value: "info"
6769
- name: ACK_RESOURCE_TAGS
6870
value: "services.k8s.aws/controller-version=%CONTROLLER_SERVICE%-%CONTROLLER_VERSION%,services.k8s.aws/namespace=%K8S_NAMESPACE%"
71+
- name: ENABLE_LEADER_ELECTION
72+
value: "false"
73+
- name: LEADER_ELECTION_NAMESPACE
74+
value: "ack-system"
6975
securityContext:
7076
allowPrivilegeEscalation: false
7177
privileged: false
@@ -79,5 +85,6 @@ spec:
7985
terminationGracePeriodSeconds: 10
8086
serviceAccountName: ack-cloudwatchlogs-controller
8187
hostIPC: false
82-
hostNetwork: false
8388
hostPID: false
89+
hostNetwork: false
90+
dnsPolicy: ClusterFirst

config/crd/bases/cloudwatchlogs.services.k8s.aws_loggroups.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ spec:
5656
type: object
5757
name:
5858
type: string
59+
retentionDays:
60+
format: int64
61+
type: integer
5962
tags:
6063
additionalProperties:
6164
type: string

config/rbac/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ resources:
44
- role-reader.yaml
55
- role-writer.yaml
66
- service-account.yaml
7-
7+
- leader-election-role.yaml
8+
- leader-election-role-binding.yaml
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: RoleBinding
4+
metadata:
5+
namespace: ack-system
6+
name: cloudwatchlogs-leader-election-rolebinding
7+
roleRef:
8+
apiGroup: rbac.authorization.k8s.io
9+
kind: Role
10+
name: cloudwatchlogs-leader-election-role
11+
subjects:
12+
- kind: ServiceAccount
13+
name: ack-cloudwatchlogs-controller
14+
namespace: ack-system

config/rbac/leader-election-role.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
name: cloudwatchlogs-leader-election-role
6+
namespace: ack-system
7+
rules:
8+
- apiGroups:
9+
- coordination.k8s.io
10+
resources:
11+
- leases
12+
verbs:
13+
- get
14+
- list
15+
- watch
16+
- create
17+
- update
18+
- patch
19+
- delete
20+
- apiGroups:
21+
- ""
22+
resources:
23+
- events
24+
verbs:
25+
- create
26+
- patch

0 commit comments

Comments
 (0)