Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into route-unification
Browse files Browse the repository at this point in the history
  • Loading branch information
fasaxc committed Aug 7, 2024
2 parents d01fa34 + ac7af84 commit 9d0cd21
Show file tree
Hide file tree
Showing 99 changed files with 28,165 additions and 44,421 deletions.
18 changes: 18 additions & 0 deletions .semaphore/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,21 @@ blocks:
- ./.semaphore/clean-up-vms ${VM_PREFIX}
secrets:
- name: google-service-account-for-gce

- name: Clean up windows resources
dependencies: []
task:
prologue:
commands:
- checkout
- az login --service-principal -u "${AZ_SP_ID}" -p "${AZ_SP_PASSWORD}" --tenant "${AZ_TENANT_ID}" --output none
- cd process/testing/util
jobs:
- name: Clean up windows felix resources
commands:
- ./delete-az-rg.sh ${USER}-capz-win-felix-${SEMAPHORE_WORKFLOW_ID:0:8}-rg
- name: Clean up windows cni resources
commands:
- ./delete-az-rg.sh ${USER}-capz-win-cni-${SEMAPHORE_WORKFLOW_ID:0:8}-rg
secrets:
- name: banzai-secrets
13 changes: 7 additions & 6 deletions .semaphore/semaphore-scheduled-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ blocks:
- cni-plugin
task:
secrets:
- name: azure-dev-ci
- name: banzai-secrets
prologue:
commands:
# Prepare azure configuration.
- az login --service-principal -u "${AZ_USER}" -p "${AZ_PASS}" --tenant "${AZ_TENANT}" --output none
- az login --service-principal -u "${AZ_SP_ID}" -p "${AZ_SP_PASSWORD}" --tenant "${AZ_TENANT_ID}" --output none
- export AZURE_SUBSCRIPTION_ID=$AZ_SUBSCRIPTION_ID
- export AZURE_TENANT_ID=$AZ_TENANT
- export AZURE_CLIENT_ID=$AZ_USER
- export AZURE_CLIENT_SECRET=$AZ_PASS
- export AZURE_TENANT_ID=$AZ_TENANT_ID
- export AZURE_CLIENT_ID=$AZ_SP_ID
- export AZURE_CLIENT_SECRET=$AZ_SP_PASSWORD
- export AZURE_RESOURCE_GROUP=${USER}-capz-win-cni-${SEMAPHORE_WORKFLOW_ID:0:8}-rg
- export REPORT_DIR=/home/semaphore/calico/process/testing/winfv-cni-plugin/report
- export LOGS_DIR=~/fv.log
- export SHORT_WORKFLOW_ID=$(echo ${SEMAPHORE_WORKFLOW_ID} | sha256sum | cut -c -8)
Expand Down Expand Up @@ -381,7 +382,7 @@ blocks:
- name: private-repo
prologue:
commands:
- export REPORT_DIR=/home/semaphore/calico/process/testing/winfv/report
- export REPORT_DIR=/home/semaphore/report
- export AZURE_SUBSCRIPTION_ID=$AZ_SUBSCRIPTION_ID
- export AZURE_TENANT_ID=$AZ_TENANT_ID
- export AZURE_CLIENT_ID=$AZ_SP_ID
Expand Down
13 changes: 7 additions & 6 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ blocks:
- cni-plugin
task:
secrets:
- name: azure-dev-ci
- name: banzai-secrets
prologue:
commands:
# Prepare azure configuration.
- az login --service-principal -u "${AZ_USER}" -p "${AZ_PASS}" --tenant "${AZ_TENANT}" --output none
- az login --service-principal -u "${AZ_SP_ID}" -p "${AZ_SP_PASSWORD}" --tenant "${AZ_TENANT_ID}" --output none
- export AZURE_SUBSCRIPTION_ID=$AZ_SUBSCRIPTION_ID
- export AZURE_TENANT_ID=$AZ_TENANT
- export AZURE_CLIENT_ID=$AZ_USER
- export AZURE_CLIENT_SECRET=$AZ_PASS
- export AZURE_TENANT_ID=$AZ_TENANT_ID
- export AZURE_CLIENT_ID=$AZ_SP_ID
- export AZURE_CLIENT_SECRET=$AZ_SP_PASSWORD
- export AZURE_RESOURCE_GROUP=${USER}-capz-win-cni-${SEMAPHORE_WORKFLOW_ID:0:8}-rg
- export REPORT_DIR=/home/semaphore/calico/process/testing/winfv-cni-plugin/report
- export LOGS_DIR=~/fv.log
- export SHORT_WORKFLOW_ID=$(echo ${SEMAPHORE_WORKFLOW_ID} | sha256sum | cut -c -8)
Expand Down Expand Up @@ -381,7 +382,7 @@ blocks:
- name: private-repo
prologue:
commands:
- export REPORT_DIR=/home/semaphore/calico/process/testing/winfv/report
- export REPORT_DIR=/home/semaphore/report
- export AZURE_SUBSCRIPTION_ID=$AZ_SUBSCRIPTION_ID
- export AZURE_TENANT_ID=$AZ_TENANT_ID
- export AZURE_CLIENT_ID=$AZ_SP_ID
Expand Down
11 changes: 6 additions & 5 deletions .semaphore/semaphore.yml.d/blocks/20-cni-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
- cni-plugin
task:
secrets:
- name: azure-dev-ci
- name: banzai-secrets
prologue:
commands:
# Prepare azure configuration.
- az login --service-principal -u "${AZ_USER}" -p "${AZ_PASS}" --tenant "${AZ_TENANT}" --output none
- az login --service-principal -u "${AZ_SP_ID}" -p "${AZ_SP_PASSWORD}" --tenant "${AZ_TENANT_ID}" --output none
- export AZURE_SUBSCRIPTION_ID=$AZ_SUBSCRIPTION_ID
- export AZURE_TENANT_ID=$AZ_TENANT
- export AZURE_CLIENT_ID=$AZ_USER
- export AZURE_CLIENT_SECRET=$AZ_PASS
- export AZURE_TENANT_ID=$AZ_TENANT_ID
- export AZURE_CLIENT_ID=$AZ_SP_ID
- export AZURE_CLIENT_SECRET=$AZ_SP_PASSWORD
- export AZURE_RESOURCE_GROUP=${USER}-capz-win-cni-${SEMAPHORE_WORKFLOW_ID:0:8}-rg
- export REPORT_DIR=/home/semaphore/calico/process/testing/winfv-cni-plugin/report
- export LOGS_DIR=~/fv.log
- export SHORT_WORKFLOW_ID=$(echo ${SEMAPHORE_WORKFLOW_ID} | sha256sum | cut -c -8)
Expand Down
2 changes: 1 addition & 1 deletion .semaphore/semaphore.yml.d/blocks/20-felix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
- name: private-repo
prologue:
commands:
- export REPORT_DIR=/home/semaphore/calico/process/testing/winfv/report
- export REPORT_DIR=/home/semaphore/report
- export AZURE_SUBSCRIPTION_ID=$AZ_SUBSCRIPTION_ID
- export AZURE_TENANT_ID=$AZ_TENANT_ID
- export AZURE_CLIENT_ID=$AZ_SP_ID
Expand Down
5 changes: 5 additions & 0 deletions apiserver/pkg/storage/calico/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func CreateClientFromConfig() clientv3.Interface {
os.Exit(1)
}

// if QPS not set in config, set default QPS
if cfg.Spec.K8sClientQPS == float32(0) {
cfg.Spec.K8sClientQPS = 50
}

c, err := clientv3.New(*cfg)
if err != nil {
klog.Errorf("Failed creating client: %q", err)
Expand Down
6 changes: 3 additions & 3 deletions calicoctl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ st: bin/calicoctl-linux-$(ARCH) version-helper
$(MAKE) stop-kubernetes-master

## Run a local kubernetes master with API
# TODO: Commonize this with the functions in lib.Makefile.
# TODO: Commonize this with the functions in lib.Makefile.
# For now, these tests do something special and launch two apiserver on different ports, so it makes sense
# to keep them separate.
run-kubernetes-master: stop-kubernetes-master
Expand Down Expand Up @@ -233,7 +233,7 @@ run-kubernetes-master: stop-kubernetes-master
-docker exec -ti st-apiserver-${KUBE_APISERVER_PORT} kubectl \
--server=https://127.0.0.1:${KUBE_APISERVER_PORT} \
create namespace test

## Stop the local kubernetes master
stop-kubernetes-master:
# Delete the cluster role binding.
Expand All @@ -259,7 +259,7 @@ cd: image-all cd-common
# Release
###############################################################################
## Produces a clean build of release artifacts at the specified version.
release-build: .release-$(VERSION).created
release-build: .release-$(VERSION).created
.release-$(VERSION).created:
$(MAKE) clean build-all image-all RELEASE=true
$(MAKE) retag-build-images-with-registries IMAGETAG=$(VERSION) RELEASE=true
Expand Down
19 changes: 4 additions & 15 deletions calicoctl/calicoctl/commands/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,7 @@ Description:
Valid resource types are:
* bgpConfiguration
* bgpPeer
* felixConfiguration
* globalNetworkPolicy
* globalNetworkSet
* hostEndpoint
* ipPool
* ipReservation
* kubeControllersConfiguration
* networkPolicy
* networkSet
* node
* profile
* workloadEndpoint
<RESOURCE_LIST>
When applying a resource:
- if the resource does not already exist (as determined by it's primary
identifiers) then it is created
Expand All @@ -99,6 +85,9 @@ Description:
name, _ := util.NameAndDescription()
doc = strings.ReplaceAll(doc, "<BINARY_NAME>", name)

// Replace <RESOURCE_LIST> with the list of resource types.
doc = strings.Replace(doc, "<RESOURCE_LIST>", util.Resources(), 1)

parsedArgs, err := docopt.ParseArgs(doc, args, "")
if err != nil {
return fmt.Errorf("Invalid option: 'calicoctl %s'. Use flag '--help' to read about a specific subcommand.", strings.Join(args, " "))
Expand Down
19 changes: 4 additions & 15 deletions calicoctl/calicoctl/commands/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,7 @@ Description:
Valid resource types are:
* bgpConfiguration
* bgpPeer
* felixConfiguration
* globalNetworkPolicy
* globalNetworkSet
* hostEndpoint
* ipPool
* ipReservation
* kubeControllersConfiguration
* networkPolicy
* networkSet
* node
* profile
* workloadEndpoint
<RESOURCE_LIST>
Attempting to create a resource that already exists is treated as a
terminating error unless the --skip-exists flag is set. If this flag is set,
resources that already exist are skipped.
Expand All @@ -96,6 +82,9 @@ Description:
name, _ := util.NameAndDescription()
doc = strings.ReplaceAll(doc, "<BINARY_NAME>", name)

// Replace <RESOURCE_LIST> with the list of resource types.
doc = strings.Replace(doc, "<RESOURCE_LIST>", util.Resources(), 1)

parsedArgs, err := docopt.ParseArgs(doc, args, "")
if err != nil {
return fmt.Errorf("Invalid option: 'calicoctl %s'. Use flag '--help' to read about a specific subcommand.", strings.Join(args, " "))
Expand Down
42 changes: 20 additions & 22 deletions calicoctl/calicoctl/commands/datastore/migrate/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"

"github.com/docopt/docopt-go"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -57,6 +57,8 @@ var allV3Resources []string = []string{
"nodes",
"bgpconfigs",
"felixconfigs",
"ipreservations",
"bgpfilters",
}

var resourceDisplayMap map[string]string = map[string]string{
Expand All @@ -65,7 +67,7 @@ var resourceDisplayMap map[string]string = map[string]string{
"ipamhandles": "IPAMHandles",
"ipamconfigs": "IPAMConfigurations",
"ippools": "IPPools",
"bgpconfig": "BGPConfigurations",
"bgpconfigs": "BGPConfigurations",
"bgppeers": "BGPPeers",
"clusterinfos": "ClusterInformations",
"felixconfigs": "FelixConfigurations",
Expand All @@ -76,11 +78,13 @@ var resourceDisplayMap map[string]string = map[string]string{
"networkpolicies": "NetworkPolicies",
"networksets": "Networksets",
"nodes": "Nodes",
"ipreservations": "IPReservations",
"bgpfilters": "BGPFilters",
}

var namespacedResources map[string]struct{} = map[string]struct{}{
"networkpolicies": struct{}{},
"networksets": struct{}{},
"networkpolicies": {},
"networksets": {},
}

func Export(args []string) error {
Expand All @@ -99,32 +103,26 @@ Description:
in yaml and json format. Save the results of this command to a file for
later use with the import command.
The resources exported include the following:
- IPAMBlocks
- BlockAffinities
- IPAMHandles
- IPAMConfigurations
- IPPools
- BGPConfigurations
- BGPPeers
- ClusterInformations
- FelixConfigurations
- GlobalNetworkPolicies
- GlobalNetworkSets
- HostEndpoints
- KubeControllersConfigurations
- NetworkPolicies
- Networksets
- Nodes
The following resources are exported:
<RESOURCE_LIST>
The following resources are not exported:
- WorkloadEndpoints
- Profiles
`
// Replace all instances of BINARY_NAME with the name of the binary.
name, _ := util.NameAndDescription()
doc = strings.ReplaceAll(doc, "<BINARY_NAME>", name)

// Replace <RESOURCE_LIST> with the list of resources that will be exported.
resourceList := ""
for _, r := range allV3Resources {
resourceList += fmt.Sprintf(" - %s\n", resourceDisplayMap[r])
}
doc = strings.Replace(doc, "<RESOURCE_LIST>", resourceList, 1)

parsedArgs, err := docopt.ParseArgs(doc, args, "")
if err != nil {
return fmt.Errorf("Invalid option: 'calicoctl %s'. Use flag '--help' to read about a specific subcommand.", strings.Join(args, " "))
Expand Down Expand Up @@ -157,7 +155,7 @@ Description:
// Check that the datastore configured datastore is etcd
cfg, err := clientmgr.LoadClientConfig(cf)
if err != nil {
log.Info("Error loading config")
logrus.Info("Error loading config")
return err
}

Expand Down
19 changes: 4 additions & 15 deletions calicoctl/calicoctl/commands/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,7 @@ Description:
Valid resource types are:
* bgpConfiguration
* bgpPeer
* felixConfiguration
* globalNetworkPolicy
* globalNetworkSet
* hostEndpoint
* ipPool
* ipReservation
* kubeControllersConfiguration
* networkPolicy
* networkSet
* node
* profile
* workloadEndpoint
<RESOURCE_LIST>
The resource type is case-insensitive and may be pluralized.
Attempting to delete a resource that does not exists is treated as a
Expand All @@ -108,6 +94,9 @@ Description:
name, _ := util.NameAndDescription()
doc = strings.ReplaceAll(doc, "<BINARY_NAME>", name)

// Replace <RESOURCE_LIST> with the list of resource types.
doc = strings.Replace(doc, "<RESOURCE_LIST>", util.Resources(), 1)

parsedArgs, err := docopt.ParseArgs(doc, args, "")
if err != nil {
return fmt.Errorf("Invalid option: 'calicoctl %s'. Use flag '--help' to read about a specific subcommand.", strings.Join(args, " "))
Expand Down
23 changes: 6 additions & 17 deletions calicoctl/calicoctl/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
package commands

import (
"github.com/docopt/docopt-go"

"fmt"
"os"
"strings"

"github.com/docopt/docopt-go"

log "github.com/sirupsen/logrus"

"github.com/projectcalico/calico/calicoctl/calicoctl/commands/argutils"
Expand Down Expand Up @@ -74,21 +74,7 @@ Description:
Valid resource types are:
* bgpConfiguration
* bgpPeer
* felixConfiguration
* globalNetworkPolicy
* globalNetworkSet
* hostEndpoint
* ipPool
* ipReservation
* kubeControllersConfiguration
* networkPolicy
* networkSet
* node
* profile
* workloadEndpoint
<RESOURCE_LIST>
The resource type is case-insensitive and may be pluralized.
Attempting to get resources that do not exist will simply return no results.
Expand Down Expand Up @@ -127,6 +113,9 @@ Description:
name, _ := util.NameAndDescription()
doc = strings.ReplaceAll(doc, "<BINARY_NAME>", name)

// Replace <RESOURCE_LIST> with the list of resource types.
doc = strings.Replace(doc, "<RESOURCE_LIST>", util.Resources(), 1)

// -a option Backward compatibility
for k, v := range args {
if v == "-a" {
Expand Down
Loading

0 comments on commit 9d0cd21

Please sign in to comment.