Preserve file modes in operator updates
This commit is contained in:
@@ -211,7 +211,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.athena-operator
|
dockerfile: Dockerfile.athena-operator
|
||||||
image: mike-ai/mcp-athena-operator:2.3.2
|
image: mike-ai/mcp-athena-operator:2.3.3
|
||||||
container_name: mike-ai-mcp-athena-operator
|
container_name: mike-ai-mcp-athena-operator
|
||||||
environment:
|
environment:
|
||||||
ATHENA_OPERATOR_SOCKET: /operator/operator.sock
|
ATHENA_OPERATOR_SOCKET: /operator/operator.sock
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
@@ -17,6 +17,7 @@ import re
|
|||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import socketserver
|
import socketserver
|
||||||
|
import stat
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
@@ -28,7 +29,7 @@ from pathlib import Path
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
VERSION = "2.3.2"
|
VERSION = "2.3.3"
|
||||||
STACK = Path(os.environ.get("ATHENA_OPERATOR_STACK", "/opt/mike-ai/stack")).resolve()
|
STACK = Path(os.environ.get("ATHENA_OPERATOR_STACK", "/opt/mike-ai/stack")).resolve()
|
||||||
REPOSITORY = Path(os.environ.get("ATHENA_OPERATOR_REPOSITORY", "/data/mike-ai-operator/repository")).resolve()
|
REPOSITORY = Path(os.environ.get("ATHENA_OPERATOR_REPOSITORY", "/data/mike-ai-operator/repository")).resolve()
|
||||||
STATE = Path(os.environ.get("ATHENA_OPERATOR_STATE", "/data/mike-ai-operator/state")).resolve()
|
STATE = Path(os.environ.get("ATHENA_OPERATOR_STATE", "/data/mike-ai-operator/state")).resolve()
|
||||||
@@ -565,6 +566,7 @@ def prepare(arguments: dict[str, Any]) -> dict[str, Any]:
|
|||||||
def sync_file(relative: Path, content: str, backup_root: Path) -> None:
|
def sync_file(relative: Path, content: str, backup_root: Path) -> None:
|
||||||
for root in (REPOSITORY, STACK):
|
for root in (REPOSITORY, STACK):
|
||||||
target = source_file(root, relative)
|
target = source_file(root, relative)
|
||||||
|
target_mode = stat.S_IMODE(target.stat().st_mode) if target.exists() else 0o644
|
||||||
if target.exists():
|
if target.exists():
|
||||||
backup = backup_root / root.name / relative
|
backup = backup_root / root.name / relative
|
||||||
backup.parent.mkdir(parents=True, exist_ok=True)
|
backup.parent.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -573,6 +575,7 @@ def sync_file(relative: Path, content: str, backup_root: Path) -> None:
|
|||||||
fd, temp_name = tempfile.mkstemp(prefix=f".{target.name}.", dir=target.parent)
|
fd, temp_name = tempfile.mkstemp(prefix=f".{target.name}.", dir=target.parent)
|
||||||
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
||||||
handle.write(content)
|
handle.write(content)
|
||||||
|
os.chmod(temp_name, target_mode)
|
||||||
os.replace(temp_name, target)
|
os.replace(temp_name, target)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user