Skip to content

Commit e592c6e

Browse files
authored
Merge pull request #580 from kumargauravsharma/ec-main-snapshot-fixes
Fixes for Snapshot failures
2 parents 4a9bf0c + d3642a8 commit e592c6e

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

pkg/runtime/reconciler.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ func (r *reconciler) sync(
156156

157157
latest, err := rm.ReadOne(ctx, desired)
158158
if err != nil {
159-
if latest != nil {
160-
// this indicates, that even though ReadOne failed
161-
// there is some changes available in the latest.RuntimeObject()
162-
// (example: ko.Status.Conditions) which have been
163-
// updated in the resource
164-
// Thus, patchResource() call should be made here
165-
_ = r.patchResource(ctx, desired, latest)
166-
}
167159
if err != ackerr.NotFound {
160+
if latest != nil {
161+
// this indicates, that even though ReadOne failed
162+
// there is some changes available in the latest.RuntimeObject()
163+
// (example: ko.Status.Conditions) which have been
164+
// updated in the resource
165+
// Thus, patchResource() call should be made here
166+
_ = r.patchResource(ctx, desired, latest)
167+
}
168168
return err
169169
}
170170
if isAdopted {

services/elasticache/pkg/resource/snapshot/custom_update_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ func (rm *resourceManager) customUpdateSnapshot(
2525
latest *resource,
2626
diffReporter *ackcompare.Reporter,
2727
) (*resource, error) {
28-
return desired, nil
28+
return latest, nil
2929
}

test/e2e/elasticache/snapshot/e2e.sh

100644100755
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ spec:
7373
EOF)
7474
echo "$snapshot_yaml" | kubectl apply -f -
7575
assert_equal "0" "$?" "Expected application of $copied_snapshot_name to succeed" || exit 1
76-
k8s_wait_resource_synced "snapshots/$snapshot_name" 10
76+
k8s_wait_resource_synced "snapshots/$copied_snapshot_name" 10
7777
7878
# test deletion
7979
kubectl delete snapshots/"$snapshot_name"
@@ -126,7 +126,7 @@ EOF)
126126
kubectl delete snapshots/"$snapshot_name"
127127
aws_wait_snapshot_deleted "$snapshot_name"
128128
129-
# case 2: specify both RG and cache cluster ID (should succeed)
129+
# case 2: specify cache cluster ID (should succeed)
130130
local snapshot_name="snapshot-cmd"
131131
daws elasticache delete-snapshot --snapshot-name "$snapshot_name" 1>/dev/null 2>&1
132132
sleep 10
@@ -138,7 +138,6 @@ metadata:
138138
name: $snapshot_name
139139
spec:
140140
snapshotName: $snapshot_name
141-
replicationGroupID: $rg_id
142141
cacheClusterID: $cc_id
143142
EOF)
144143
echo "$snapshot_yaml" | kubectl apply -f -
@@ -192,24 +191,24 @@ EOF)
192191
kubectl delete snapshots/"$snapshot_name"
193192
aws_wait_snapshot_deleted "$snapshot_name"
194193
195-
# case 2: specify both RG and cache cluster ID
194+
# case 2: specify cache cluster ID should fail with error
196195
local snapshot_name="snapshot-cme"
197196
daws elasticache delete-snapshot --snapshot-name "$snapshot_name" 1>/dev/null 2>&1
198197
sleep 10
199-
local cc_id="$rg_id-001"
198+
local cc_id="$rg_id-0001-001" # Replication group has two node group, picking first node group.
200199
local snapshot_yaml=$(cat <<EOF
201200
apiVersion: elasticache.services.k8s.aws/v1alpha1
202201
kind: Snapshot
203202
metadata:
204203
name: $snapshot_name
205204
spec:
206205
snapshotName: $snapshot_name
207-
replicationGroupID: $rg_id
208206
cacheClusterID: $cc_id
209207
EOF)
210208
echo "$snapshot_yaml" | kubectl apply -f -
211209
assert_equal "0" "$?" "Expected application of $snapshot_name to succeed" || exit 1
212-
k8s_wait_resource_synced "snapshots/$snapshot_name" 10
210+
sleep 35 # give time for server validation
211+
k8s_check_resource_terminal_condition_true "snapshots/$snapshot_name" "Cannot snapshot a cache cluster with cluster-mode enabled. Please specify a replication group instead"
213212
214213
# delete snapshot for case 2 if creation succeeded
215214
kubectl delete snapshots/"$snapshot_name"

0 commit comments

Comments
 (0)