Skip to content

Develop/spapadop#28

Merged
eywalker merged 15 commits into
mainfrom
develop/spapadop
Mar 6, 2026
Merged

Develop/spapadop#28
eywalker merged 15 commits into
mainfrom
develop/spapadop

Conversation

@spapa013
Copy link
Copy Markdown
Collaborator

@spapa013 spapa013 commented Mar 6, 2026

Closes PLT-859 #24
Closes PLT-881 #25
Closes PLT-862 #26
Closes PLT-849 #27

spapa013 and others added 15 commits March 4, 2026 23:54
… UID/GID lookups and conditional rename/create logic for the dev account.
…tall to prevent breakage from stale UID/GID ownership
…tion and remove conflicting filepath tag so valid absolute paths pass consistently
… shell quoting for user/group and path arguments
… setup to prevent stale-dotfile permission failures (e.g. .bashrc)
…v-startup-script-so-generated-devenvs-boot

Spapadop/plt 859 stabilize devenv startup script so generated devenvs boot
…h-validation-incorrectly-uses-filepath

Spapadop/plt 881 volumemount path validation incorrectly uses filepath
…sage-in-rendered-manifest-files

spapadop/plt-862-fix-namespace-usage-in-rendered-manifest-files
…match StatefulSet serviceName while preserving existing SSH/HTTP services
…vicename-does-not-match-any-generated-service

Spapadop/plt 849 statefulset servicename does not match any generated service
@spapa013 spapa013 requested a review from eywalker March 6, 2026 20:02
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/config/validation.go 71.42% 5 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@eywalker eywalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great -- thanks for catching all those subtle bugs

@@ -1,7 +1,26 @@
apiVersion: v1
kind: Service
metadata:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this extra SSH port for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the reply I got when I asked ChatGPT at the time:

Great question. Practical implications are:

  1. With the port (22) on the headless governing Service:
  • Service is clearly valid/standard and reliably accepted by Kubernetes API.
  • EndpointSlices include a named port (ssh), so SRV-based discovery can work.
  • You get no extra external exposure by itself, because it is still headless (clusterIP: None) and not NodePort/LoadBalancer.
  1. Without any port on that Service:
  • You still get the main StatefulSet DNS identity behavior (pod hostnames) in many setups.
  • But Service definitions without ports are less standard and can be rejected depending on API validation/version/config.
  • You lose explicit service-port metadata (and SRV records tied to named ports).
  1. Bottom line:
  • The port is mostly low-risk structural correctness and compatibility.
  • It does not replace or affect external SSH access; that still comes from devenv-ssh-{{.Name}} NodePort service.

if id -g ${TARGET_GID} &>/dev/null; then
echo "Renaming group ${TARGET_GID} to ${DEV_USERNAME}"
groupmod -n ${DEV_USERNAME} $(id -gn ${TARGET_GID})
if GROUP_ENTRY="$(getent group "${TARGET_GID}")"; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious to learn what was the problem with id -g?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getent is better here because you’re checking numeric UID/GID existence, not “user by name”.

Why id was wrong in this context:

  • id -u ARG / id -g ARG interpret ARG as a username, not a UID/GID lookup key.
  • So with TARGET_UID=10000, id -u 10000 means “user literally named 10000”, not “does UID 10000 exist?”

That can send logic down the wrong branch (try useradd/groupadd when entries already exist).

Why getent fits:

  • getent passwd does NSS lookup by UID key.

  • getent group does NSS lookup by GID key.

  • It works across configured identity sources (/etc/passwd, LDAP, etc.) through NSS, same source of truth account tools use.

Practical impact in your script:

  • Correctly detects existing UID/GID mappings.
  • Makes create/rename logic truly idempotent.
  • Avoids false negatives and collision failures from mis-detection.

else
echo "Adding user ${DEV_USERNAME} with UID ${TARGET_UID}"
useradd -u ${TARGET_UID} -m -s /bin/bash ${DEV_USERNAME}
useradd -u "${TARGET_UID}" -g "${TARGET_GID}" -m -s /bin/bash "${DEV_USERNAME}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good catch...

@eywalker eywalker merged commit c90a769 into main Mar 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants