@synopackageland/cli 0.3.10 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +57 -9
- package/dist/bin.js +1 -2
- package/dist/build-spk/generator.d.ts +0 -3
- package/dist/build-spk/generator.js +138 -287
- package/dist/build-spk/native-lifecycle.js +0 -3
- package/dist/build-spk/native-payload.js +0 -1
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +178 -151
- package/dist/compose/analyze.d.ts +1 -2
- package/dist/compose/analyze.js +5 -48
- package/dist/contract/unsupported-types.d.ts +10 -0
- package/dist/contract/unsupported-types.js +49 -0
- package/dist/contract/validate.js +25 -2
- package/dist/contract/web-launch.js +0 -2
- package/dist/deploy/deploy.d.ts +1 -4
- package/dist/deploy/deploy.js +45 -156
- package/dist/deploy/homes-values.js +1 -1
- package/dist/deploy/plan.d.ts +18 -0
- package/dist/deploy/plan.js +54 -0
- package/dist/deploy/spk-version.d.ts +2 -14
- package/dist/deploy/spk-version.js +25 -111
- package/dist/dev.d.ts +1 -3
- package/dist/dev.js +14 -28
- package/dist/error-registry.js +830 -862
- package/dist/host/dsm-client.js +12 -272
- package/dist/host/dsm-port-profile.d.ts +0 -1
- package/dist/host/dsm-port-profile.js +0 -2
- package/dist/host/types.d.ts +1 -83
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -6
- package/dist/info.d.ts +0 -1
- package/dist/info.js +3 -10
- package/dist/init.d.ts +15 -1
- package/dist/init.js +128 -12
- package/dist/log.js +2 -3
- package/dist/native/validate.js +0 -1
- package/dist/standalone/binary.d.ts +9 -0
- package/dist/standalone/binary.js +67 -0
- package/dist/standalone/build.d.ts +25 -0
- package/dist/standalone/build.js +110 -0
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +26 -0
- package/dist/standalone/dsm-window.js +291 -0
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +21 -0
- package/dist/standalone/helper.js +105 -0
- package/dist/standalone/host-adapter.d.ts +5 -0
- package/dist/standalone/host-adapter.js +148 -0
- package/dist/standalone/host-platform.d.ts +13 -0
- package/dist/standalone/host-platform.js +42 -0
- package/dist/standalone/host-types.d.ts +49 -0
- package/dist/standalone/host-types.js +1 -0
- package/dist/standalone/i18n.d.ts +28 -0
- package/dist/standalone/i18n.js +161 -0
- package/dist/standalone/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +23 -0
- package/dist/standalone/inspect-spk.js +209 -0
- package/dist/standalone/lifecycle-helper.d.ts +2 -0
- package/dist/standalone/lifecycle-helper.js +12 -0
- package/dist/standalone/lifecycle.d.ts +3 -0
- package/dist/standalone/lifecycle.js +53 -0
- package/dist/standalone/manifest.d.ts +73 -0
- package/dist/standalone/manifest.js +279 -0
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.d.ts +7 -0
- package/dist/standalone/root-messages.js +259 -0
- package/dist/standalone/root-ops.d.ts +42 -0
- package/dist/standalone/root-ops.js +101 -0
- package/dist/standalone/root-window.d.ts +36 -0
- package/dist/standalone/root-window.js +302 -0
- package/dist/standalone/spk.d.ts +23 -0
- package/dist/standalone/spk.js +192 -0
- package/dist/template-paths.d.ts +2 -0
- package/dist/template-paths.js +9 -0
- package/dist/templates/_daemon/fixture_linux_test.go +15 -0
- package/dist/templates/_daemon/fixture_other_test.go +7 -0
- package/dist/templates/_daemon/go.mod +3 -0
- package/dist/templates/_daemon/main.go +608 -0
- package/dist/templates/_daemon/main_test.go +242 -0
- package/dist/templates/_daemon/process_linux.go +55 -0
- package/dist/templates/_daemon/process_linux_test.go +161 -0
- package/dist/templates/_daemon/process_other.go +14 -0
- package/dist/templates/_daemon/testdata/child.go +41 -0
- package/dist/templates/_shared/GO-LICENSE +27 -0
- package/dist/templates/_shared/GO-PATENTS +22 -0
- package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/dist/templates/_shared/notice-overrides/index.json +14 -0
- package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/dist/templates/_shared/third-party-notices.mjs +51 -0
- package/dist/templates/binary/synology-app.yaml +7 -0
- package/dist/templates/hello-files/compose.yaml +0 -1
- package/dist/templates/hello-web/compose.yaml +13 -10
- package/dist/templates/hello-web/html/app.js +1 -23
- package/dist/templates/hello-web/html/index.html +1 -3
- package/dist/templates/hello-web-page/compose.yaml +13 -10
- package/dist/templates/hello-web-page/html/app.js +1 -23
- package/dist/templates/hello-web-page/html/index.html +1 -3
- package/dist/templates/native-go/README.md +324 -0
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/app/main.go +49 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/dist/templates/native-go/backend/go.mod +7 -0
- package/dist/templates/native-go/backend/go.sum +4 -0
- package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
- package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/dist/templates/native-go/backend/internal/api/errors.go +33 -0
- package/dist/templates/native-go/backend/internal/api/registry.go +104 -0
- package/dist/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/dist/templates/native-go/backend/internal/api/server.go +159 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/dist/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +138 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +172 -0
- package/dist/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/dist/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/control.go +424 -0
- package/dist/templates/native-go/backend/internal/helper/control_test.go +250 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/dist/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/status.go +334 -0
- package/dist/templates/native-go/backend/internal/helper/status_test.go +288 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/dist/templates/native-go/dsm-package.yaml +58 -0
- package/dist/templates/native-go/gitignore +1 -0
- package/dist/templates/native-go/i18n/glossary.json +662 -0
- package/dist/templates/native-go/i18n/messages/de.json +28 -0
- package/dist/templates/native-go/i18n/messages/en.json +28 -0
- package/dist/templates/native-go/i18n/messages/es.json +28 -0
- package/dist/templates/native-go/i18n/messages/fr.json +28 -0
- package/dist/templates/native-go/i18n/messages/it.json +28 -0
- package/dist/templates/native-go/i18n/messages/ja.json +28 -0
- package/dist/templates/native-go/i18n/messages/ko.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/dist/templates/native-go/ui/app.css +35 -0
- package/dist/templates/native-go/ui/app.js +101 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/dist/templates/native-go-better-auth/node/app.mjs +72 -0
- package/dist/templates/native-go-better-auth/node/build.mjs +4 -0
- package/dist/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/dist/templates/native-go-better-auth/node/package.json +1 -0
- package/dist/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/dist/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/dist/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/dist/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/dist/templates/native-go-root/root/whoami.sh +6 -0
- package/dist/templates/native-go-vue/README.md +224 -0
- package/dist/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +2410 -0
- package/dist/templates/native-go-vue/frontend/package.json +6 -0
- package/dist/templates/native-go-vue/frontend/src/App.vue +159 -0
- package/dist/templates/native-go-vue/frontend/src/context.ts +56 -0
- package/dist/templates/native-go-vue/frontend/src/main.ts +29 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +31 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
- package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/dist/templates/native-go-vue/frontend/vite.config.ts +10 -0
- package/dist/templates/native-go-vue/gitignore +2 -0
- package/dist/types.d.ts +1 -1
- package/dist/validate.js +11 -7
- package/package.json +5 -8
- package/schema/synology-app.schema.json +36 -37
- package/skills/SKILL.md +4 -48
- package/skills/reference/create.md +11 -83
- package/skills/reference/deploy.md +7 -78
- package/skills/reference/diagnose.md +4 -101
- package/skills/reference/files.md +5 -41
- package/skills/reference/identity.md +3 -29
- package/skills/reference/wrap.md +0 -2
- package/templates/_daemon/fixture_linux_test.go +15 -0
- package/templates/_daemon/fixture_other_test.go +7 -0
- package/templates/_daemon/go.mod +3 -0
- package/templates/_daemon/main.go +608 -0
- package/templates/_daemon/main_test.go +242 -0
- package/templates/_daemon/process_linux.go +55 -0
- package/templates/_daemon/process_linux_test.go +161 -0
- package/templates/_daemon/process_other.go +14 -0
- package/templates/_daemon/testdata/child.go +41 -0
- package/templates/_shared/GO-LICENSE +27 -0
- package/templates/_shared/GO-PATENTS +22 -0
- package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/templates/_shared/notice-overrides/index.json +14 -0
- package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/templates/_shared/third-party-notices.mjs +51 -0
- package/templates/binary/synology-app.yaml +7 -0
- package/templates/hello-files/compose.yaml +0 -1
- package/templates/hello-web/compose.yaml +13 -10
- package/templates/hello-web/html/app.js +1 -23
- package/templates/hello-web/html/index.html +1 -3
- package/templates/hello-web-page/compose.yaml +13 -10
- package/templates/hello-web-page/html/app.js +1 -23
- package/templates/hello-web-page/html/index.html +1 -3
- package/templates/native-go/README.md +324 -0
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/app/main.go +49 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/templates/native-go/backend/go.mod +7 -0
- package/templates/native-go/backend/go.sum +4 -0
- package/templates/native-go/backend/internal/api/binary.go +154 -0
- package/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/templates/native-go/backend/internal/api/errors.go +33 -0
- package/templates/native-go/backend/internal/api/registry.go +104 -0
- package/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/templates/native-go/backend/internal/api/server.go +159 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/templates/native-go/backend/internal/app/routes.go +138 -0
- package/templates/native-go/backend/internal/app/routes_test.go +172 -0
- package/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/templates/native-go/backend/internal/helper/control.go +424 -0
- package/templates/native-go/backend/internal/helper/control_test.go +250 -0
- package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +177 -0
- package/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +124 -0
- package/templates/native-go/backend/internal/helper/status.go +334 -0
- package/templates/native-go/backend/internal/helper/status_test.go +288 -0
- package/templates/native-go/backend/internal/helper/supervision.go +107 -0
- package/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/templates/native-go/backend/internal/helper/write.go +77 -0
- package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/templates/native-go/dsm-package.yaml +58 -0
- package/templates/native-go/gitignore +1 -0
- package/templates/native-go/i18n/glossary.json +662 -0
- package/templates/native-go/i18n/messages/de.json +28 -0
- package/templates/native-go/i18n/messages/en.json +28 -0
- package/templates/native-go/i18n/messages/es.json +28 -0
- package/templates/native-go/i18n/messages/fr.json +28 -0
- package/templates/native-go/i18n/messages/it.json +28 -0
- package/templates/native-go/i18n/messages/ja.json +28 -0
- package/templates/native-go/i18n/messages/ko.json +28 -0
- package/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/templates/native-go/ui/app.css +35 -0
- package/templates/native-go/ui/app.js +101 -0
- package/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/templates/native-go-better-auth/node/app.mjs +72 -0
- package/templates/native-go-better-auth/node/build.mjs +4 -0
- package/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/templates/native-go-better-auth/node/package.json +1 -0
- package/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/templates/native-go-root/root/whoami.sh +6 -0
- package/templates/native-go-vue/README.md +224 -0
- package/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/templates/native-go-vue/frontend/package-lock.json +2410 -0
- package/templates/native-go-vue/frontend/package.json +6 -0
- package/templates/native-go-vue/frontend/src/App.vue +159 -0
- package/templates/native-go-vue/frontend/src/context.ts +56 -0
- package/templates/native-go-vue/frontend/src/main.ts +29 -0
- package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/templates/native-go-vue/frontend/src/style.css +31 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
- package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/templates/native-go-vue/frontend/vite.config.ts +10 -0
- package/templates/native-go-vue/gitignore +2 -0
- package/dist/attestation/app-package.d.ts +0 -86
- package/dist/attestation/app-package.js +0 -206
- package/dist/attestation/install-on-host.d.ts +0 -14
- package/dist/attestation/install-on-host.js +0 -52
- package/dist/attestation/keyring.d.ts +0 -21
- package/dist/attestation/keyring.js +0 -168
- package/dist/attestation/platform-service.d.ts +0 -70
- package/dist/attestation/platform-service.js +0 -250
- package/dist/build-spk/broker-glue.d.ts +0 -16
- package/dist/build-spk/broker-glue.js +0 -40
- package/dist/deploy/catalog-publish.d.ts +0 -3
- package/dist/deploy/catalog-publish.js +0 -7
- package/dist/doctor.d.ts +0 -22
- package/dist/doctor.js +0 -822
- package/dist/error-collector.d.ts +0 -2
- package/dist/error-collector.js +0 -46
- package/dist/host/broker-paths.d.ts +0 -1
- package/dist/host/broker-paths.js +0 -1
- package/dist/host/broker-upgrade-preflight.d.ts +0 -61
- package/dist/host/broker-upgrade-preflight.js +0 -156
- package/dist/host/digests.d.ts +0 -5
- package/dist/host/digests.js +0 -63
- package/dist/host/fake-nas.d.ts +0 -49
- package/dist/host/fake-nas.js +0 -193
- package/dist/mock-broker/bootstrap.d.ts +0 -2
- package/dist/mock-broker/bootstrap.js +0 -8
- package/dist/mock-broker/files.d.ts +0 -60
- package/dist/mock-broker/files.js +0 -408
- package/dist/mock-broker/oidc.d.ts +0 -31
- package/dist/mock-broker/oidc.js +0 -161
- package/dist/mock-broker/path.d.ts +0 -9
- package/dist/mock-broker/path.js +0 -50
- package/dist/mock-broker/server.d.ts +0 -19
- package/dist/mock-broker/server.js +0 -350
- package/dist/publish/build-ledger.d.ts +0 -22
- package/dist/publish/build-ledger.js +0 -26
- package/dist/publish/community-path.d.ts +0 -6
- package/dist/publish/community-path.js +0 -41
- package/dist/publish/curated-release.d.ts +0 -78
- package/dist/publish/curated-release.js +0 -883
- package/dist/publish/file-build-ledger.d.ts +0 -18
- package/dist/publish/file-build-ledger.js +0 -268
- package/dist/publish/github-pr.d.ts +0 -25
- package/dist/publish/github-pr.js +0 -85
- package/dist/publish/github-repo.d.ts +0 -8
- package/dist/publish/github-repo.js +0 -21
- package/dist/publish/platform-service-release.d.ts +0 -60
- package/dist/publish/platform-service-release.js +0 -333
- package/dist/publish/preflight.d.ts +0 -24
- package/dist/publish/preflight.js +0 -138
- package/dist/publish/publish.d.ts +0 -27
- package/dist/publish/publish.js +0 -136
- package/dist/publish/sync-definition.d.ts +0 -4
- package/dist/publish/sync-definition.js +0 -48
- package/dist/release-bin.d.ts +0 -2
- package/dist/release-bin.js +0 -23
- package/dist/templates/hello-web/html/sdk.js +0 -68
- package/dist/templates/hello-web-page/html/sdk.js +0 -68
- package/dist/templates/native/synology-app.yaml +0 -7
- package/dist/test-host.d.ts +0 -15
- package/dist/test-host.js +0 -37
- package/templates/hello-web/html/sdk.js +0 -68
- package/templates/hello-web-page/html/sdk.js +0 -68
- package/templates/native/synology-app.yaml +0 -7
- /package/dist/templates/{native → binary}/native.yaml +0 -0
- /package/templates/{native → binary}/native.yaml +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"testing"
|
|
7
|
+
"time"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
func TestReadinessPreservesAdmissionRefusal(t *testing.T) {
|
|
11
|
+
now := time.Now()
|
|
12
|
+
b := testBinding()
|
|
13
|
+
g := newAdmission(b)
|
|
14
|
+
g.observeUnit(b, 7, "", false, true, 0, now)
|
|
15
|
+
if g.readiness(now) != "ready" || !g.allow(now) {
|
|
16
|
+
t.Fatal("fresh readiness")
|
|
17
|
+
}
|
|
18
|
+
g.requestUnitCheck(true, now)
|
|
19
|
+
if g.readiness(now) != "reload-revalidating" || g.allow(now) {
|
|
20
|
+
t.Fatal("suspension must still refuse")
|
|
21
|
+
}
|
|
22
|
+
g.fence("unit-transition")
|
|
23
|
+
if g.readiness(now) != "fenced" || g.allow(now) {
|
|
24
|
+
t.Fatal("terminal refusal")
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
func TestPendingHealthBoundariesAndFencePrecedence(t *testing.T) {
|
|
29
|
+
now := time.Now()
|
|
30
|
+
b := testBinding()
|
|
31
|
+
fresh := func() *admission { g := newAdmission(b); g.observeUnit(b, 7, "", false, true, 0, now); return g }
|
|
32
|
+
t.Run("post-budget", func(t *testing.T) {
|
|
33
|
+
g := fresh()
|
|
34
|
+
g.requestUnitCheck(true, now)
|
|
35
|
+
g.requestUnitCheck(false, now.Add(9*time.Second))
|
|
36
|
+
if g.readiness(now.Add(11999*time.Millisecond)) != "reload-revalidating" || g.allow(now.Add(11999*time.Millisecond)) {
|
|
37
|
+
t.Fatal("post budget admission")
|
|
38
|
+
}
|
|
39
|
+
if g.readiness(now.Add(12*time.Second)) != "fenced" || g.observerDiagnostic("").Fence.Detail != "verification-deadline" {
|
|
40
|
+
t.Fatal("late health not fenced")
|
|
41
|
+
}
|
|
42
|
+
g.observeUnit(b, 7, "", false, true, g.unitSerial, now.Add(12*time.Second))
|
|
43
|
+
if g.readiness(now.Add(12*time.Second)) != "fenced" {
|
|
44
|
+
t.Fatal("sticky fence lost")
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
t.Run("reload-cap", func(t *testing.T) {
|
|
48
|
+
g := fresh()
|
|
49
|
+
g.requestUnitCheck(true, now)
|
|
50
|
+
if g.readiness(now.Add(9999*time.Millisecond)) != "reload-revalidating" {
|
|
51
|
+
t.Fatal("missing pending")
|
|
52
|
+
}
|
|
53
|
+
if g.readiness(now.Add(10*time.Second)) != "fenced" || g.observerDiagnostic("").Fence.Detail != "reload-deadline" {
|
|
54
|
+
t.Fatal("cap not enforced")
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
t.Run("unpaired-removal", func(t *testing.T) {
|
|
58
|
+
g := fresh()
|
|
59
|
+
g.requestUnitRemoval(now)
|
|
60
|
+
if g.readiness(now) != "fenced" || g.allow(now) {
|
|
61
|
+
t.Fatal("pending without reload boundary")
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
t.Run("success", func(t *testing.T) {
|
|
65
|
+
g := fresh()
|
|
66
|
+
g.requestUnitCheck(true, now)
|
|
67
|
+
g.requestUnitCheck(false, now.Add(4*time.Second))
|
|
68
|
+
serial, _ := g.unitProbe(now.Add(4500 * time.Millisecond))
|
|
69
|
+
g.observeUnit(b, 7, "", false, true, serial, now.Add(4500*time.Millisecond))
|
|
70
|
+
if g.readiness(now.Add(4500*time.Millisecond)) != "ready" || !g.allow(now.Add(4500*time.Millisecond)) {
|
|
71
|
+
t.Fatal("fresh snapshot not ready")
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
for _, reason := range []string{"unit-transition", "installation-changed", "owner-changed", "observation-unavailable", "helper-exited", "grant-authority-fenced"} {
|
|
75
|
+
t.Run(reason, func(t *testing.T) {
|
|
76
|
+
g := fresh()
|
|
77
|
+
g.requestUnitCheck(true, now)
|
|
78
|
+
g.fence(reason)
|
|
79
|
+
if g.readiness(now) != "fenced" || g.reason() != reason || g.allow(now) {
|
|
80
|
+
t.Fatal("pending hid terminal fence")
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
func TestPendingReplyNeverCertifiesAdmissionOrStop(t *testing.T) {
|
|
87
|
+
i := fixture(t).Expected
|
|
88
|
+
for _, tc := range []struct {
|
|
89
|
+
res Response
|
|
90
|
+
want string
|
|
91
|
+
}{
|
|
92
|
+
{Response{OK: true}, "ready"}, {Response{Error: "reload-revalidating"}, "reload-revalidating"},
|
|
93
|
+
{Response{OK: true, Error: "reload-revalidating"}, "fenced"}, {Response{Error: "fenced"}, "fenced"}, {Response{}, "fenced"},
|
|
94
|
+
} {
|
|
95
|
+
if got := supervisorReadiness(tc.res, nil); got != tc.want {
|
|
96
|
+
t.Fatalf("%+v -> %s", tc.res, got)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if supervisorReadiness(Response{Error: "reload-revalidating"}, errTrust) != "fenced" {
|
|
100
|
+
t.Fatal("untrusted refusal accepted")
|
|
101
|
+
}
|
|
102
|
+
res := Response{Inventory: i, Nonce: "nonce", Error: "reload-revalidating"}
|
|
103
|
+
data, _ := json.Marshal(res)
|
|
104
|
+
if readSupervisorReply(bytes.NewReader(data), i, "nonce") == nil {
|
|
105
|
+
t.Fatal("pending certified ACK")
|
|
106
|
+
}
|
|
107
|
+
for _, tc := range []struct {
|
|
108
|
+
data []byte
|
|
109
|
+
nonce string
|
|
110
|
+
}{{data, "replay"}, {append(data, []byte("{}")...), "nonce"}, {[]byte(`{"inventory":{}}`), "nonce"}} {
|
|
111
|
+
if _, err := decodeSupervisorReply(bytes.NewReader(tc.data), i, tc.nonce); err == nil {
|
|
112
|
+
t.Fatal("unauthenticated reply accepted")
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"testing"
|
|
5
|
+
"time"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
func TestReloadKeepsPostBoundaryVerificationBudget(t *testing.T) {
|
|
9
|
+
now := time.Now()
|
|
10
|
+
b := testBinding()
|
|
11
|
+
g := newAdmission(b)
|
|
12
|
+
g.observeUnit(b, 7, "", false, true, 0, now)
|
|
13
|
+
g.requestUnitCheck(true, now)
|
|
14
|
+
end := now.Add(2888 * time.Millisecond)
|
|
15
|
+
g.requestUnitCheck(false, end)
|
|
16
|
+
// 250ms watcher scheduling plus a 500ms query after a 2.888s reload.
|
|
17
|
+
serial, ready := g.unitProbe(end.Add(250 * time.Millisecond))
|
|
18
|
+
if !ready || g.fenced(end.Add(750*time.Millisecond)) {
|
|
19
|
+
t.Fatalf("reload consumed post budget: %s", g.reason())
|
|
20
|
+
}
|
|
21
|
+
g.observeUnit(b, 7, "", false, true, serial, end.Add(750*time.Millisecond))
|
|
22
|
+
if !g.allow(end.Add(750 * time.Millisecond)) {
|
|
23
|
+
t.Fatal("same v219 identity did not resume")
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
func TestReloadWindowsCannotBeExtended(t *testing.T) {
|
|
27
|
+
now := time.Now()
|
|
28
|
+
b := testBinding()
|
|
29
|
+
fresh := func() *admission { g := newAdmission(b); g.observeUnit(b, 7, "", false, true, 0, now); return g }
|
|
30
|
+
t.Run("fixed-reload", func(t *testing.T) {
|
|
31
|
+
g := fresh()
|
|
32
|
+
g.requestUnitCheck(true, now)
|
|
33
|
+
for n := 1; n < 10; n++ {
|
|
34
|
+
g.requestUnitCheck(true, now.Add(time.Duration(n)*time.Second))
|
|
35
|
+
g.requestUnitRemoval(now.Add(time.Duration(n) * time.Second))
|
|
36
|
+
if g.fenced(now.Add(time.Duration(n)*time.Second)) || g.allow(now) {
|
|
37
|
+
t.Fatal("premature fence or admission")
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if !g.fenced(now.Add(10*time.Second)) || g.observerDiagnostic("").Fence.Detail != "reload-deadline" {
|
|
41
|
+
t.Fatal("reload cap extended")
|
|
42
|
+
}
|
|
43
|
+
g.requestUnitCheck(false, now.Add(10*time.Second))
|
|
44
|
+
if g.reason() == "" {
|
|
45
|
+
t.Fatal("late false erased fence")
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
t.Run("fixed-post", func(t *testing.T) {
|
|
49
|
+
g := fresh()
|
|
50
|
+
g.requestUnitCheck(true, now)
|
|
51
|
+
end := now.Add(4 * time.Second)
|
|
52
|
+
g.requestUnitCheck(false, end)
|
|
53
|
+
g.requestUnitCheck(false, end.Add(2*time.Second))
|
|
54
|
+
g.requestUnitRemoval(end.Add(2500 * time.Millisecond))
|
|
55
|
+
if !g.fenced(end.Add(3*time.Second)) || g.observerDiagnostic("").Fence.Detail != "verification-deadline" {
|
|
56
|
+
t.Fatal("duplicate false/removal extended post verification")
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
t.Run("no-reload", func(t *testing.T) {
|
|
60
|
+
g := fresh()
|
|
61
|
+
g.requestUnitRemoval(now)
|
|
62
|
+
g.requestUnitCheck(false, now.Add(2*time.Second))
|
|
63
|
+
if !g.fenced(now.Add(3 * time.Second)) {
|
|
64
|
+
t.Fatal("unmatched false extended removal budget")
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
t.Run("chatter-total", func(t *testing.T) {
|
|
68
|
+
g := fresh()
|
|
69
|
+
g.requestUnitCheck(true, now)
|
|
70
|
+
g.requestUnitCheck(false, now.Add(9*time.Second))
|
|
71
|
+
g.requestUnitCheck(true, now.Add(9500*time.Millisecond))
|
|
72
|
+
g.requestUnitCheck(false, now.Add(9900*time.Millisecond))
|
|
73
|
+
if g.allow(now.Add(12900*time.Millisecond)) || !g.fenced(now.Add(13*time.Second)) {
|
|
74
|
+
t.Fatal("cycle bought extra budget")
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
t.Run("chatter-late-true", func(t *testing.T) {
|
|
78
|
+
g := fresh()
|
|
79
|
+
g.requestUnitCheck(true, now)
|
|
80
|
+
g.requestUnitCheck(false, now.Add(9*time.Second))
|
|
81
|
+
g.requestUnitCheck(true, now.Add(11*time.Second))
|
|
82
|
+
if !g.fenced(now.Add(11 * time.Second)) {
|
|
83
|
+
t.Fatal("new true bought a new cap")
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
func TestRemovalBeforeReloadStillHasAbsoluteCycleBound(t *testing.T) {
|
|
89
|
+
now := time.Now()
|
|
90
|
+
g := newAdmission(testBinding())
|
|
91
|
+
g.observeUnit(testBinding(), 7, "", false, true, 0, now)
|
|
92
|
+
g.requestUnitRemoval(now)
|
|
93
|
+
g.requestUnitCheck(true, now.Add(2900*time.Millisecond))
|
|
94
|
+
g.requestUnitCheck(false, now.Add(12*time.Second))
|
|
95
|
+
if !g.fenced(now.Add(13 * time.Second)) {
|
|
96
|
+
t.Fatal("early removal bought extra pending time")
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
func TestSuccessfulReloadStartsIndependentNextCycle(t *testing.T) {
|
|
101
|
+
now := time.Now()
|
|
102
|
+
b := testBinding()
|
|
103
|
+
g := newAdmission(b)
|
|
104
|
+
g.observeUnit(b, 7, "", false, true, 0, now)
|
|
105
|
+
for _, start := range []time.Time{now, now.Add(5 * time.Second)} {
|
|
106
|
+
g.requestUnitCheck(true, start)
|
|
107
|
+
g.requestUnitCheck(false, start.Add(4*time.Second))
|
|
108
|
+
serial, ready := g.unitProbe(start.Add(4500 * time.Millisecond))
|
|
109
|
+
if !ready {
|
|
110
|
+
t.Fatal("next cycle inherited expired cap")
|
|
111
|
+
}
|
|
112
|
+
g.observeUnit(b, 7, "", false, true, serial, start.Add(4500*time.Millisecond))
|
|
113
|
+
if !g.allow(start.Add(4500 * time.Millisecond)) {
|
|
114
|
+
t.Fatal("same identity rejected in fresh cycle")
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"testing"
|
|
5
|
+
"time"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
func TestObservationEdgesAreSticky(t *testing.T) {
|
|
9
|
+
g := newAdmission(testBinding())
|
|
10
|
+
now := time.Now()
|
|
11
|
+
g.observe(testBinding(), 7, true, now)
|
|
12
|
+
if !g.allow(now) {
|
|
13
|
+
t.Fatal("active refused")
|
|
14
|
+
}
|
|
15
|
+
g.observe(testBinding(), 7, true, now.Add(time.Millisecond))
|
|
16
|
+
if !g.allow(now) {
|
|
17
|
+
t.Fatal("same active update fenced")
|
|
18
|
+
}
|
|
19
|
+
g.fence("unit-stopped")
|
|
20
|
+
g.observe(testBinding(), 8, true, now.Add(time.Millisecond))
|
|
21
|
+
if g.allow(now) || g.reason() != "unit-stopped" {
|
|
22
|
+
t.Fatal("Stop/Start erased edge")
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
func TestObservationFreshnessAndInvocationRejectMissedTransitions(t *testing.T) {
|
|
26
|
+
for _, kind := range []string{"stale", "invocation", "install", "query"} {
|
|
27
|
+
t.Run(kind, func(t *testing.T) {
|
|
28
|
+
g := newAdmission(testBinding())
|
|
29
|
+
now := time.Now()
|
|
30
|
+
g.observe(testBinding(), 7, true, now)
|
|
31
|
+
switch kind {
|
|
32
|
+
case "stale":
|
|
33
|
+
now = now.Add(2 * time.Second)
|
|
34
|
+
case "invocation":
|
|
35
|
+
g.observe(testBinding(), 8, true, now)
|
|
36
|
+
case "install":
|
|
37
|
+
g.observe(Binding{Boot: "different", Install: testBinding().Install}, 7, true, now)
|
|
38
|
+
case "query":
|
|
39
|
+
g.observe(testBinding(), 7, false, now)
|
|
40
|
+
}
|
|
41
|
+
if g.allow(now) {
|
|
42
|
+
t.Fatal("untrusted observation admitted")
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
func TestReloadVerificationDeniesUntilFreshSnapshot(t *testing.T) {
|
|
49
|
+
b := testBinding()
|
|
50
|
+
g := newAdmission(b)
|
|
51
|
+
now := time.Now()
|
|
52
|
+
g.observe(b, 7, true, now)
|
|
53
|
+
g.requestUnitCheck(true, now)
|
|
54
|
+
if g.allow(now) || g.fenced(now) {
|
|
55
|
+
t.Fatal("reload must suspend, not permanently fence")
|
|
56
|
+
}
|
|
57
|
+
token, ready := g.unitProbe(now)
|
|
58
|
+
if ready {
|
|
59
|
+
t.Fatal("must wait for Reloading(false)")
|
|
60
|
+
}
|
|
61
|
+
g.requestUnitCheck(false, now.Add(time.Millisecond))
|
|
62
|
+
g.observeUnit(b, 7, "id", true, true, token, now.Add(2*time.Millisecond))
|
|
63
|
+
if g.allow(now) {
|
|
64
|
+
t.Fatal("pre-boundary snapshot cleared suspension")
|
|
65
|
+
}
|
|
66
|
+
token, ready = g.unitProbe(now)
|
|
67
|
+
if !ready {
|
|
68
|
+
t.Fatal("verification not scheduled")
|
|
69
|
+
}
|
|
70
|
+
g.observeUnit(b, 7, "id", true, true, token, now.Add(3*time.Millisecond))
|
|
71
|
+
if !g.allow(now.Add(3*time.Millisecond)) || g.binding.Entered != 7 {
|
|
72
|
+
t.Fatal("verified same epoch refused")
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
func TestReloadBudgetIsFixedAndFenceIsSticky(t *testing.T) {
|
|
76
|
+
b := testBinding()
|
|
77
|
+
g := newAdmission(b)
|
|
78
|
+
now := time.Now()
|
|
79
|
+
g.observe(b, 7, true, now)
|
|
80
|
+
g.requestUnitCheck(true, now)
|
|
81
|
+
for n := 1; n < 5; n++ {
|
|
82
|
+
g.requestUnitCheck(true, now.Add(time.Duration(n)*time.Second/2))
|
|
83
|
+
}
|
|
84
|
+
if !g.fenced(now.Add(unitReloadBudget)) || g.reason() != "observation-unavailable" {
|
|
85
|
+
t.Fatal("reload extended deadline")
|
|
86
|
+
}
|
|
87
|
+
g.requestUnitCheck(false, now.Add(unitReloadBudget))
|
|
88
|
+
token, _ := g.unitProbe(now)
|
|
89
|
+
g.observeUnit(b, 7, "", false, true, token, now.Add(unitReloadBudget))
|
|
90
|
+
if g.allow(now) {
|
|
91
|
+
t.Fatal("late snapshot erased timeout fence")
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
func TestReloadRejectsChangedIdentityAndStopEdges(t *testing.T) {
|
|
95
|
+
for _, kind := range []string{"timestamp", "invocation", "missing-invocation", "new-invocation", "inactive", "install", "boot", "stop", "query", "disconnect", "owner"} {
|
|
96
|
+
t.Run(kind, func(t *testing.T) {
|
|
97
|
+
b := testBinding()
|
|
98
|
+
g := newAdmission(b)
|
|
99
|
+
now := time.Now()
|
|
100
|
+
initialInv, initialPresent := "id", true
|
|
101
|
+
if kind == "new-invocation" {
|
|
102
|
+
initialInv, initialPresent = "", false
|
|
103
|
+
}
|
|
104
|
+
g.observeUnit(b, 7, initialInv, initialPresent, true, 0, now)
|
|
105
|
+
g.requestUnitCheck(true, now)
|
|
106
|
+
g.requestUnitCheck(false, now)
|
|
107
|
+
token, _ := g.unitProbe(now)
|
|
108
|
+
entered, inv, present, active := uint64(7), "id", true, true
|
|
109
|
+
switch kind {
|
|
110
|
+
case "timestamp":
|
|
111
|
+
entered = 8
|
|
112
|
+
case "invocation":
|
|
113
|
+
inv = "new"
|
|
114
|
+
case "missing-invocation":
|
|
115
|
+
present = false
|
|
116
|
+
case "new-invocation":
|
|
117
|
+
// The initial snapshot had no InvocationID property.
|
|
118
|
+
case "inactive":
|
|
119
|
+
active = false
|
|
120
|
+
case "install":
|
|
121
|
+
b.Install = "new"
|
|
122
|
+
case "boot":
|
|
123
|
+
b.Boot = "new"
|
|
124
|
+
case "stop":
|
|
125
|
+
g.fence("unit-stopped")
|
|
126
|
+
case "query", "disconnect":
|
|
127
|
+
g.fence("observation-unavailable")
|
|
128
|
+
case "owner":
|
|
129
|
+
g.fence("bus-owner-changed")
|
|
130
|
+
}
|
|
131
|
+
g.observeUnit(b, entered, inv, present, active, token, now)
|
|
132
|
+
g.observeUnit(testBinding(), 7, "id", true, true, token, now)
|
|
133
|
+
if g.allow(now) || !g.fenced(now) {
|
|
134
|
+
t.Fatal("transition erased by reload snapshot")
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
func TestRemovalWithoutReloadStillRequiresVerification(t *testing.T) {
|
|
140
|
+
b := testBinding()
|
|
141
|
+
g := newAdmission(b)
|
|
142
|
+
now := time.Now()
|
|
143
|
+
g.observeUnit(b, 7, "", false, true, 0, now)
|
|
144
|
+
g.requestUnitCheck(false, now)
|
|
145
|
+
if g.allow(now) || g.fenced(now) {
|
|
146
|
+
t.Fatal("unit removal directly admitted or fenced")
|
|
147
|
+
}
|
|
148
|
+
token, ready := g.unitProbe(now)
|
|
149
|
+
if !ready {
|
|
150
|
+
t.Fatal("missing bounded probe")
|
|
151
|
+
}
|
|
152
|
+
g.observeUnit(b, 7, "", false, true, token, now)
|
|
153
|
+
if !g.allow(now) {
|
|
154
|
+
t.Fatal("legacy systemd same active timestamp rejected")
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
func TestUnitProbeFailureRespectsReloadGenerationAndBudget(t *testing.T) {
|
|
159
|
+
for _, kind := range []string{"stale", "current", "owner", "install", "stop", "expired"} {
|
|
160
|
+
t.Run(kind, func(t *testing.T) {
|
|
161
|
+
now := time.Now()
|
|
162
|
+
g := newAdmission(testBinding())
|
|
163
|
+
g.observeUnit(testBinding(), 7, "id", true, true, 0, now)
|
|
164
|
+
old, _ := g.unitProbe(now)
|
|
165
|
+
g.requestUnitCheck(true, now)
|
|
166
|
+
g.requestUnitCheck(false, now)
|
|
167
|
+
reason, definitive := "observation-unavailable", false
|
|
168
|
+
switch kind {
|
|
169
|
+
case "current":
|
|
170
|
+
old, _ = g.unitProbe(now)
|
|
171
|
+
case "owner":
|
|
172
|
+
reason, definitive = "bus-owner-changed", true
|
|
173
|
+
case "install":
|
|
174
|
+
reason, definitive = "installation-changed", true
|
|
175
|
+
case "stop":
|
|
176
|
+
g.fence("unit-stopped")
|
|
177
|
+
reason = "unit-stopped"
|
|
178
|
+
case "expired":
|
|
179
|
+
now = now.Add(unitVerificationBudget)
|
|
180
|
+
}
|
|
181
|
+
blocked := g.failUnitProbe(old, reason, definitive, now)
|
|
182
|
+
if blocked != (kind != "stale") || g.allow(now) {
|
|
183
|
+
t.Fatalf("invalid outcome: blocked=%t reason=%s", blocked, g.reason())
|
|
184
|
+
}
|
|
185
|
+
serial, _ := g.unitProbe(now)
|
|
186
|
+
g.observeUnit(testBinding(), 7, "id", true, true, serial, now)
|
|
187
|
+
if kind == "stale" {
|
|
188
|
+
if !g.allow(now) {
|
|
189
|
+
t.Fatal("fresh query did not resume")
|
|
190
|
+
}
|
|
191
|
+
} else if g.allow(now) || g.reason() != reason {
|
|
192
|
+
t.Fatalf("sticky reason changed: %s", g.reason())
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"strings"
|
|
6
|
+
"time"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
const observerEventLimit = 64
|
|
10
|
+
const observerDiagnosticLimit = 32768
|
|
11
|
+
|
|
12
|
+
// Only fixed branch names and transport metadata belong here. Never store a
|
|
13
|
+
// signal body, query value, installation identity, or an error's text.
|
|
14
|
+
type observerEvent struct {
|
|
15
|
+
At time.Time `json:"at"`
|
|
16
|
+
Kind string `json:"kind"`
|
|
17
|
+
Detail string `json:"detail,omitempty"`
|
|
18
|
+
Phase string `json:"phase,omitempty"`
|
|
19
|
+
ErrorClass string `json:"errorClass,omitempty"`
|
|
20
|
+
Signal string `json:"signal,omitempty"`
|
|
21
|
+
Sender string `json:"sender,omitempty"`
|
|
22
|
+
WireSerial uint32 `json:"wireSerial,omitempty"`
|
|
23
|
+
SignalSequence uint64 `json:"signalSequence,omitempty"`
|
|
24
|
+
QuerySerial uint64 `json:"querySerial,omitempty"`
|
|
25
|
+
}
|
|
26
|
+
type observerDiagnostic struct {
|
|
27
|
+
Schema int `json:"schema"`
|
|
28
|
+
Epoch string `json:"epoch"`
|
|
29
|
+
Reason string `json:"reason"`
|
|
30
|
+
Fence observerEvent `json:"fence"`
|
|
31
|
+
Events []observerEvent `json:"events"`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
func (g *admission) recordObserver(e observerEvent) {
|
|
35
|
+
g.mu.Lock()
|
|
36
|
+
defer g.mu.Unlock()
|
|
37
|
+
g.recordObserverLocked(e)
|
|
38
|
+
}
|
|
39
|
+
func (g *admission) recordObserverLocked(e observerEvent) {
|
|
40
|
+
if e.At.IsZero() {
|
|
41
|
+
e.At = time.Now().UTC()
|
|
42
|
+
}
|
|
43
|
+
g.events[g.eventNext] = e
|
|
44
|
+
g.eventNext = (g.eventNext + 1) % observerEventLimit
|
|
45
|
+
if g.eventCount < observerEventLimit {
|
|
46
|
+
g.eventCount++
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
func (g *admission) fenceObserver(reason string, e observerEvent) {
|
|
50
|
+
g.mu.Lock()
|
|
51
|
+
defer g.mu.Unlock()
|
|
52
|
+
g.fenceObserverLocked(reason, e)
|
|
53
|
+
}
|
|
54
|
+
func (g *admission) fenceObserverLocked(reason string, e observerEvent) {
|
|
55
|
+
e.Kind = "fence"
|
|
56
|
+
if e.At.IsZero() {
|
|
57
|
+
e.At = time.Now().UTC()
|
|
58
|
+
}
|
|
59
|
+
if e.Detail == "" {
|
|
60
|
+
e.Detail = reason
|
|
61
|
+
}
|
|
62
|
+
if g.blocked == "" {
|
|
63
|
+
g.blocked = reason
|
|
64
|
+
g.firstFence = e
|
|
65
|
+
}
|
|
66
|
+
g.recordObserverLocked(e)
|
|
67
|
+
}
|
|
68
|
+
func (g *admission) observerDiagnostic(epoch string) observerDiagnostic {
|
|
69
|
+
g.mu.Lock()
|
|
70
|
+
defer g.mu.Unlock()
|
|
71
|
+
d := observerDiagnostic{Schema: 1, Epoch: epoch, Reason: g.blocked, Fence: g.firstFence, Events: make([]observerEvent, g.eventCount)}
|
|
72
|
+
start := (g.eventNext - g.eventCount + observerEventLimit) % observerEventLimit
|
|
73
|
+
for n := range d.Events {
|
|
74
|
+
d.Events[n] = g.events[(start+n)%observerEventLimit]
|
|
75
|
+
}
|
|
76
|
+
return d
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Diagnostics are independent of approval/completion authority. Write once on
|
|
80
|
+
// owner return, after teardown attempts. A parked owner retains its lifecycle
|
|
81
|
+
// sub-reason; a failed diagnostic write cannot change its fence or proof.
|
|
82
|
+
func persistObserverDiagnostic(c Client, epoch string, g *admission) {
|
|
83
|
+
d := g.observerDiagnostic(epoch)
|
|
84
|
+
if d.Reason == "" || !digestPattern.MatchString(epoch) {
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
b, err := json.Marshal(d)
|
|
88
|
+
if err != nil || len(b) > observerDiagnosticLimit || protected(c.StateDir, c.Owner, true) != nil {
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
_ = writeProtected(c.StateDir, "observer-diagnostic.json", d)
|
|
92
|
+
}
|
|
93
|
+
func safeBusSender(s string) string {
|
|
94
|
+
if s == "org.freedesktop.DBus" {
|
|
95
|
+
return s
|
|
96
|
+
}
|
|
97
|
+
if len(s) < 4 || len(s) > 32 || s[0] != ':' {
|
|
98
|
+
return ""
|
|
99
|
+
}
|
|
100
|
+
for _, c := range s[1:] {
|
|
101
|
+
if (c < '0' || c > '9') && c != '.' {
|
|
102
|
+
return ""
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if !strings.Contains(s, ".") {
|
|
106
|
+
return ""
|
|
107
|
+
}
|
|
108
|
+
return s
|
|
109
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"github.com/godbus/dbus/v5"
|
|
7
|
+
"io"
|
|
8
|
+
"net"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func observerErrorClass(err error) string {
|
|
12
|
+
switch {
|
|
13
|
+
case errors.Is(err, context.Canceled):
|
|
14
|
+
return "canceled"
|
|
15
|
+
case errors.Is(err, context.DeadlineExceeded):
|
|
16
|
+
return "deadline"
|
|
17
|
+
case errors.Is(err, io.EOF):
|
|
18
|
+
return "eof"
|
|
19
|
+
case errors.Is(err, errTrust):
|
|
20
|
+
return "trust"
|
|
21
|
+
}
|
|
22
|
+
var timeout net.Error
|
|
23
|
+
if errors.As(err, &timeout) && timeout.Timeout() {
|
|
24
|
+
return "timeout"
|
|
25
|
+
}
|
|
26
|
+
var bus dbus.Error
|
|
27
|
+
if errors.As(err, &bus) {
|
|
28
|
+
switch bus.Name {
|
|
29
|
+
case "org.freedesktop.systemd1.NoSuchUnit":
|
|
30
|
+
return "dbus-no-unit"
|
|
31
|
+
case "org.freedesktop.DBus.Error.NoReply":
|
|
32
|
+
return "dbus-no-reply"
|
|
33
|
+
case "org.freedesktop.DBus.Error.Disconnected":
|
|
34
|
+
return "dbus-disconnected"
|
|
35
|
+
case "org.freedesktop.DBus.Error.NameHasNoOwner":
|
|
36
|
+
return "dbus-no-owner"
|
|
37
|
+
case "org.freedesktop.DBus.Error.ServiceUnknown":
|
|
38
|
+
return "dbus-service-unknown"
|
|
39
|
+
default:
|
|
40
|
+
return "dbus-other"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return "other"
|
|
44
|
+
}
|
|
45
|
+
func observerSignalName(name string) string {
|
|
46
|
+
switch name {
|
|
47
|
+
case "org.freedesktop.DBus.NameOwnerChanged", managerInterface + ".Reloading", managerInterface + ".UnitRemoved", managerInterface + ".JobNew", propertiesInterface + ".PropertiesChanged":
|
|
48
|
+
return name
|
|
49
|
+
}
|
|
50
|
+
return ""
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The godbus receive loop invokes this immediately before synchronous signal
|
|
54
|
+
// delivery. Correlate header-only wire serial; Signal.Sequence is a different,
|
|
55
|
+
// connection-local receive ordinal. Neither counter is an authority input.
|
|
56
|
+
func (o *unitObserver) incomingObserverMessage(m *dbus.Message) {
|
|
57
|
+
if m.Type != dbus.TypeSignal {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
iface, _ := m.Headers[dbus.FieldInterface].Value().(string)
|
|
61
|
+
member, _ := m.Headers[dbus.FieldMember].Value().(string)
|
|
62
|
+
sender, _ := m.Headers[dbus.FieldSender].Value().(string)
|
|
63
|
+
o.wireMu.Lock()
|
|
64
|
+
defer o.wireMu.Unlock()
|
|
65
|
+
o.wire = observerEvent{Signal: observerSignalName(iface + "." + member), Sender: safeBusSender(sender), WireSerial: m.Serial()}
|
|
66
|
+
}
|
|
67
|
+
func (o *unitObserver) signalEvent(s *dbus.Signal) observerEvent {
|
|
68
|
+
e := observerEvent{Kind: "signal", Signal: observerSignalName(s.Name), Sender: safeBusSender(s.Sender), SignalSequence: uint64(s.Sequence)}
|
|
69
|
+
o.wireMu.Lock()
|
|
70
|
+
defer o.wireMu.Unlock()
|
|
71
|
+
if e.Signal != "" && e.Signal == o.wire.Signal && e.Sender == o.wire.Sender {
|
|
72
|
+
e.WireSerial = o.wire.WireSerial
|
|
73
|
+
}
|
|
74
|
+
o.wire = observerEvent{}
|
|
75
|
+
return e
|
|
76
|
+
}
|