Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Merge main into release-v0.5 #1947

Merged
merged 6 commits into from
Oct 28, 2020
Merged
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
26 changes: 13 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
needs: version
env:
CLI_VERSION: ${{ needs.version.outputs.version }}
VERSION: ${{ needs.version.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
Expand Down Expand Up @@ -53,43 +53,43 @@ jobs:
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/osm-${{ env.CLI_VERSION }}-darwin-amd64.zip"
asset_name: "osm-${{ env.CLI_VERSION }}-darwin-amd64.zip"
asset_path: "_dist/osm-${{ env.VERSION }}-darwin-amd64.zip"
asset_name: "osm-${{ env.VERSION }}-darwin-amd64.zip"
asset_content_type: application/zip
- name: Upload macOS .tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/osm-${{ env.CLI_VERSION }}-darwin-amd64.tar.gz"
asset_name: "osm-${{ env.CLI_VERSION }}-darwin-amd64.tar.gz"
asset_path: "_dist/osm-${{ env.VERSION }}-darwin-amd64.tar.gz"
asset_name: "osm-${{ env.VERSION }}-darwin-amd64.tar.gz"
asset_content_type: application/gzip
- name: Upload Linux .zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/osm-${{ env.CLI_VERSION }}-linux-amd64.zip"
asset_name: "osm-${{ env.CLI_VERSION }}-linux-amd64.zip"
asset_path: "_dist/osm-${{ env.VERSION }}-linux-amd64.zip"
asset_name: "osm-${{ env.VERSION }}-linux-amd64.zip"
asset_content_type: application/zip
- name: Upload Linux .tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/osm-${{ env.CLI_VERSION }}-linux-amd64.tar.gz"
asset_name: "osm-${{ env.CLI_VERSION }}-linux-amd64.tar.gz"
asset_path: "_dist/osm-${{ env.VERSION }}-linux-amd64.tar.gz"
asset_name: "osm-${{ env.VERSION }}-linux-amd64.tar.gz"
asset_content_type: application/gzip
- name: Upload Windows .zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/osm-${{ env.CLI_VERSION }}-windows-amd64.zip"
asset_name: "osm-${{ env.CLI_VERSION }}-windows-amd64.zip"
asset_path: "_dist/osm-${{ env.VERSION }}-windows-amd64.zip"
asset_name: "osm-${{ env.VERSION }}-windows-amd64.zip"
asset_content_type: application/zip
- name: Upload Windows .tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/osm-${{ env.CLI_VERSION }}-windows-amd64.tar.gz"
asset_name: "osm-${{ env.CLI_VERSION }}-windows-amd64.tar.gz"
asset_path: "_dist/osm-${{ env.VERSION }}-windows-amd64.tar.gz"
asset_name: "osm-${{ env.VERSION }}-windows-amd64.tar.gz"
asset_content_type: application/gzip
- name: Upload Checksums
uses: actions/upload-release-asset@v1
Expand Down
4 changes: 2 additions & 2 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ type MeshCataloger interface {
// GetServicesForServiceAccount returns a list of services corresponding to a service account
GetServicesForServiceAccount(service.K8sServiceAccount) ([]service.MeshService, error)

// GetHostnamesForService returns the hostnames for a service
GetHostnamesForService(service service.MeshService) (string, error)
// GetResolvableHostnamesForUpstreamService returns the hostnames over which an upstream service is accessible from a downstream service
GetResolvableHostnamesForUpstreamService(downstream, upstream service.MeshService) ([]string, error)

//GetWeightedClusterForService returns the weighted cluster for a service
GetWeightedClusterForService(service service.MeshService) (service.WeightedCluster, error)
Expand Down
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ GOPATH = $(shell go env GOPATH)
GOBIN = $(GOPATH)/bin
GOX = go run github.com/mitchellh/gox

CLI_VERSION ?= dev
CONTROLLER_VERSION = $$(git describe --abbrev=0 --tags --match "v*")
VERSION ?= dev
BUILD_DATE=$$(date +%Y-%m-%d-%H:%M)
GIT_SHA=$$(git rev-parse HEAD)
BUILD_DATE_VAR := github.com/openservicemesh/osm/pkg/version.BuildDate
BUILD_VERSION_VAR := github.com/openservicemesh/osm/pkg/version.Version
BUILD_GITCOMMIT_VAR := github.com/openservicemesh/osm/pkg/version.GitCommit

LDFLAGS ?= "-X $(BUILD_DATE_VAR)=$(BUILD_DATE) -X $(BUILD_VERSION_VAR)=$(CLI_VERSION) -X $(BUILD_GITCOMMIT_VAR)=$(GIT_SHA) -X main.chartTGZSource=$$(cat -) -s -w"
LDFLAGS ?= "-X $(BUILD_DATE_VAR)=$(BUILD_DATE) -X $(BUILD_VERSION_VAR)=$(VERSION) -X $(BUILD_GITCOMMIT_VAR)=$(GIT_SHA) -X main.chartTGZSource=$$(cat -) -s -w"

# These two values are combined and passed to go test
E2E_FLAGS ?= -kindCluster
Expand All @@ -46,7 +45,7 @@ build: build-osm-controller

.PHONY: build-osm-controller
build-osm-controller: clean-osm-controller
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./bin/osm-controller/osm-controller -ldflags "-X $(BUILD_DATE_VAR)=$(BUILD_DATE) -X $(BUILD_VERSION_VAR)=$(CONTROLLER_VERSION) -X $(BUILD_GITCOMMIT_VAR)=$(GIT_SHA) -s -w" ./cmd/osm-controller
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./bin/osm-controller/osm-controller -ldflags "-X $(BUILD_DATE_VAR)=$(BUILD_DATE) -X $(BUILD_VERSION_VAR)=$(VERSION) -X $(BUILD_GITCOMMIT_VAR)=$(GIT_SHA) -s -w" ./cmd/osm-controller

.PHONY: build-osm
build-osm:
Expand Down Expand Up @@ -169,8 +168,8 @@ dist:
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf osm-${CLI_VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r osm-${CLI_VERSION}-{}.zip {} \; && \
$(DIST_DIRS) tar -zcf osm-${VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r osm-${VERSION}-{}.zip {} \; && \
sha256sum osm-* > sha256sums.txt \
)

Expand Down
2 changes: 1 addition & 1 deletion charts/osm/templates/mutatingwebhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ webhooks:
service:
name: osm-controller
namespace: {{.Release.Namespace}}
path: /mutate
path: /mutate-pod-creation
port: 443
failurePolicy: Fail
matchPolicy: Exact
Expand Down
2 changes: 1 addition & 1 deletion charts/osm/templates/osm-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
resources:
limits:
cpu: 1.5
memory: 128M
memory: 256M
requests:
cpu: 0.5
memory: 32M
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ var _ = Describe("Resolving values for install command with vault parameters", f
enableGrafana: false,
enableFluentbit: false,

envoyLogLevel: testEnvoyLogLevel,
envoyLogLevel: testEnvoyLogLevel,
}

vals, err = installCmd.resolveValues()
Expand Down
2 changes: 1 addition & 1 deletion cmd/osm-controller/osm-controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ = Describe("Test creation of CA bundle k8s secret", func() {

actual, err := k8sClient.CoreV1().Secrets(namespace).Get(context.Background(), secretName, v1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
expected := "-----BEGIN CERTIFICATE-----\nMIIF"
expected := "-----BEGIN CERTIFICATE-----\nMIID"
stringPEM := string(actual.Data[constants.KubernetesOpaqueSecretCAKey])[:len(expected)]
Expect(stringPEM).To(Equal(expected))

Expand Down
31 changes: 16 additions & 15 deletions pkg/catalog/mock_catalog.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 27 additions & 23 deletions pkg/catalog/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,59 +130,63 @@ func hostnamesTostr(hostnames []string) string {
return strings.Join(hostnames, ",")
}

// GetHostnamesForService returns the hostnames for a service.
// The hostname can be the FQDN for the service, and can include ports as well.
// GetResolvableHostnamesForUpstreamService returns the hostnames over which an upstream service is accessible from a downstream service
// The hostname is the FQDN for the service, and can include ports as well.
// Ex. bookstore.default, bookstore.default:80, bookstore.default.svc, bookstore.default.svc:80 etc.
func (mc *MeshCatalog) GetHostnamesForService(meshService service.MeshService) (string, error) {
log.Trace().Msgf("Finding domain for service %s", meshService)
func (mc *MeshCatalog) GetResolvableHostnamesForUpstreamService(downstream, upstream service.MeshService) ([]string, error) {
sameNamespace := downstream.Namespace == upstream.Namespace
var svcHostnames []string

if mc.configurator.IsPermissiveTrafficPolicyMode() {
hostnames, err := mc.getServiceHostnames(meshService)
hostnames, err := mc.getServiceHostnames(upstream, sameNamespace)
if err != nil {
log.Error().Err(err).Msgf("Error getting service hostnames for MeshService %s", meshService)
return "", err
log.Error().Err(err).Msgf("Error getting service hostnames for upstream service %s", upstream)
return svcHostnames, err
}
return hostnamesTostr(hostnames), nil
return hostnames, nil
}

// Retrieve the domain name from traffic split
// If this service is referenced in a traffic split
// Retrieve the domain name from traffic split root service
servicesList := mc.meshSpec.ListTrafficSplitServices()
for _, activeService := range servicesList {
if activeService.Service == meshService {
log.Trace().Msgf("Getting hostnames for service %s", meshService)
if activeService.Service == upstream {
log.Trace().Msgf("Getting hostnames for service %s", upstream)
rootServiceName := kubernetes.GetServiceFromHostname(activeService.RootService)
rootMeshService := service.MeshService{
Namespace: meshService.Namespace,
Namespace: upstream.Namespace,
Name: rootServiceName,
}
hostnames, err := mc.getServiceHostnames(rootMeshService)
hostnames, err := mc.getServiceHostnames(rootMeshService, sameNamespace)
if err != nil {
log.Error().Err(err).Msgf("Error getting service hostnames for Apex service %s", rootMeshService)
return "", err
return svcHostnames, err
}
return hostnamesTostr(hostnames), nil
svcHostnames = append(svcHostnames, hostnames...)
}
}

// This service is not a backend for a traffic split policy.
// The hostnames for this service are the Kubernetes service DNS names.
hostnames, err := mc.getServiceHostnames(meshService)
hostnames, err := mc.getServiceHostnames(upstream, sameNamespace)
if err != nil {
log.Error().Err(err).Msgf("Error getting service hostnames for MeshService %s", meshService)
return "", err
log.Error().Err(err).Msgf("Error getting service hostnames for upstream service %s", upstream)
return svcHostnames, err
}

return hostnamesTostr(hostnames), nil
svcHostnames = append(svcHostnames, hostnames...)
return svcHostnames, nil
}

// getServiceHostnames returns a list of hostnames corresponding to the service
func (mc *MeshCatalog) getServiceHostnames(meshService service.MeshService) ([]string, error) {
// getServiceHostnames returns a list of hostnames corresponding to the service.
// If the service is in the same namespace, it returns the shorthand hostname for the service that does not
// include its namespace, ex: bookstore, bookstore:80
func (mc *MeshCatalog) getServiceHostnames(meshService service.MeshService, sameNamespace bool) ([]string, error) {
svc := mc.kubeController.GetService(meshService)
if svc == nil {
return nil, errors.Errorf("Error fetching service %q", meshService)
}

hostnames := kubernetes.GetHostnamesForService(svc)
hostnames := kubernetes.GetHostnamesForService(svc, sameNamespace)
return hostnames, nil
}

Expand Down
Loading