Skip to content
Open
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
76 changes: 0 additions & 76 deletions .github/workflows/docs-deploy.yaml

This file was deleted.

8 changes: 1 addition & 7 deletions hypershift-operator/controllers/nodepool/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
53 changes: 0 additions & 53 deletions hypershift-operator/controllers/nodepool/config_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package nodepool

import (
"bytes"
"compress/gzip"
"errors"
"fmt"
"io"
"testing"

. "github.com/onsi/gomega"
Expand Down Expand Up @@ -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"
Expand Down
18 changes: 7 additions & 11 deletions hypershift-operator/controllers/nodepool/nodepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -116,7 +114,6 @@ type NotReadyError struct {
}

type CPOCapabilities struct {
DecompressAndDecodeConfig bool
CreateDefaultAWSSecurityGroup bool
}

Expand Down Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions hypershift-operator/controllers/nodepool/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
8 changes: 2 additions & 6 deletions hypershift-operator/controllers/nodepool/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -689,9 +687,7 @@ func TestTokenReconcile(t *testing.T) {
additionalTrustBundle,
ignitionServerCACert,
},
cpoCapabilities: &CPOCapabilities{
DecompressAndDecodeConfig: true,
},
cpoCapabilities: &CPOCapabilities{},
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 0 additions & 13 deletions support/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down