Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion initializer/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func GetRootFSSizes(
gardenClient garden_client.Client,
guidGenerator guidgen.Generator,
containerOwnerName string,
rootFSes map[string]string,
rootFSes []string,
) (RootFSSizer, error) {
rootFSSizes := make(map[string]uint64)

Expand Down
24 changes: 12 additions & 12 deletions initializer/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ var _ = Describe("configuration", func() {
Describe("GetRootFSSizes", func() {
var (
logger lager.Logger
rootFSes map[string]string
rootFSes []string

fakeGuidGen *fakeguidgen.FakeGenerator
guidToRootFS map[string]string
Expand All @@ -275,9 +275,9 @@ var _ = Describe("configuration", func() {

BeforeEach(func() {
logger = lagertest.NewTestLogger("configuration")
rootFSes = map[string]string{
"rootFS1": "/rootFS1/path",
"rootFS2": "/rootFS2/path",
rootFSes = []string{
"/rootFS1/path",
"/rootFS2/path",
}

fakeGuidGen = new(fakeguidgen.FakeGenerator)
Expand All @@ -293,8 +293,8 @@ var _ = Describe("configuration", func() {
Context("when container with provided rootFS is created", func() {
BeforeEach(func() {
expectedMetrics := map[string]garden.ContainerMetricsEntry{
"rootfs-c-g1": garden.ContainerMetricsEntry{Metrics: garden.Metrics{DiskStat: garden.ContainerDiskStat{TotalBytesUsed: uint64(150 * 1024 * 1024), ExclusiveBytesUsed: uint64(50 * 1024 * 1024)}}},
"rootfs-c-g2": garden.ContainerMetricsEntry{Metrics: garden.Metrics{DiskStat: garden.ContainerDiskStat{TotalBytesUsed: uint64(32 * 1024 * 1024), ExclusiveBytesUsed: uint64(8*1024*1024 - 5)}}},
"rootfs-c-g1": {Metrics: garden.Metrics{DiskStat: garden.ContainerDiskStat{TotalBytesUsed: uint64(150 * 1024 * 1024), ExclusiveBytesUsed: uint64(50 * 1024 * 1024)}}},
"rootfs-c-g2": {Metrics: garden.Metrics{DiskStat: garden.ContainerDiskStat{TotalBytesUsed: uint64(32 * 1024 * 1024), ExclusiveBytesUsed: uint64(8*1024*1024 - 5)}}},
}
gardenClient.Connection.BulkMetricsReturnsOnCall(0, expectedMetrics, nil)
})
Expand Down Expand Up @@ -346,8 +346,8 @@ var _ = Describe("configuration", func() {

Context("when the rootfs URI query string has been augmented with a query/scheme/host/etc.", func() {
BeforeEach(func() {
rootFSes = map[string]string{
"rootFS1": "/rootFS1/path",
rootFSes = []string{
"/rootFS1/path",
}
})

Expand All @@ -366,8 +366,8 @@ var _ = Describe("configuration", func() {

Context("when a preloaded rootfs URI is not just a simple path", func() {
BeforeEach(func() {
rootFSes = map[string]string{
"rootFS1": "somescheme:///rootFS1/path",
rootFSes = []string{
"somescheme:///rootFS1/path",
}
})

Expand All @@ -379,8 +379,8 @@ var _ = Describe("configuration", func() {

Context("when a preloaded rootfs URI is an invalid URI", func() {
BeforeEach(func() {
rootFSes = map[string]string{
"rootFS1": "/some/path/that/is/%invalid",
rootFSes = []string{
"/some/path/that/is/%invalid",
}
})

Expand Down
22 changes: 5 additions & 17 deletions initializer/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,13 @@ var (
metricsWorkPool, readWorkPool *workpool.WorkPool
)

func Initialize(
logger lager.Logger,
config ExecutorConfig,
cellID string,
zone string,
rootFSes map[string]string,
metronClient loggingclient.IngressClient,
func Initialize(logger lager.Logger, config ExecutorConfig, cellID, zone string,
rootFSes []string, metronClient loggingclient.IngressClient,
clock clock.Clock,
) (
executor.Client,
*containermetrics.StatsReporter,
grouper.Members,
error,
) {

) (executor.Client, *containermetrics.StatsReporter, grouper.Members, error) {
var gardenHealthcheckRootFS string
for _, rootFSPath := range rootFSes {
gardenHealthcheckRootFS = rootFSPath
break
if len(rootFSes) > 0 {
gardenHealthcheckRootFS = rootFSes[len(rootFSes)-1]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code changes the behavior (I think) from before.

Before it looks like gardenHealthcheckRootFS was set to the first rootFSPath. Now it looks like it is being set to the last last rootFSPath.

❓ What is the intention behind this change? Is there a test change to go with it?

}

postSetupHook, err := shlex.Split(config.PostSetupHook)
Expand Down
5 changes: 2 additions & 3 deletions initializer/initializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var _ = Describe("Initializer", func() {
config.GardenAddr = fakeGarden.HTTPTestServer.Listener.Addr().String()
config.GardenNetwork = "tcp"
go func() {
rootFSes := map[string]string{}
rootFSes := []string{}
_, _, _, err := initializer.Initialize(logger, config, "cell-id", "some-zone", rootFSes, fakeMetronClient, fakeClock)
errCh <- err
close(done)
Expand Down Expand Up @@ -194,7 +194,7 @@ var _ = Describe("Initializer", func() {
if r.FormValue(healthcheckTagQueryParam) == gardenhealth.HealthcheckTagValue {
ghttp.RespondWithJSONEncoded(http.StatusOK, struct{}{})(w, r)
} else {
ghttp.RespondWithJSONEncoded(http.StatusOK, map[string][]string{"handles": []string{"cnr1", "cnr2"}})(w, r)
ghttp.RespondWithJSONEncoded(http.StatusOK, map[string][]string{"handles": {"cnr1", "cnr2"}})(w, r)
}
},
)
Expand Down Expand Up @@ -718,7 +718,6 @@ var _ = Describe("Initializer", func() {
config.CachePath = ""

fakeCertPoolRetriever.SystemCertsReturns(x509.NewCertPool(), nil)

})
It("returns an error", func() {
certBytes, err := os.ReadFile(config.PathToTLSCACert)
Expand Down