`publish --delete-unmatched` (full publish) does not remove child resources, and does not protect the built-in `master` subscription

Đang mở
#342 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
azure, github-actions, javascript, node.js, typescript
Lĩnh vực
cli, cloud, devops

Hướng nghiên cứu

Start in services/delete-unmatched-service.js at computeDeleteActions, which lists deployed resources per type with listResources and silently swallows errors for child types that need a parent. Check isSystemResource for where the built-in master subscription (scope /) should be excluded. Done when child resources missing from the artifact folder yield DELETE actions in a dry-run, and master is never listed as DELETE, with tests covering both cases.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

With apiops-cli 1.0.5, a full apiops publish --delete-unmatched (no --commit-id) only reconciles top-level resources (and managed-gateway API assignments). Child resources that exist in APIM but not in the artifact folder are never deleted. Separately, the built-in master subscription is not treated as a system resource, so it is deleted when its file is absent.

1. Child resources are not reconciled

Steps to reproduce
  1. Publish an artifact folder that contains an API with an API-level policy (apis/<api>/policy.xml) and a product with an API link (products/<p>/apis.json).
  2. Remove apis/<api>/policy.xml and the API from products/<p>/apis.json.
  3. Run apiops publish --delete-unmatched --dry-run, then without --dry-run.
Expected

The API policy and the product–API link are listed as DELETE and removed, so APIM matches the artifact folder (as with top-level resources).

Actual

No DELETE actions are produced for them; both remain in APIM.

Analysis

computeDeleteActions (services/delete-unmatched-service.js) lists deployed resources per resource type via listResources. For child types (ApiPolicy, ApiOperationPolicy, ProductPolicy, ApiDiagnostic, ApiSchema, ProductApi, ProductGroup, ApiTagDescription, …) the list path needs a parent, so the call throws and the error is swallowed; those types are silently skipped. Incremental mode (--commit-id) does delete children whose files were removed in that commit, but full publish – the mode needed to redeploy an older revision (rollback) – does not.

Impact
  • Removing a policy/diagnostic/link from Git has no effect in APIM.
  • Redeploying an older revision leaves child resources that were added later.
  • The dry-run gives no indication of this.
Suggestion

For each deployed parent (API, product, operation, …), enumerate its children and compare them with the artifact folder; at minimum, warn in the dry-run/publish output that child resources are not reconciled.

2. master subscription is not protected

isSystemResource covers the built-in products/APIs (starter, unlimited, echo-api, …) and built-in groups, but not the built-in master subscription (scope /). Publish already skips root-scoped subscriptions, but with --delete-unmatched the master subscription is listed as DELETE when subscriptions/master is not present in the artifact folder. Expected: treat it as a system resource, like the other built-ins.

Environment

  • @azure-tools/apiops-cli 1.0.5, Node.js 22, GitHub Actions (ubuntu-latest) and Windows.

Possibly related: #142, #169.

Ngôn ngữ chính
TypeScript
Star
44
Fork
14
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Azure/apiops-cli

Tất cả issue của Azure/apiops-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.