Skip to content

Commit 66c3850

Browse files
committed
Merge branch '2.8' into merge-2.8
2 parents c8fbcaf + 341884e commit 66c3850

File tree

7 files changed

+69
-16
lines changed

7 files changed

+69
-16
lines changed

api/apiclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ func tagToString(tag names.Tag) string {
575575
return tag.String()
576576
}
577577

578-
// dialResult holds a dialled connection, the URL
578+
// dialResult holds a dialed connection, the URL
579579
// and TLS configuration used to connect to it.
580580
type dialResult struct {
581581
conn jsoncodec.JSONConn

caas/kubernetes/provider/k8s.go

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ func (k *kubernetesClient) configurePodFiles(
12751275
containers []specs.ContainerSpec,
12761276
cfgMapName configMapNameFunc,
12771277
) error {
1278-
for i, container := range containers {
1278+
for _, container := range containers {
12791279
for _, fileSet := range container.VolumeConfig {
12801280
vol, err := k.fileSetToVolume(appName, annotations, workloadSpec, fileSet, cfgMapName)
12811281
if err != nil {
@@ -1284,16 +1284,40 @@ func (k *kubernetesClient) configurePodFiles(
12841284
if err = k8sstorage.PushUniqueVolume(&workloadSpec.Pod.PodSpec, vol, false); err != nil {
12851285
return errors.Trace(err)
12861286
}
1287-
workloadSpec.Pod.Containers[i].VolumeMounts = append(workloadSpec.Pod.Containers[i].VolumeMounts, core.VolumeMount{
1288-
// TODO(caas): add more config fields support(SubPath, ReadOnly, etc).
1289-
Name: vol.Name,
1290-
MountPath: fileSet.MountPath,
1291-
})
1287+
if err := configVolumeMount(
1288+
container, workloadSpec,
1289+
core.VolumeMount{
1290+
// TODO(caas): add more config fields support(SubPath, ReadOnly, etc).
1291+
Name: vol.Name,
1292+
MountPath: fileSet.MountPath,
1293+
},
1294+
); err != nil {
1295+
return errors.Trace(err)
1296+
}
12921297
}
12931298
}
12941299
return nil
12951300
}
12961301

1302+
func configVolumeMount(container specs.ContainerSpec, workloadSpec *workloadSpec, volMount core.VolumeMount) error {
1303+
if container.Init {
1304+
for i, c := range workloadSpec.Pod.InitContainers {
1305+
if c.Name == container.Name {
1306+
workloadSpec.Pod.InitContainers[i].VolumeMounts = append(workloadSpec.Pod.InitContainers[i].VolumeMounts, volMount)
1307+
return nil
1308+
}
1309+
}
1310+
return errors.Annotatef(errors.NotFoundf("init container %q", container.Name), "configuring volume mount %q", volMount.Name)
1311+
}
1312+
for i, c := range workloadSpec.Pod.Containers {
1313+
if c.Name == container.Name {
1314+
workloadSpec.Pod.Containers[i].VolumeMounts = append(workloadSpec.Pod.Containers[i].VolumeMounts, volMount)
1315+
return nil
1316+
}
1317+
}
1318+
return errors.Annotatef(errors.NotFoundf("container %q", container.Name), "configuring volume mount %q", volMount.Name)
1319+
}
1320+
12971321
func (k *kubernetesClient) configureStorage(
12981322
appName string, legacy bool, uniquePrefix string,
12991323
filesystems []storage.KubernetesFilesystemParams,

caas/kubernetes/provider/k8s_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,7 @@ func (s *K8sBrokerSuite) TestConfigurePodFiles(c *gc.C) {
11051105
}, {
11061106
Name: "test2",
11071107
Ports: []specs.ContainerPort{{ContainerPort: 8080, Protocol: "TCP", Name: "fred"}},
1108+
Init: true,
11081109
Image: "juju/image2",
11091110
VolumeConfig: []specs.FileSet{
11101111
{
@@ -1152,7 +1153,10 @@ func (s *K8sBrokerSuite) TestConfigurePodFiles(c *gc.C) {
11521153
Handler: core.Handler{HTTPGet: &core.HTTPGetAction{Path: "/liveready"}},
11531154
},
11541155
VolumeMounts: dataVolumeMounts(),
1155-
}, {
1156+
},
1157+
}
1158+
workloadSpec.Pod.InitContainers = []core.Container{
1159+
{
11561160
Name: "test2",
11571161
Image: "juju/image2",
11581162
Ports: []core.ContainerPort{{ContainerPort: int32(8080), Protocol: core.ProtocolTCP}},
@@ -1218,7 +1222,10 @@ func (s *K8sBrokerSuite) TestConfigurePodFiles(c *gc.C) {
12181222
{Name: "cache-volume", MountPath: "/empty-dir"},
12191223
{Name: "cache-volume", MountPath: "/another-empty-dir"},
12201224
}...),
1221-
}, {
1225+
},
1226+
})
1227+
c.Assert(workloadSpec.Pod.InitContainers, gc.DeepEquals, []core.Container{
1228+
{
12221229
Name: "test2",
12231230
Image: "juju/image2",
12241231
Ports: []core.ContainerPort{{ContainerPort: int32(8080), Protocol: core.ProtocolTCP}},

charmstore/client.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (c Client) listResources(ch CharmID) ([]resource.Resource, error) {
280280
if err != nil {
281281
return nil, errors.Trace(err)
282282
}
283-
return api2resources(resources)
283+
return api2resources(ch.URL.String(), resources)
284284
}
285285

286286
// csWrapper is a type that abstracts away the low-level implementation details
@@ -336,13 +336,17 @@ func (c csclientImpl) ResourceMeta(channel csparams.Channel, id *charm.URL, name
336336
return client.ResourceMeta(id, name, revision)
337337
}
338338

339-
func api2resources(res []csparams.Resource) ([]resource.Resource, error) {
339+
func api2resources(name string, res []csparams.Resource) ([]resource.Resource, error) {
340340
result := make([]resource.Resource, len(res))
341341
for i, r := range res {
342342
var err error
343343
result[i], err = csparams.API2Resource(r)
344344
if err != nil {
345-
return nil, errors.Trace(err)
345+
msg := name
346+
if r.Name != "" {
347+
msg = fmt.Sprintf("%s resource %q", msg, r.Name)
348+
}
349+
return nil, errors.Trace(errors.Annotatef(err, "%s", msg))
346350
}
347351
}
348352
return result, nil

charmstore/client_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package charmstore
55

66
import (
7+
"fmt"
78
"io/ioutil"
89
"strings"
910

@@ -169,6 +170,23 @@ func (s *ClientSuite) TestListResourcesError(c *gc.C) {
169170
c.Assert(ret, gc.IsNil)
170171
}
171172

173+
func (s *ClientSuite) TestListResourcesAPI2ResourcesFailure(c *gc.C) {
174+
dev := params.Resource{
175+
Name: "name2",
176+
}
177+
s.wrapper.ReturnListResourcesStable = []resourceResult{oneResourceResult(dev)}
178+
client, err := newCachingClient(s.cache, "", s.wrapper.makeWrapper)
179+
c.Assert(err, jc.ErrorIsNil)
180+
181+
curl := charm.MustParseURL("cs:quantal/foo-1")
182+
ret, err := client.ListResources([]CharmID{{
183+
URL: curl,
184+
Channel: params.StableChannel,
185+
}})
186+
c.Assert(err, gc.ErrorMatches, fmt.Sprintf("%s resource %q: .*", curl.String(), dev.Name))
187+
c.Assert(ret, gc.IsNil)
188+
}
189+
172190
func (s *ClientSuite) TestGetResource(c *gc.C) {
173191
fp, err := resource.GenerateFingerprint(strings.NewReader("data"))
174192
c.Assert(err, jc.ErrorIsNil)

mongo/open.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func DialInfo(info Info, opts DialOpts) (*mgo.DialInfo, error) {
171171
}
172172
c = cc
173173
}
174-
logger.Debugf("dialled mongodb server at %q", addr)
174+
logger.Debugf("dialed mongodb server at %q", addr)
175175
return c, nil
176176
}
177177

tests/includes/juju.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ bootstrap() {
122122
if [ -n "${OUT}" ]; then
123123
echo "${model} already exists. Use the following to clean up the environment:"
124124
echo " juju switch ${bootstrapped_name}"
125-
echo " juju destroy-model --force -y ${model}"
125+
echo " juju destroy-model -y ${model}"
126126
exit 1
127127
fi
128128

@@ -219,7 +219,7 @@ destroy_model() {
219219
output="${TEST_DIR}/${name}-destroy.log"
220220

221221
echo "====> Destroying juju model ${name}"
222-
echo "${name}" | xargs -I % juju destroy-model --force -y % >"${output}" 2>&1
222+
echo "${name}" | xargs -I % juju destroy-model -y % >"${output}" 2>&1 || true
223223
CHK=$(cat "${output}" | grep -i "ERROR" || true)
224224
if [ -n "${CHK}" ]; then
225225
printf "\\nFound some issues\\n"
@@ -253,7 +253,7 @@ destroy_controller() {
253253
echo "====> Destroying model ($(green "${name}"))"
254254

255255
output="${TEST_DIR}/${name}-destroy-model.log"
256-
echo "${name}" | xargs -I % juju destroy-model --force -y % >"${output}" 2>&1
256+
echo "${name}" | xargs -I % juju destroy-model -y % >"${output}" 2>&1 || true
257257

258258
echo "====> Destroyed model ($(green "${name}"))"
259259
return

0 commit comments

Comments
 (0)