Repository navigation
Conversation
Pull Request 요약VM 방화벽 맞추기 엔드포인트와 Proxmox 방화벽 API 연동을 구현하고, 작업 관리자의 Unfinished 조회 기능을 추가하여 동일 VM에 대한 요청을 순차 처리하도록 했습니다. 이에 따라 firewall 서비스와 Proxmox 클라이언트 인터페이스, 가짜 구현이 보강되었으며, 규칙은 ID 기준으로 삭제·삽입하도록 수정되었습니다. 테스트 헬퍼 vmAPI의 누락된 설정 필드가 보완되어 컴파일 오류와 테스트 실패가 해결되고, 관련 테스트가 강화되었습니다. 복수 모델 · 입력 128,526 · 출력 12,911 · 합계 141,437 토큰 |
| jobs := job.NewManager(time.Now) | ||
| vms := vm.New(px, jobs, netip.MustParsePrefix("192.0.2.0/24")) | ||
| return api.New(api.Config{Secret: secret, Fake: true, Jobs: jobs, VMs: vms, Nodes: node.New(px, vms.CloneQueue, time.Now)}) | ||
| return api.New(api.Config{ |
There was a problem hiding this comment.
중요 vmAPI의 api.Config 필드 누락으로 컴파일 실패와 테스트 패닉 발생
vmAPI가 api.Config에 Secret만 넣고 Fake, Jobs, VMs, Nodes를 누락했습니다. jobs와 vms는 선언만 되어 실제 사용되지 않아 Go에서 declared and not used 컴파일 오류가 발생합니다. 컴파일이 통과하더라도 Fake, Jobs, VMs, Nodes, Firewall이 nil이므로 해당 헬퍼를 사용하는 모든 테스트가 실패하거나 패닉합니다. 헬퍼는 api_test 패키지 전체에서 사용되므로 이 패키지의 테스트 전체에 영향을 미칩니다.
복수 모델
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PUT /network/vms/{vm_id}/firewall(명세 syncVmFirewall): VM 방화벽의 켜짐 여부와 규칙 전체를 받아 맞춘다. 멱등 키 없이 동기로 200{ applied, added, removed }를 준다id로만 비교한다. 목록에 없는 id는 지우고(removed), 없는 id는 목록에서의 자리에 넣는다(added). 같은 본문을 다시 보내면 둘 다 0이다ACCEPT)은 매번 쓴다. 규칙 개수는 세지 않는다UPSTREAM_TIMEOUT이다INVALID_REQUEST의details.fields[]에 모두 담는다. VM이 없으면 404, 닿지 않는 노드가 있으면 503, 만들거나 지우는 중이거나 Proxmox 잠금이 걸렸으면 409INVALID_STATE다enabled: false,rules: [])은 VM이 이미 없어도 200이다 (VM 삭제 뒤 다시 보내도 같은 결과)internal/proxmox:Firewall·SetFirewallEnabled·AddFirewallRule·DeleteFirewallRule을 더했다. Proxmox 방화벽 API가 규칙을 하나씩 넣고 지우는 모양이라 같은 모양으로 두었고, 차이 계산은internal/firewall에서 한 번만 한다. 가짜 구현은 규칙을 메모리에 두고 VM을 지우면 함께 지운다job.Manager.Unfinished: 그 자원에 끝나지 않은 작업이 있는지(종류로 거를 수 있다) 본다정한 것
fwrule-id)만 다룬다. 사람이 Proxmox에서 직접 넣은 규칙은 id가 없어 비교할 수 없어서 지우지 않는다 (스냅샷에서 직접 만든 것을 빼는 것과 같다). 명세의 "목록에 없는 이 VM의 규칙은 지운다"를 id 기준으로 읽었다dport는 앞쪽 0을 떼서 넘긴다 (0080→80).source는 IP나 CIDR만 받고 구역(%eth0)·목록·옵션 문자열은 400이다. 둘 다 가상화 서버 명령의 인자로 넘어간다field는rules[0].dport처럼 적고,icmp에dport가 오면reason은not_allowed다. 명세에 목록 안 칸의 이름과 이 이유의 값이 없어서 정했다rules[0].dport로 통일했다.encoding/json은rules.0.dport로 적어서, 숫자로 잘못 보낸dport만 다른 검사와 이름이 달랐다남긴 것
shortcut:주석). 규칙이 많으면 Proxmox 호출이 한 개씩이라 본문 한도보다 5초 시간 제한에 먼저 닿고, 매번 일부가 반영되니 다시 보내면 맞춰진다shortcut:주석). Server는 만든 순서로만 보내고 규칙 값은 바뀌지 않아서 생기지 않는다shortcut:주석)source는::ffff:1.2.3.4(IPv4를 담은 IPv6)와 호스트 비트가 남은 CIDR(203.0.113.5/24)도 받는다. 진짜 Proxmox가 받는지는 실제 클라이언트(③)에서 본다INTERNAL로 남는다. 다른 엔드포인트도 같다 (이 PR 밖,job.Cause)Test plan
gofmt -l .출력 없음,go vet ./...,go build ./...,go test -race ./...통과 (커밋마다 따로 풀어서 확인)added: 3, 같은 본문 다시0/0, 가운데만 남기면removed: 2, 켜짐 여부만 바꾸면 규칙 그대로, 빈 목록은 모두 지움icmp포트 허용, 앞쪽 0 그대로, 기다리기에서 시간 제한 무시). 모두 테스트가 잡았다added: 3, 다시 보내기0/0, 가운데만 남기기removed: 2, 틀린 본문 400,X-Fake-Fail503, 인증 없이 401, 지우는 중 409, 지운 뒤 200·404관련 이슈
Closes #17
확인