Skip to content

chore: move proxy and network specs to runtime config #2296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2025

Conversation

emosbaugh
Copy link
Member

@emosbaugh emosbaugh commented Jun 11, 2025

What this PR does / why we need it:

Add missing properties from the UI install config to the runtime config ahead of merging the two.

Related
replicatedhq/kots#5355

Which issue(s) this PR fixes:

Does this PR require a test?

Does this PR require a release note?


Does this PR require documentation?

Copy link

github-actions bot commented Jun 11, 2025

This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID.

Online Installer:

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci/appver-dev-2142cd1" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Airgap Installer (may take a few minutes before the airgap bundle is built):

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci-airgap/appver-dev-2142cd1?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

@emosbaugh emosbaugh force-pushed the emosbaugh/20250611/more-in-runtime-config branch 2 times, most recently from 3a0c26e to f7b7c01 Compare June 12, 2025 18:45
@emosbaugh emosbaugh requested a review from sgalsaleh June 12, 2025 20:53
@emosbaugh emosbaugh marked this pull request as ready for review June 12, 2025 22:19
@emosbaugh emosbaugh enabled auto-merge (squash) June 12, 2025 22:19
@emosbaugh
Copy link
Member Author

[sc-124940]

@emosbaugh emosbaugh force-pushed the emosbaugh/20250611/more-in-runtime-config branch from 79c94f9 to 4672f1c Compare June 13, 2025 21:18
Copy link
Member

@JGAntunes JGAntunes left a comment

Choose a reason for hiding this comment

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

Some questions/suggestions.

Comment on lines 57 to 63
type EnvSetter interface {
Setenv(key string, val string) error
}
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if it would make sense for this interface, the respective struct implementation and the mock implementation to live in api/pkg/utils instead? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

moved to the runtimeconfig package

@@ -162,6 +162,7 @@ func TestConfigureInstallation(t *testing.T) {
installController, err := install.NewInstallController(
install.WithHostUtils(tc.mockHostUtils),
install.WithRuntimeConfig(rc),
install.WithEnvSetter(&testEnvSetter{}),
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we're missing a set of assertions here that validate:

  • The environment variables are set
  • All these runtime config fields are updated accordingly -
    c.rc.SetDataDir(config.DataDirectory)
    c.rc.SetLocalArtifactMirrorPort(config.LocalArtifactMirrorPort)
    c.rc.SetAdminConsolePort(config.AdminConsolePort)
    c.rc.SetProxySpec(proxy)
    c.rc.SetNetworkSpec(networkSpec)

Copy link
Member Author

Choose a reason for hiding this comment

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

added

Comment on lines 21 to 23
if os.Getuid() != 0 {
return fmt.Errorf("update command must be run as root")
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? If so the msg should be changed s/update/join.

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

Comment on lines +25 to +33
var err error
rc, err = rcutil.GetRuntimeConfigFromCluster(ctx)
if err != nil {
return fmt.Errorf("failed to init runtime config from cluster: %w", err)
}

os.Setenv("TMPDIR", rc.EmbeddedClusterTmpSubDir())

return nil
Copy link
Member

Choose a reason for hiding this comment

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

Curious, is this only required now? Or was it already being done before but in a different place?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is a bug if we dont have this. The previous will not work for a non-default data directory.

@@ -356,8 +356,6 @@ func TestConfigureHost(t *testing.T) {
hum.On("ConfigureHost", mock.Anything, hostutils.InitForInstallOptions{
LicenseFile: "license.yaml",
AirgapBundle: "bundle.tar",
PodCIDR: "10.0.0.0/16",
ServiceCIDR: "10.1.0.0/16",
}).Return(nil),
Copy link
Member

Choose a reason for hiding this comment

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

Should we validate the RC param VS keeping the mock.Anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -212,6 +212,9 @@ jobs:
with:
fetch-depth: 0

- name: Free up runner disk space
uses: ./.github/actions/free-disk-space
Copy link
Member

Choose a reason for hiding this comment

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

i've seen this action take ~10 minutes some times, have you seen the build fail due to low disk space?

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@@ -857,3 +867,15 @@ func WithInfraManager(infraManager infra.InfraManager) InstallControllerOption {
c.infraManager = infraManager
}
}

type testEnvSetter struct {
Copy link
Member

Choose a reason for hiding this comment

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

wonder if this should live in a utils package like Joao mentioned with a proper mock like the other interfaces

Copy link
Member Author

Choose a reason for hiding this comment

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

moved to the runtimeconfig package

os.Setenv("KUBECONFIG", c.rc.PathToKubeConfig())
os.Setenv("TMPDIR", c.rc.EmbeddedClusterTmpSubDir())
_ = c.envSetter.Setenv("KUBECONFIG", c.rc.PathToKubeConfig())
_ = c.envSetter.Setenv("TMPDIR", c.rc.EmbeddedClusterTmpSubDir())
Copy link
Member

Choose a reason for hiding this comment

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

why not handle the errors?

Copy link
Member

Choose a reason for hiding this comment

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

(i know the old code didn't ,but that's probably a mistake if os.Setenv returns an error)

Copy link
Member Author

Choose a reason for hiding this comment

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

handled

@emosbaugh emosbaugh force-pushed the emosbaugh/20250611/more-in-runtime-config branch from 4672f1c to 358c583 Compare June 16, 2025 18:40
@emosbaugh emosbaugh requested review from sgalsaleh and JGAntunes June 16, 2025 23:23
return fmt.Errorf("failed to init runtime config from cluster: %w", err)
}

os.Setenv("TMPDIR", rc.EmbeddedClusterTmpSubDir())
Copy link
Member

Choose a reason for hiding this comment

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

Shoukd this use rc.Setenv?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didnt use setenv in places where we didnt set both env vars. we can refactor later

@emosbaugh emosbaugh merged commit 2a86d34 into main Jun 17, 2025
68 checks passed
@emosbaugh emosbaugh deleted the emosbaugh/20250611/more-in-runtime-config branch June 17, 2025 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants