diff --git a/.github/workflows/docs-deploy.yaml b/.github/workflows/docs-deploy.yaml deleted file mode 100644 index 3e5ddf2ebf35..000000000000 --- a/.github/workflows/docs-deploy.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Docs Deploy Preview - -on: - workflow_run: - workflows: ["Docs Build"] - types: - - completed - -permissions: - actions: read - deployments: write - -jobs: - deploy: - name: Deploy Preview - if: github.event.workflow_run.conclusion == 'success' - runs-on: arc-runner-set - timeout-minutes: 5 - continue-on-error: true - environment: - name: docs-preview - steps: - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: docs-site - path: site - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ github.token }} - - name: Read PR number - id: pr - run: echo "number=$(cat site/pr-number.txt)" >> "$GITHUB_OUTPUT" - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - with: - node-version: '20' - env: - npm_config_cache: ${{ runner.temp }}/.npm - - name: Deploy to Cloudflare Pages - env: - npm_config_cache: ${{ runner.temp }}/.npm - uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy site --project-name=hypershift --branch=pr-${{ steps.pr.outputs.number }} --commit-dirty=true - - name: Create PR deployment status - env: - GITHUB_TOKEN: ${{ github.token }} - PR_NUMBER: ${{ steps.pr.outputs.number }} - HEAD_SHA: ${{ github.event.workflow_run.head_sha }} - REPO: ${{ github.repository }} - run: | - if ! [[ "${PR_NUMBER}" =~ ^[0-9]+$ ]]; then - echo "Invalid PR number: '${PR_NUMBER}'" - exit 1 - fi - DEPLOY_ENV="docs-preview/pr-${PR_NUMBER}" - ENV_URL="https://pr-${PR_NUMBER}.hypershift.pages.dev" - - DEPLOY_ID=$(curl -fsSL \ - -X POST \ - -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/${REPO}/deployments" \ - -d '{"ref":"'"${HEAD_SHA}"'","environment":"'"${DEPLOY_ENV}"'","auto_merge":false,"required_contexts":[]}' \ - | jq -r '.id') - if ! [[ "${DEPLOY_ID}" =~ ^[0-9]+$ ]]; then - echo "Failed to create deployment. DEPLOY_ID='${DEPLOY_ID}'" - exit 1 - fi - - curl -fsSL \ - -X POST \ - -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/${REPO}/deployments/${DEPLOY_ID}/statuses" \ - -d '{"state":"success","environment_url":"'"${ENV_URL}"'","description":"Docs preview for PR #'"${PR_NUMBER}"'"}' diff --git a/hypershift-operator/controllers/nodepool/config.go b/hypershift-operator/controllers/nodepool/config.go index 7dffe44d4a9a..ec8b6f0658c5 100644 --- a/hypershift-operator/controllers/nodepool/config.go +++ b/hypershift-operator/controllers/nodepool/config.go @@ -154,13 +154,7 @@ func NewConfigGenerator(ctx context.Context, client client.Client, hostedCluster return cg, nil } -// Compressed returns a gzipped artifact of the rawconfig. -// Prefer CompressedAndEncoded unless the CPO/your decompressor doesn't know how to handle base64 encoded data. -func (cg *ConfigGenerator) Compressed() (*bytes.Buffer, error) { - return supportutil.Compress([]byte(cg.mcoRawConfig)) -} - -// CompressedAndEncoded returns a gzipped and base-64 encodesd artifact of the raw config. +// CompressedAndEncoded returns a gzipped and base-64 encoded artifact of the raw config. func (cg *ConfigGenerator) CompressedAndEncoded() (*bytes.Buffer, error) { return supportutil.CompressAndEncode([]byte(cg.mcoRawConfig)) } diff --git a/hypershift-operator/controllers/nodepool/config_test.go b/hypershift-operator/controllers/nodepool/config_test.go index 2d8d2f67d652..959003ff513a 100644 --- a/hypershift-operator/controllers/nodepool/config_test.go +++ b/hypershift-operator/controllers/nodepool/config_test.go @@ -1,11 +1,8 @@ package nodepool import ( - "bytes" - "compress/gzip" "errors" "fmt" - "io" "testing" . "github.com/onsi/gomega" @@ -524,56 +521,6 @@ func TestCompressedAndEncoded(t *testing.T) { } } -func TestCompressed(t *testing.T) { - testCases := []struct { - name string - mcoRawConfig string - }{ - { - name: "When mcoRawConfig has content it should be possible to decompress", - mcoRawConfig: "test config", - }, - { - name: "When mcoRawConfig is empty it should be possible to decompress", - mcoRawConfig: "", - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - g := NewWithT(t) - cg := &ConfigGenerator{ - rolloutConfig: &rolloutConfig{ - mcoRawConfig: tc.mcoRawConfig, - }, - } - - compressed, err := cg.Compressed() - g.Expect(err).ToNot(HaveOccurred()) - - decompressed, err := decompress(compressed.Bytes()) - g.Expect(err).ToNot(HaveOccurred()) - g.Expect(string(decompressed)).To(Equal(tc.mcoRawConfig)) - }) - } -} - -func decompress(content []byte) ([]byte, error) { - if len(content) == 0 { - return nil, nil - } - gr, err := gzip.NewReader(bytes.NewBuffer(content)) - if err != nil { - return nil, fmt.Errorf("failed to uncompress content: %w", err) - } - defer gr.Close() - data, err := io.ReadAll(gr) - if err != nil { - return nil, fmt.Errorf("failed to read content: %w", err) - } - return data, nil -} - func TestHash(t *testing.T) { baseCaseMCORawConfig := "test config" baseCaseReleaseVersion := "4.7.0" diff --git a/hypershift-operator/controllers/nodepool/nodepool_controller.go b/hypershift-operator/controllers/nodepool/nodepool_controller.go index d26d090b8235..31d52791f3e2 100644 --- a/hypershift-operator/controllers/nodepool/nodepool_controller.go +++ b/hypershift-operator/controllers/nodepool/nodepool_controller.go @@ -82,15 +82,13 @@ const ( nodePoolAnnotationCanonicalDataPlaneImages = "hypershift.openshift.io/canonical-data-plane-images" nodePoolCoreIgnitionConfigLabel = "hypershift.openshift.io/core-ignition-config" - tuningConfigKey = "tuning" - tunedConfigMapLabel = "hypershift.openshift.io/tuned-config" - nodeTuningGeneratedConfigLabel = "hypershift.openshift.io/nto-generated-machine-config" - PerformanceProfileConfigMapLabel = "hypershift.openshift.io/performanceprofile-config" - NodeTuningGeneratedPerformanceProfileStatusLabel = "hypershift.openshift.io/nto-generated-performance-profile-status" - ContainerRuntimeConfigConfigMapLabel = "hypershift.openshift.io/containerruntimeconfig-config" - KubeletConfigConfigMapLabel = "hypershift.openshift.io/kubeletconfig-config" - controlPlaneOperatorManagesDecompressAndDecodeConfig = "io.openshift.hypershift.control-plane-operator-manages.decompress-decode-config" - + tuningConfigKey = "tuning" + tunedConfigMapLabel = "hypershift.openshift.io/tuned-config" + nodeTuningGeneratedConfigLabel = "hypershift.openshift.io/nto-generated-machine-config" + PerformanceProfileConfigMapLabel = "hypershift.openshift.io/performanceprofile-config" + NodeTuningGeneratedPerformanceProfileStatusLabel = "hypershift.openshift.io/nto-generated-performance-profile-status" + ContainerRuntimeConfigConfigMapLabel = "hypershift.openshift.io/containerruntimeconfig-config" + KubeletConfigConfigMapLabel = "hypershift.openshift.io/kubeletconfig-config" controlPlaneOperatorCreatesDefaultAWSSecurityGroup = "io.openshift.hypershift.control-plane-operator-creates-aws-sg" labelManagedPrefix = "managed.hypershift.openshift.io" @@ -116,7 +114,6 @@ type NotReadyError struct { } type CPOCapabilities struct { - DecompressAndDecodeConfig bool CreateDefaultAWSSecurityGroup bool } @@ -1051,7 +1048,6 @@ func (r *NodePoolReconciler) detectCPOCapabilities(ctx context.Context, hostedCl imageLabels := supportutil.ImageLabels(controlPlaneOperatorImageMetadata) result := &CPOCapabilities{} - _, result.DecompressAndDecodeConfig = imageLabels[controlPlaneOperatorManagesDecompressAndDecodeConfig] _, result.CreateDefaultAWSSecurityGroup = imageLabels[controlPlaneOperatorCreatesDefaultAWSSecurityGroup] return result, nil diff --git a/hypershift-operator/controllers/nodepool/token.go b/hypershift-operator/controllers/nodepool/token.go index 4c8daa216fbf..027a40d20174 100644 --- a/hypershift-operator/controllers/nodepool/token.go +++ b/hypershift-operator/controllers/nodepool/token.go @@ -331,16 +331,7 @@ func (t *Token) reconcileTokenSecret(tokenSecret *corev1.Secret) error { // 2. - Reconcile towards expected state of the world. compressedConfig, err := t.CompressedAndEncoded() if err != nil { - return fmt.Errorf("failed to compress and decode config: %w", err) - } - - // TODO (alberto): Drop this after dropping < 4.12 support. - // So all CPOs ign server will know to decompress and decode. - if !t.cpoCapabilities.DecompressAndDecodeConfig { - compressedConfig, err = t.Compressed() - if err != nil { - return fmt.Errorf("failed to compress config: %w", err) - } + return fmt.Errorf("failed to compress and encode config: %w", err) } tokenSecret.Data = map[string][]byte{} diff --git a/hypershift-operator/controllers/nodepool/token_test.go b/hypershift-operator/controllers/nodepool/token_test.go index 33df617a04ef..431e9923f999 100644 --- a/hypershift-operator/controllers/nodepool/token_test.go +++ b/hypershift-operator/controllers/nodepool/token_test.go @@ -627,9 +627,7 @@ func TestTokenReconcile(t *testing.T) { additionalTrustBundle, ignitionServerCACert, }, - cpoCapabilities: &CPOCapabilities{ - DecompressAndDecodeConfig: true, - }, + cpoCapabilities: &CPOCapabilities{}, }, { name: "when HostedCluster is restored from backup it should set ignition-reached annotation on the token secret", @@ -689,9 +687,7 @@ func TestTokenReconcile(t *testing.T) { additionalTrustBundle, ignitionServerCACert, }, - cpoCapabilities: &CPOCapabilities{ - DecompressAndDecodeConfig: true, - }, + cpoCapabilities: &CPOCapabilities{}, }, } diff --git a/karpenter-operator/controllers/karpenterignition/karpenterignition_controller.go b/karpenter-operator/controllers/karpenterignition/karpenterignition_controller.go index e28894a40585..85c273dd4eba 100644 --- a/karpenter-operator/controllers/karpenterignition/karpenterignition_controller.go +++ b/karpenter-operator/controllers/karpenterignition/karpenterignition_controller.go @@ -269,9 +269,7 @@ func (r *KarpenterIgnitionReconciler) reconcileNodeClassToken( return fmt.Errorf("failed to build config generator: %w", err) } - token, err := nodepool.NewToken(ctx, cg, &nodepool.CPOCapabilities{ - DecompressAndDecodeConfig: true, - }) + token, err := nodepool.NewToken(ctx, cg, &nodepool.CPOCapabilities{}) if err != nil { return fmt.Errorf("failed to create token: %w", err) } diff --git a/support/util/util.go b/support/util/util.go index 5b917a90b10b..993281ce3bda 100644 --- a/support/util/util.go +++ b/support/util/util.go @@ -103,19 +103,6 @@ func CompressAndEncode(payload []byte) (*bytes.Buffer, error) { return out, err } -// Compress compresses a given byte array. -func Compress(payload []byte) (*bytes.Buffer, error) { - in := bytes.NewBuffer(payload) - out := bytes.NewBuffer(nil) - - if len(payload) == 0 { - return out, nil - } - - err := compress(in, out) - return out, err -} - // DecodeAndDecompress decompresses and base-64 decodes a given byte array. Ideal for consuming a // gzipped / base64-encoded byte array from a ConfigMap or Secret. func DecodeAndDecompress(payload []byte) (*bytes.Buffer, error) {