Commit ed9165c2 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent b4b9b385
......@@ -43,7 +43,7 @@ module PodLogs
end
def check_container_name(result)
pod_details = result[:raw_pods].first { |p| p.metadata.name == result[:pod_name] }
pod_details = result[:raw_pods].find { |p| p.metadata.name == result[:pod_name] }
containers = pod_details.spec.containers.map(&:name)
# select first container if not specified
......
---
title: Fix access to logs when multiple pods exist
merge_request: 27008
author:
type: fixed
......@@ -588,6 +588,15 @@ output of the [Helm
Tiller](https://v2.helm.sh/docs/install/#running-tiller-locally) binary
will be saved as a [CI job artifact](../../ci/pipelines/job_artifacts.md).
### Important notes
Note the following:
- When you set the value for `installed` key back to `false`, the application will be
unprovisioned from the cluster.
- If you update `.gitlab/managed-apps/<application>/values.yaml` with new values, the
application will be redeployed.
### Install Ingress using GitLab CI
To install Ingress, define the `.gitlab/managed-apps/config.yaml` file
......
......@@ -14,7 +14,7 @@ privileges.
This can be useful for:
- Creating pipelines to install cluster-wide applications into your cluster.
- Creating pipelines to install cluster-wide applications into your cluster, see [Install using GitLab CI (alpha)](applications.md#install-using-gitlab-ci-alpha) for details.
- Any jobs that require `cluster-admin` privileges.
## Permissions
......@@ -47,6 +47,8 @@ To select a cluster management project to use:
**Operations > Kubernetes** page.
- [Group-level cluster](../group/clusters/index.md), navigate to your group's **Kubernetes**
page.
- [Instance-level cluster](../instance/clusters/index.md), navigate to Admin Area's **Kubernetes**
page.
1. Select the project using **Cluster management project field** in the **Advanced settings**
section.
......
import testAction from 'helpers/vuex_action_helper';
import createState from '~/create_cluster/gke_cluster/store/state';
import * as types from '~/create_cluster/gke_cluster/store/mutation_types';
import * as actions from '~/create_cluster/gke_cluster/store/actions';
import { createStore } from '~/create_cluster/gke_cluster/store';
import gapi from '../helpers';
import { selectedProjectMock, selectedZoneMock, selectedMachineTypeMock } from '../mock_data';
import {
selectedProjectMock,
selectedZoneMock,
selectedMachineTypeMock,
gapiProjectsResponseMock,
gapiZonesResponseMock,
gapiMachineTypesResponseMock,
} from '../mock_data';
describe('GCP Cluster Dropdown Store Actions', () => {
let store;
beforeEach(() => {
store = createStore();
});
describe('setProject', () => {
it('should set project', done => {
testAction(
......@@ -76,16 +78,16 @@ describe('GCP Cluster Dropdown Store Actions', () => {
});
describe('fetchProjects', () => {
it('fetches projects from Google API', done => {
store
.dispatch('fetchProjects')
.then(() => {
expect(store.state.projects[0].projectId).toEqual(selectedProjectMock.projectId);
expect(store.state.projects[0].name).toEqual(selectedProjectMock.name);
done();
})
.catch(done.fail);
it('fetches projects from Google API', () => {
const state = createState();
return testAction(
actions.fetchProjects,
null,
state,
[{ type: types.SET_PROJECTS, payload: gapiProjectsResponseMock.projects }],
[],
);
});
});
......@@ -112,28 +114,30 @@ describe('GCP Cluster Dropdown Store Actions', () => {
});
describe('fetchZones', () => {
it('fetches zones from Google API', done => {
store
.dispatch('fetchZones')
.then(() => {
expect(store.state.zones[0].name).toEqual(selectedZoneMock);
done();
})
.catch(done.fail);
it('fetches zones from Google API', () => {
const state = createState();
return testAction(
actions.fetchZones,
null,
state,
[{ type: types.SET_ZONES, payload: gapiZonesResponseMock.items }],
[],
);
});
});
describe('fetchMachineTypes', () => {
it('fetches machine types from Google API', done => {
store
.dispatch('fetchMachineTypes')
.then(() => {
expect(store.state.machineTypes[0].name).toEqual(selectedMachineTypeMock);
done();
})
.catch(done.fail);
it('fetches machine types from Google API', () => {
const state = createState();
return testAction(
actions.fetchMachineTypes,
null,
state,
[{ type: types.SET_MACHINE_TYPES, payload: gapiMachineTypesResponseMock.items }],
[],
);
});
});
});
......
import { createStore } from '~/create_cluster/gke_cluster/store';
import createState from '~/create_cluster/gke_cluster/store/state';
import * as types from '~/create_cluster/gke_cluster/store/mutation_types';
import mutations from '~/create_cluster/gke_cluster/store/mutations';
import {
selectedProjectMock,
selectedZoneMock,
selectedMachineTypeMock,
gapiProjectsResponseMock,
gapiZonesResponseMock,
gapiMachineTypesResponseMock,
} from '../mock_data';
describe('GCP Cluster Dropdown Store Mutations', () => {
let store;
beforeEach(() => {
store = createStore();
});
describe('SET_PROJECT', () => {
it('should set GCP project as selectedProject', () => {
const projectToSelect = gapiProjectsResponseMock.projects[0];
store.commit(types.SET_PROJECT, projectToSelect);
expect(store.state.selectedProject.projectId).toEqual(selectedProjectMock.projectId);
expect(store.state.selectedProject.name).toEqual(selectedProjectMock.name);
});
});
describe('SET_PROJECT_BILLING_STATUS', () => {
it('should set project billing status', () => {
store.commit(types.SET_PROJECT_BILLING_STATUS, true);
expect(store.state.projectHasBillingEnabled).toBeTruthy();
});
});
describe('SET_ZONE', () => {
it('should set GCP zone as selectedZone', () => {
const zoneToSelect = gapiZonesResponseMock.items[0].name;
store.commit(types.SET_ZONE, zoneToSelect);
expect(store.state.selectedZone).toEqual(selectedZoneMock);
});
});
describe('SET_MACHINE_TYPE', () => {
it('should set GCP machine type as selectedMachineType', () => {
const machineTypeToSelect = gapiMachineTypesResponseMock.items[0].name;
store.commit(types.SET_MACHINE_TYPE, machineTypeToSelect);
expect(store.state.selectedMachineType).toEqual(selectedMachineTypeMock);
});
});
describe('SET_PROJECTS', () => {
it('should set Google API Projects response as projects', () => {
expect(store.state.projects.length).toEqual(0);
store.commit(types.SET_PROJECTS, gapiProjectsResponseMock.projects);
expect(store.state.projects.length).toEqual(gapiProjectsResponseMock.projects.length);
});
});
describe('SET_ZONES', () => {
it('should set Google API Zones response as zones', () => {
expect(store.state.zones.length).toEqual(0);
store.commit(types.SET_ZONES, gapiZonesResponseMock.items);
expect(store.state.zones.length).toEqual(gapiZonesResponseMock.items.length);
});
});
describe('SET_MACHINE_TYPES', () => {
it('should set Google API Machine Types response as machineTypes', () => {
expect(store.state.machineTypes.length).toEqual(0);
store.commit(types.SET_MACHINE_TYPES, gapiMachineTypesResponseMock.items);
expect(store.state.machineTypes.length).toEqual(gapiMachineTypesResponseMock.items.length);
describe.each`
mutation | stateProperty | mockData
${types.SET_PROJECTS} | ${'projects'} | ${gapiProjectsResponseMock.projects}
${types.SET_ZONES} | ${'zones'} | ${gapiZonesResponseMock.items}
${types.SET_MACHINE_TYPES} | ${'machineTypes'} | ${gapiMachineTypesResponseMock.items}
${types.SET_MACHINE_TYPE} | ${'selectedMachineType'} | ${gapiMachineTypesResponseMock.items[0].name}
${types.SET_ZONE} | ${'selectedZone'} | ${gapiZonesResponseMock.items[0].name}
${types.SET_PROJECT} | ${'selectedProject'} | ${gapiProjectsResponseMock.projects[0]}
${types.SET_PROJECT_BILLING_STATUS} | ${'projectHasBillingEnabled'} | ${true}
${types.SET_IS_VALIDATING_PROJECT_BILLING} | ${'isValidatingProjectBilling'} | ${true}
`('$mutation', ({ mutation, stateProperty, mockData }) => {
it(`should set the mutation payload to the ${stateProperty} state property`, () => {
const state = createState();
expect(state[stateProperty]).not.toBe(mockData);
mutations[mutation](state, mockData);
expect(state[stateProperty]).toBe(mockData);
});
});
});
......@@ -9,11 +9,13 @@ describe ::PodLogs::BaseService do
let(:namespace) { 'autodevops-deploy-9-production' }
let(:pod_name) { 'pod-1' }
let(:pod_name_2) { 'pod-2' }
let(:container_name) { 'container-0' }
let(:params) { {} }
let(:raw_pods) do
JSON.parse([
kube_pod(name: pod_name)
kube_pod(name: pod_name),
kube_pod(name: pod_name_2)
].to_json, object_class: OpenStruct)
end
......@@ -115,7 +117,7 @@ describe ::PodLogs::BaseService do
result = subject.send(:get_pod_names, raw_pods: raw_pods)
expect(result[:status]).to eq(:success)
expect(result[:pods]).to eq([pod_name])
expect(result[:pods]).to eq([pod_name, pod_name_2])
end
end
end
......@@ -9,16 +9,20 @@ describe ::PodLogs::KubernetesService do
let(:namespace) { 'autodevops-deploy-9-production' }
let(:pod_name) { 'pod-1' }
let(:pod_name_2) { 'pod-2' }
let(:container_name) { 'container-0' }
let(:container_name_2) { 'foo-0' }
let(:params) { {} }
let(:raw_logs) do
"2019-12-13T14:04:22.123456Z Log 1\n2019-12-13T14:04:23.123456Z Log 2\n" \
"2019-12-13T14:04:24.123456Z Log 3"
end
let(:raw_pods) do
JSON.parse([
kube_pod(name: pod_name)
kube_pod(name: pod_name),
kube_pod(name: pod_name_2, container_name: container_name_2)
].to_json, object_class: OpenStruct)
end
......@@ -220,12 +224,12 @@ describe ::PodLogs::KubernetesService do
it 'returns success if container_name was not specified and there are containers' do
result = subject.send(:check_container_name,
pod_name: pod_name,
pod_name: pod_name_2,
raw_pods: raw_pods
)
expect(result[:status]).to eq(:success)
expect(result[:container_name]).to eq(container_name)
expect(result[:container_name]).to eq(container_name_2)
end
it 'returns error if container_name was not specified and there are no containers on the pod' do
......
......@@ -489,7 +489,7 @@ module KubernetesHelpers
# This is a partial response, it will have many more elements in reality but
# these are the ones we care about at the moment
def kube_pod(name: "kube-pod", environment_slug: "production", namespace: "project-namespace", project_slug: "project-path-slug", status: "Running", track: nil)
def kube_pod(name: "kube-pod", container_name: "container-0", environment_slug: "production", namespace: "project-namespace", project_slug: "project-path-slug", status: "Running", track: nil)
{
"metadata" => {
"name" => name,
......@@ -506,8 +506,8 @@ module KubernetesHelpers
},
"spec" => {
"containers" => [
{ "name" => "container-0" },
{ "name" => "container-1" }
{ "name" => "#{container_name}" },
{ "name" => "#{container_name}-1" }
]
},
"status" => { "phase" => status }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment